From: | Martijn van Oosterhout <kleptog(at)svana(dot)org> |
---|---|
To: | "Frank D(dot) Engel, Jr(dot)" <fde101(at)fjrhome(dot)net> |
Cc: | Postgres general mailing list <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: [HACKERS] Much Ado About COUNT(*) |
Date: | 2005-01-14 18:38:39 |
Message-ID: | 20050114183835.GB1724@svana.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-hackers |
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(at)svana(dot)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.
From | Date | Subject | |
---|---|---|---|
Next Message | Bo Lorentsen | 2005-01-14 18:39:16 | Re: OID Usage |
Previous Message | Richard Huxton | 2005-01-14 18:38:16 | Re: [HACKERS] Much Ado About COUNT(*) |
From | Date | Subject | |
---|---|---|---|
Next Message | Frank D. Engel, Jr. | 2005-01-14 18:47:54 | Re: [HACKERS] Much Ado About COUNT(*) |
Previous Message | Richard Huxton | 2005-01-14 18:38:16 | Re: [HACKERS] Much Ado About COUNT(*) |