From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl> |
Cc: | Manfred Koizar <mkoi-pg(at)aon(dot)at>, David Blasby <dblasby(at)refractions(dot)net>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: SELECT * FROM <table> LIMIT 1; is really slow |
Date: | 2004-05-28 20:45:28 |
Message-ID: | 5723.1085777128@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl> writes:
> On Fri, May 28, 2004 at 03:48:11PM -0400, Tom Lane wrote:
>> Nope. Think about sub-subtransactions.
> They are all aborted if the parent is, so
> BEGIN;
> BEGIN; -- cid = 1
> BEGIN; -- cid = 2
> INSERT INTO foo VALUES (1) -- cid=3
> COMMIT;
> ROLLBACK; -- aborts from Cid 1 to Cid 3
> -- here we can't see the tuple because Xmin == my-xid
> -- and Cmin=1 is aborted
> COMMIT;
> I assume this is how you think it works, isn't it?
[ thinks about it for a while... ] Yeah, I guess you are right. Since
we don't have threading, an outer transaction cannot assign any new CIDs
while a subtransaction is in progress. Therefore, when a subtransaction
ends, all CIDs from its start to current belong to either itself or its
subtransactions. On abort we can just mark *all* of these as aborted.
If we had to do anything at subtrans commit, we'd need more state, but
we don't have to do anything at subtrans commit.
So you're right, the per-open-subtrans state is just its starting CID.
Slick.
However, I just remembered why we rejected this idea to start with :-(.
If we do it this way then when the overall xact commits, we no longer
have state that tells which particular tuples are good or not. We would
have to trawl for tuples written by aborted subtransactions and mark
them dead before committing, else other transactions would think they
were good.
What this says is that we still need persistent pg_subtrans status.
I'm not sure if we can use CIDs as subtrans IDs this way and still have
a reasonably efficient storage representation for the global pg_subtrans
table.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Marc G. Fournier | 2004-05-28 20:54:45 | Re: Win32, PITR, nested transactions, tablespaces |
Previous Message | Alvaro Herrera | 2004-05-28 20:14:44 | Re: Nested xacts: looking for testers and review |