Re: ToDo: KNN Search should to support DISTINCT clasuse? - Mailing list pgsql-hackers

From Greg Stark
Subject Re: ToDo: KNN Search should to support DISTINCT clasuse?
Date
Msg-id CAM-w4HO9TakKStXT6xtCqrECmo+5G4PAurK0cvQ+4fpw37WPeQ@mail.gmail.com
Whole thread Raw
In response to Re: ToDo: KNN Search should to support DISTINCT clasuse?  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: ToDo: KNN Search should to support DISTINCT clasuse?  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
On Mon, Oct 22, 2012 at 4:57 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Don't hold your breath.  There are two ways the system could implement
> the DISTINCT clause: either sort and uniq, or hashaggregate.
> hashaggregate will destroy any input ordering, so there's no value in
> using the index as input.  sort and uniq requires the input to be sorted
> by *all* the columns being distinct'ed, not just one, so again this
> index isn't useful.

We already have some bits that understand functional dependencies for
distinct/group by don't we? Do we detect that col <-> 'foo' is
functionally dependent on col? If so is it possible to construct a
multicolumn index that can produce an ordering like [col <-> 'foo',
col] which could be used to get distinct values of col in the knn
order (since the first column is functionally dependent on the second
it can be ignored for grouping purposes).

Not that we can do this now but I wonder whether a lot of the pieces
are already there and just need to be hooked up together.


-- 
greg



pgsql-hackers by date:

Previous
From: Greg Stark
Date:
Subject: Re: Successor of MD5 authentication, let's use SCRAM
Next
From: "David Johnston"
Date:
Subject: Re: Deprecating RULES