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@svana.org> 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.