Re: [PERFORM] count(*) using index scan in "query often, update rarely" environment

2005-10-08 Thread mark
On Fri, Oct 07, 2005 at 12:48:16PM +0200, Steinar H. Gunderson wrote: > On Fri, Oct 07, 2005 at 11:24:05AM +0200, Cestmir Hybl wrote: > > Isn't it possible (and reasonable) for these environments to keep track of > > whether there is a transaction in progress with update to given table and > > if n

Re: [PERFORM] count(*) using index scan in "query often, update rarely" environment

2005-10-08 Thread hubert depesz lubaczewski
On 10/7/05, Cestmir Hybl <[EMAIL PROTECTED]> wrote: No, I can't speed-up evaluation of generic "count(*) where ()" queries this way. no you can't speed up generic where(), *but* you can check what are the most common "where"'s (like usually i do where on one column like: select count(*) from table

Re: [PERFORM] count(*) using index scan in "query often, update rarely"

2005-10-07 Thread Richard Huxton
Tom Lane wrote: There's a workable-looking design in the archives (pghackers probably) for maintaining overall table counts in a separate table, with each transaction adding one row of "delta" information just before it commits. I haven't seen anything else that looks remotely attractive. It

Re: [PERFORM] count(*) using index scan in "query often, update rarely" environment

2005-10-07 Thread Merlin Moncure
On 10/7/05, Cestmir Hybl <[EMAIL PROTECTED]> wrote: Isn't it possible (and reasonable) for these environments to keep track of whether there is a transaction in progress with update to given table and if not, use an index scan (count(*) where) or cached value (count(*)) to perform this kind of quer

Re: [PERFORM] count(*) using index scan in "query often, update rarely" environment

2005-10-07 Thread Tom Lane
"Cestmir Hybl" <[EMAIL PROTECTED]> writes: > Isn't it possible (and reasonable) for these environments to keep track = > of whether there is a transaction in progress with update to given table = > and if not, use an index scan (count(*) where) or cached value = > (count(*)) to perform this kind of

Re: [PERFORM] count(*) using index scan in "query often, update rarely" environment

2005-10-07 Thread Alvaro Herrera
On Fri, Oct 07, 2005 at 01:14:20PM +0200, Cestmir Hybl wrote: > collision: it's possible to either block updating transaction until > index scan ends or discard index scan imediately and finish query using > MVCC compliant scan You can't change from one scan method to a different one on the fly.

Re: [PERFORM] count(*) using index scan in "query often, update rarely" environment

2005-10-07 Thread Cestmir Hybl
t would be possible/worth to make indexes matching live records when there's no transaction in progress on that table - Original Message - From: "Steinar H. Gunderson" <[EMAIL PROTECTED]> To: Sent: Friday, October 07, 2005 12:48 PM Subject: Re: [PERFORM] count(*) u

Re: [PERFORM] count(*) using index scan in "query often, update rarely" environment

2005-10-07 Thread Steinar H. Gunderson
On Fri, Oct 07, 2005 at 11:24:05AM +0200, Cestmir Hybl wrote: > Isn't it possible (and reasonable) for these environments to keep track of > whether there is a transaction in progress with update to given table and > if not, use an index scan (count(*) where) or cached value (count(*)) to > perform

Re: [PERFORM] count(*) using index scan in "query often, update rarely" environment

2005-10-07 Thread Cestmir Hybl
count() queries in environment with infrequent updates.   Cestmir - Original Message - From: hubert depesz lubaczewski To: Cestmir Hybl Cc: pgsql-performance@postgresql.org Sent: Friday, October 07, 2005 11:54 AM Subject: Re: [PERFORM] count(*) using index

Re: [PERFORM] count(*) using index scan in "query often, update rarely" environment

2005-10-07 Thread hubert depesz lubaczewski
On 10/7/05, Cestmir Hybl <[EMAIL PROTECTED]> wrote: Isn't it possible (and reasonable) for these environments to keep track of whether there is a transaction in progress with update to given table and if not, use an index scan (count(*) where) or cached value (count(*)) to perform this kind of q

[PERFORM] count(*) using index scan in "query often, update rarely" environment

2005-10-07 Thread Cestmir Hybl
Hello all   First of all, I do understand why pgsql with it's MVCC design has to examine tuples to evaluate "count(*)" and "count(*) where (...)" queries in environment with heavy concurrent updates.   This kind of usage IMHO isn't the average one. There are many circumstances with rather "qu