From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Kevin Brown <kevin(at)sysexperts(dot)com> |
Cc: | pgsql-performance(at)postgresql(dot)org |
Subject: | Re: [SQL] Yet Another (Simple) Case of Index not used |
Date: | 2003-04-20 15:21:32 |
Message-ID: | 26961.1050852092@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-performance pgsql-sql |
Kevin Brown <kevin(at)sysexperts(dot)com> writes:
> This is why I suspect the best way to manage this would be to manage
> the counter itself using the MVCC mechanism (that is, you treat the
> shared counter as a row in a table just like any other and, in fact,
> it might be most beneficial for it to actually be exactly that), which
> handles the visibility problem automatically. But I don't know how
> much contention there would be as a result.
Hm. Contention probably wouldn't be the killer, since if transactions
don't try to update the count until they are about to commit, they won't
be holding the row lock for long. (You'd have to beware of deadlocks
between transactions that need to update multiple counters, but that
seems soluble.) What *would* be a problem is that such counter tables
would accumulate huge numbers of dead rows very quickly, making it
inefficient to find the live row. Josh already mentioned this as a
problem with user-trigger-based counting. You could stanch the bleeding
with sufficiently frequent vacuums, perhaps, but it just doesn't look
very appealing.
Ultimately what this comes down to is "how much overhead are we willing
to load onto all other operations in order to make SELECT-COUNT(*)-with-
no-WHERE-clause fast"? Postgres has made a set of design choices that
favor the other operations. If you've designed an application that
lives or dies by fast COUNT(*), perhaps you should choose another
database.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2003-04-20 15:25:29 | Re: [SQL] Yet Another (Simple) Case of Index not used |
Previous Message | Jeffrey Melloy | 2003-04-20 15:19:59 | Re: 7.3 PDF documentation |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2003-04-20 15:25:29 | Re: [SQL] Yet Another (Simple) Case of Index not used |
Previous Message | Andreas Pflug | 2003-04-20 10:07:53 | Re: [SQL] Yet Another (Simple) Case of Index not used |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2003-04-20 15:25:29 | Re: [SQL] Yet Another (Simple) Case of Index not used |
Previous Message | Andreas Pflug | 2003-04-20 10:07:53 | Re: [SQL] Yet Another (Simple) Case of Index not used |