Results 1 to 5 of 5
  1. #1
    shabar is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jan 2013
    Posts
    66

    Count query takes too long time

    Hi All

    I have query (view) with lots of records and there I need to get a count. when I ran below query it takes lots of time but didn't get a result

    SELECT count(*)


    FROM Table1

    What could be the reason



    Cheers

    Shabar

  2. #2
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    define "lots of records" ...?? XP doesn't typically have gobs of RAM so possibly the record count really is excessive compared to the hardware.....

    but typically you need just the key field in the query (not all fields) if you are simply counting the table records...a simple aggregate query generally runs pretty fast.

  3. #3
    shabar is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jan 2013
    Posts
    66
    Hi NTC

    Thax for your quick reply

    Just a question currently I don't have primary key in my query. how to create primary key in select query. This is the saved query that I use to get the record count


    Cheers

    shabar

  4. #4
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    the key field exists in the table. it isn't created in the query. I suggested using the key field to count because there is always a value in every record where as some other field there may perhaps be nulls such that the count would not be of every record. If there is any field where you absolutely know there is always a value - then you can count that field alone.

    when I set up a count in an aggregate query, I select just 1 field to count. generally it is quite fast. I don't think counting just 1 field vs counting the whole record explains a significant time difference all things being equal; but when the table's record count approaches 1M or even 500k then older hardware / XP can go into never never land when the query requires alot of RAM....

    if your aggregate query is of another query rather than a table - then generally that explains why it is slow or going into never never land. in which case consider tweaking that underlying query to make it more efficient....strip out fields and remove any sorting....

  5. #5
    shabar is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jan 2013
    Posts
    66
    Thax mate

    cheers

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

Similar Threads

  1. Replies: 10
    Last Post: 04-17-2012, 10:29 AM
  2. Replies: 3
    Last Post: 10-13-2011, 02:27 PM
  3. Replies: 3
    Last Post: 12-23-2010, 10:23 AM
  4. Query Design View Takes a Long Time to Open
    By jackthedog in forum Queries
    Replies: 0
    Last Post: 12-22-2009, 03:27 PM
  5. ODBC and Long Query Time
    By pdouglas in forum Access
    Replies: 0
    Last Post: 07-09-2009, 10:21 AM

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