From: | Peter Geoghegan <peter(at)2ndquadrant(dot)com> |
---|---|
To: | Luby Liao <lubyliao(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: What happens to a primary key b-tree index when a table tuple is deleted by a transaction? |
Date: | 2012-11-25 19:05:41 |
Message-ID: | CAEYLb_XRjSbvxjOAAW5kcakd4c+pktBBhoo25wC03iTpMzR1zQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 25 November 2012 18:03, Luby Liao <lubyliao(at)gmail(dot)com> wrote:
> If the b-tree changes for the transaction, would it not become broken for
> other transactions?
> Can anyone tell me how Postgres handles this? Thank you, Luby
Unfortunately, that book is a little out of date.
Even with a unique index, there can simultaneously be "duplicate" row
versions (I emphasize the distinction between logical rows and
physical row versions), provided that no two duplicate values are
simultaneously visible to a snapshot - they cannot exist at the same
"time". MVCC doesn't modify rows in place; in creates new row
versions. So, just as with tables, btree indexes will have multiple
row versions for the same logical row.
There is one notable exception to this, though. There was an
optimisation added to PostgreSQL 8.3 called HOT, or heap-only tuples.
This optimisation allows Postgres to use clever tricks to get away
with only having a new row version in tables, and not in each index,
if and only if the UPDATE statement only affects non-indexed columns.
--
Peter Geoghegan http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training and Services
From | Date | Subject | |
---|---|---|---|
Next Message | Stefan Froehlich | 2012-11-25 19:39:45 | Re: large INSERT leads to "invalid memory alloc" |
Previous Message | Pavel Stehule | 2012-11-25 18:34:48 | Re: What happens to a primary key b-tree index when a table tuple is deleted by a transaction? |