Search Postgresql Archives

Re: [HACKERS] Much Ado About COUNT(*)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jan 14, 2005 at 12:39:04PM -0500, Frank D. Engel, Jr. wrote:
> This is probably stupid for some reason, but why not use a 64-bit 
> integer to track the number of records in the table? Increment when 
> adding records, decrement when deleting them... then COUNT(*) could 
> just return that in cases where a query is known to be looking at all 
> of the records?

Because there is no single value for count(*), if you're in a
transaction that has added records it will be bigger than in a
transaction that hasn't. How does your integer deal with this?

The usual solutions this involve locking, which is precisely what MVCC
is designed to avoid.

Hope this helps,
-- 
Martijn van Oosterhout   <kleptog@xxxxxxxxx>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

Attachment: pgpIElVcyjxf5.pgp
Description: PGP signature


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux