Re: [PATCHES] GIN improvements - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [PATCHES] GIN improvements
Date
Msg-id 8177.1216920042@sss.pgh.pa.us
Whole thread Raw
In response to Re: [PATCHES] GIN improvements  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: [PATCHES] GIN improvements  (Teodor Sigaev <teodor@sigaev.ru>)
List pgsql-hackers
I wrote:
> Really?  Then GiST needs to be fixed too.  Otherwise you risk having
> queries return the same row twice.  A bitmap indexscan plan would mask
> such an index bug ... but a plain indexscan won't.

BTW, there's another issue I forgot about yesterday, which is that
the planner assumes that all index AMs work correctly for backwards
scan.  The place where the rubber meets the road here is that
if you DECLARE SCROLL CURSOR for a plan implemented as a plain
indexscan, then FETCH BACKWARDS is supposed to reliably generate
results consistent with previous FETCH FORWARDS, to wit the same
tuples in the reverse order.

We can assume that the query is using an MVCC snapshot, which means
that at the index level it's okay for the index to return newly-inserted
entries that weren't returned in the previous forward scan, or to not
return entries that were removed meanwhile by VACUUM.  But re-ordering
live tuples is bad news.

The idea of copying the pending-tuples list into local scan state would
make this work as expected as far as the proposed patch goes, but I'm
wondering whether the behavior isn't completely broken anyway by
operations such as page splits.  Do we need to change the planner to
assume that this only works nicely for btree?
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Extending grant insert on tables to sequences
Next
From: "Greg Sabino Mullane"
Date:
Subject: Re: [DOCS] [ADMIN] shared_buffers and shmmax