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

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Cestmir Hybl <cestmirl(at)freeside(dot)sk>
Cc: "Steinar H(dot) Gunderson" <sgunderson(at)bigfoot(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: count(*) using index scan in "query often, update rarely" environment
Date: 2005-10-07 13:07:15
Message-ID: 20051007130714.GB5175@surnet.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

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.
There's no way to know which tuples have alreaady been returned.

Our index access methods are designed to be very concurrent, and it
works extremely well. One index scan being able to block an update
would destroy that advantage.

> dead rows: this sounds like more serious counter-argument, I don't know
> much about dead records management and whether it would be
> possible/worth to make indexes matching live records when there's no
> transaction in progress on that table

It's not possible, because a finishing transaction would have to clean
up every index it has used, and also any index it hasn't used but has
been modified by another transaction which couldn't clean up by itself
but didn't do the work because the first one was looking at the index.
It's easy to see that it's possible to create an unbounded number of
transactions, each forcing the other to do some index cleanup. This is
not acceptable.

Plus, it would be very hard to implement, and a very wide door to bugs.

--
Alvaro Herrera http://www.advogato.org/person/alvherre
"Et put se mouve" (Galileo Galilei)

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Lane Van Ingen 2005-10-07 13:37:44 Re: Need Some Suggestions
Previous Message Merlin Moncure 2005-10-07 12:27:05 Re: Status of Opteron vs Xeon