From: Tom Lane <tgl@sss.pgh.pa.us>
To: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Cc: Dilyan Palauzov <dilyan.palauzov@aegee.org>
Cc: pgsql-bugs@postgresql.org
Subject: Re: Query planner skipping index depending on DISTINCT parameter order (2)
Date: Sun, 17 Sep 2017 13:15:34 -0400
Message-ID: <12044.1505668534@sss.pgh.pa.us> (raw)
In-Reply-To: <271e4961-abfa-06ef-a502-cf00a31b236a@2ndquadrant.com>
References: <3c651d99-a943-4e21-4ec9-604b142c85e0@aegee.org>
<57ccc03b-279a-63f7-19c6-6fe3b2d0e1be@aegee.org>
<cd89d79f-96df-1a1e-5821-ef111950eccf@2ndquadrant.com>
<a68737c6-601f-6846-2ba0-3795c942c81f@aegee.org>
<271e4961-abfa-06ef-a502-cf00a31b236a@2ndquadrant.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
Tomas Vondra <tomas.vondra@2ndquadrant.com> writes:
> On 09/17/2017 02:30 AM, Dilyan Palauzov wrote:
>> The behaviour behind DISTINCT and indexes surprises me, as the
>> query planner does reorder the columns for SELECT to determine the
>> most suitable index.
> Well, I agree it's somewhat reasonable optimization. The thing is, the
> planner/optimizer does not start with all features on day 1, it gets
> improved over time. And no one implemented this bit yet.
For the DISTINCT ON case, the user-visible semantics are actually pretty
tightly tied to ORDER BY, so that it would not be very reasonable to
consider any other orderings than the given column order anyway.
For plain DISTINCT, yeah we could consider other orderings ... but
we're rather unlikely to find an index that matches all the output
columns, regardless of what order they're in. So it's just not that
exciting.
IOW, somebody might get around to this someday, but don't hold your
breath; there's lots of higher-value fruit to be reaching for.
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, tomas.vondra@2ndquadrant.com, dilyan.palauzov@aegee.org
Subject: Re: Query planner skipping index depending on DISTINCT parameter order (2)
In-Reply-To: <12044.1505668534@sss.pgh.pa.us>
References: <3c651d99-a943-4e21-4ec9-604b142c85e0@aegee.org> <57ccc03b-279a-63f7-19c6-6fe3b2d0e1be@aegee.org> <cd89d79f-96df-1a1e-5821-ef111950eccf@2ndquadrant.com> <a68737c6-601f-6846-2ba0-3795c942c81f@aegee.org> <271e4961-abfa-06ef-a502-cf00a31b236a@2ndquadrant.com> <12044.1505668534@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox