Re: SELECT DISTINCT never uses an index? - Mailing list pgsql-hackers

From David Rowley
Subject Re: SELECT DISTINCT never uses an index?
Date
Msg-id CAKJS1f_7YLoO-MnJTRir9DfPOzNtaH=p=6+e8SteiP70ZcwyLg@mail.gmail.com
Whole thread Raw
In response to Re: SELECT DISTINCT never uses an index?  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
On 8 July 2016 at 09:49, Robert Haas <robertmhaas@gmail.com> wrote:
> We're probably missing a few tricks on queries of this type. If the
> index-traversal machinery had a mechanism to skip quickly to the next
> distinct value, that could be used here: walk up the btree until you
> find a page that contains keyspace not equal to the current key, then
> walk back down until you find the first leaf page that contains such a
> value.  That would potentially let you step over large chunks of the
> index without actually examining all the leaf pages, which for a query
> like this seems like it could be a big win.

Thomas Munro did take some initial steps to implementing this a few years ago:
https://www.postgresql.org/message-id/CADLWmXXbTSBxP-MzJuPAYSsL_2f0iPm5VWPbCvDbVvfX93FKkw%40mail.gmail.com


-- David Rowley                   http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training & Services



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: delta relations in AFTER triggers
Next
From: Peter Geoghegan
Date:
Subject: Re: \timing interval