Re: How can I count rows fast ?

From: Jae W. Chang <jae+_at_CMU.EDU>
Date: Thu, 16 Jun 1994 18:52:09 -0400
Message-ID: <8i0BSN200VAx8C61gW_at_andrew.cmu.edu>


kimmng_at_uswnvg.com (Kim Ng) writes:
> I do not understand how a computer can count something without going through
> the whole table (unless, of course, if there is a counter somewhere that is
> being kept --- I probably won't trust that counter anyway --- or you only
> want to count records that match a certain criteria).
>
> Logically, it will have to go through the whole table from top to bottom
> (like a person counting how many fingers he/she have). Any other way would
> be just guessing.
>
> I would love to hear if there is a short cut. I am sure billions of others
> would too.

Well, I haven't been following the entire thread, but it depends on implementation, how data structures are defined, other variables, etc.

If you wanted to count # of rows of constant size in a table, calculate the size of table and divide by size of rows, eg.

Given certain constraints, assumptions, hacks, etc. you CAN count w/o doing the human equivalent of counting w/ fingers.

Jae



jae+_at_cmu.edu Received on Fri Jun 17 1994 - 00:52:09 CEST

Original text of this message