From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andres Freund <andres@anarazel.de>
Cc: pgsql-hackers@postgresql.org
Subject: Re: ORDER/GROUP BY expression not found in targetlist
Date: Thu, 26 May 2016 13:22:46 -0400
Message-ID: <10433.1464283366@sss.pgh.pa.us> (raw)
In-Reply-To: <20160526021235.w4nq7k3gnheg7vit@alap3.anarazel.de>
References: <20160526021235.w4nq7k3gnheg7vit@alap3.anarazel.de>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
Andres Freund <andres@anarazel.de> writes:
> trying to reproduce a performance problem I just found:
> =# CREATE TABLE twocol(col01 int, col02 int);
> =# SELECT DISTINCT col01, col02, col01 FROM twocol ;
> ERROR: XX000: ORDER/GROUP BY expression not found in targetlist
> LOCATION: get_sortgroupref_tle, tlist.c:341
> which appears to be a 9.6 regression, presumable fallout from the path
> restructuring.
Huh. The problem is that createplan.c is trying to apply the
physical-tlist optimization to the seqscan underneath the aggregate
node. That means that the output from the seqscan is just
"col01, col02", which means that col01 can only be decorated with
a single ressortgroupref ... but there are two ressortgrouprefs
for it as far as the groupClause is concerned. Only one gets applied
to the seqscan's tlist, and then later we fail because we don't find
the other one there. Conclusions:
* we need to back off the physical-tlist optimization in this case
* the code that transfers sortgroupref labels onto a tlist probably
ought to notice and complain if it's asked to put inconsistent labels
onto the same column.
I'm a little surprised that it's not discarding the third grouping
item as redundant ... but that's probably not something to mess with
right now. Prior versions don't appear to do that either.
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
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-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, andres@anarazel.de
Subject: Re: ORDER/GROUP BY expression not found in targetlist
In-Reply-To: <10433.1464283366@sss.pgh.pa.us>
References: <20160526021235.w4nq7k3gnheg7vit@alap3.anarazel.de> <10433.1464283366@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