Re: Optimize single tuple fetch from nbtree index - Mailing list pgsql-hackers

From Peter Geoghegan
Subject Re: Optimize single tuple fetch from nbtree index
Date
Msg-id CAH2-WzmWGxFNvuYgodGO6zHpenZr_vvgt6QD6Eu3HejOwMUdDg@mail.gmail.com
Whole thread Raw
In response to Re: Optimize single tuple fetch from nbtree index  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Optimize single tuple fetch from nbtree index  (Peter Geoghegan <pg@bowt.ie>)
List pgsql-hackers
On Fri, Aug 2, 2019 at 1:43 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Meh.  I think the odds that you got this 100% right are small, and the
> odds that it would be maintainable are smaller.  There's too much that
> can happen if you're not holding any lock --- and there's a lot of active
> work on btree indexes, which could break whatever assumptions you might
> make today.

I agree that this sounds very scary.

> BTW, you haven't even really made the case that optimizing a query that
> behaves this way is the right thing to be doing ... maybe some other
> plan shape that isn't a nestloop around a LIMIT query would be a better
> solution.

I wonder if some variety of block nested loop join would be helpful
here. I'm not aware of any specific design that would help with
Floris' case, but the idea of reducing the number of scans required on
the inner side by buffering outer side tuples (say based on the
"k=:val" constant) seems like it might generalize well enough. I
suggest Floris look into that possibility. This paper might be worth a
read:

https://dl.acm.org/citation.cfm?id=582278

(Though it also might not be worth a read -- I haven't actually read it myself.)

--
Peter Geoghegan



pgsql-hackers by date:

Previous
From: Stephen Frost
Date:
Subject: Re: [PATCH] Stop ALTER SYSTEM from making bad assumptions
Next
From: Peter Geoghegan
Date:
Subject: Re: The unused_oids script should have a reminder to use the8000-8999 OID range