Which is Faster????

Results 1 to 6 of 6

Thread: Which is Faster????

  1. #1
    MG Guest

    Default Which is Faster????

    Which is faster. 1000&#039s of records<BR><BR>A group by query with the count function on the id field.<BR>or<BR>The recordcount method of the recordset.<BR><BR>Thanks

  2. #2
    Hmm.. Guest

    Default RE: Which is Faster????

    Here&#039s a thought... why not try it and see?<BR><BR>(Although it should be the first one)

  3. #3
    MG Guest

    Default Anyone Else??

    Anyone else have a answer?

  4. #4
    Egad. Guest

    Default RE: Anyone Else??

    In the time it&#039s taken you to write these questions, you could have tried it. <BR><BR>Assuming that the queries are the same (except for the COUNT operation), the query using the COUNT will be faster. Why? Let&#039s say your query returns 1000 records. That information will have to be marshalled between the SQL server (or Access) and the requesting thread/object. All of the work that goes on behind the scenes to create a recordset, read through the tables, populate the recordset, check indexes, etc. would have to occur. THEN, when you do a .RECORDCOUNT in your process, it has to physically read through ALL of the records in the recordset to provide you with that count. Using COUNT however, means that everything is done internally within SQL Server, and only ONE small bit of data has to be comunicated to the requesting thread/object.<BR><BR>Much faster, yes?

  5. #5
    MG Guest

    Default RE: Anyone Else??

    I could have tried it but I would not understand why like I do now. Thank You.

  6. #6
    Welcome. Guest

    Default RE: Anyone Else??

    Ahh, but you only asked which was faster, not why. ;-)<BR><BR>I just wrote a quickie script to test it out. Using the same query (except that one returns just the count) on only 500 records, here are the results:<BR><BR>1= .3789063 (return all records and use recordcount)<BR>Method 2= .1042969 (use COUNT)<BR><BR>So, almost 4 times faster.<BR><BR>Enjoy!<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts