Results 1 to 4 of 4
  1. #1
    harpyopsis is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2009
    Posts
    2

    Counting large ADODB recordsets

    Hello all!

    I have a serious problem counting records in a large ADO rst in real time (user traveling on a 24-level MSComctl TreeView).

    The underlying data is a mdb file with 21 related tables (all one-to-many) representing the phylogeny of (all?) living Species (1.4 Gigs).

    Table1 ("Taxo00K") contains 8 Kingdoms, down to Table 20 ("Taxo20Species") which contains 1.1 mil. Species ID's. In between are 19 Tables with the 120 Classes, 1100 Orders, 7500 Families, Tribes, 110,000 Genera and so on. A long, -maybe too long, chain of 21 Tables...

    All ID's, look-up and Sort_order fields are properly indexed.

    Feeding the ADO rst with a very short SELECT (just the SpeciesID field), a necessarily huge FROM (cascading "INNER JOIN") and a simple WHERE clause ("FamilyID = MyLng") works very fine: RecordCount for some 1000's records is done in milliseconds.

    Problems arise when we need RecordCount for higher classification levels (e.g. the Order level), which may amounts to 100,000 records, and which is 10 steps above the bottom "Species" Table. That process can need 10 seconds!

    Generating a public rst at start-up, - or a private rst on Open (with the one mil. Species on which to perform rst.filter when needed), takes around 18 seconds. Way too long!

    Is there any method to improve this "Count" speed???

    Months ago, I had the upper classification levels ID's duplicated in the last "Species" Table and it performed well, but 1,000,000 times 21 long Int's is too heavy.

    ADO rst.filter and rst.sort work great, but RecordCount is far behind Dcount!

    Out of despair, I tried to fill the Dcount's domain with my SQL strings. Useless!

    Last: this Taxonomy Table is a Replica, connected to a front-end mdb/mde file with forms and modules for biodiversity and GIS.

    Any hint would be so highly appreciated!



    Many thanks!

  2. #2
    dcrake's Avatar
    dcrake is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2009
    Posts
    435
    When using large recordsets it is imperative that fields used for criteria conditions are primary keys from the source tables not the foreign keys in the target tables. Even with 1:m relates by querying the 1 side increases the return rate as it pulls the many records into it.

    David

  3. #3
    harpyopsis is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2009
    Posts
    2
    You are absolutely right David! The speed increase is obvious when you work on the primary keys of the source Tables! Have to!

    The solution to my problem was also very simple: a "SELECT Count []![] as Expr FROM (..Inner Join...) WHERE TableX.Rec_ID = MyLng"!

    Instant results...

    I now stop expecting too much from RecordCount!

    Have a very nice day in UK and thank you so much!

    phil

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows XP Access 2002
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Excellent! Thanks for sharing your solution. Follow the link in my sig if you want to mark the thread as Solved.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Linking large number of forms and tables
    By jlcaviglia-harris in forum Forms
    Replies: 2
    Last Post: 04-17-2009, 09:19 AM
  2. Median and Mode for a large table
    By brandon in forum Access
    Replies: 0
    Last Post: 05-08-2008, 09:26 AM
  3. Recordsets, add new, DAO and ADO
    By Arca in forum Programming
    Replies: 1
    Last Post: 04-07-2008, 03:57 PM
  4. Import large txt into access
    By klm127 in forum Import/Export Data
    Replies: 0
    Last Post: 04-23-2007, 06:22 AM
  5. How to extract names from 1 large field
    By Tepin in forum Access
    Replies: 1
    Last Post: 12-04-2006, 01:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums