pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew Gierth <andrew@tao11.riddles.org.uk>
To: Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>
Cc: pgsql-bugs@lists.postgresql.org
Cc: rhaas@postgresql.org
Subject: Re: BUG #15352: postgresql FDW error "ERROR: ORDER BY position 0 is not in select list"
Date: Fri, 31 Aug 2018 10:51:00 +0100
Message-ID: <87pnxyx6kf.fsf@news-spur.riddles.org.uk> (raw)
In-Reply-To: <CAFjFpRfX_GMfU7MVSS9kEqd0Fr7JnYRR0wqBDZ8E88XJGc3RGg@mail.gmail.com>
References: <153518420278.1478.14875560810251994661@wrigleys.postgresql.org>
	<87efemzw0v.fsf@news-spur.riddles.org.uk>
	<87a7paz8b1.fsf@news-spur.riddles.org.uk>
	<87r2iiy3if.fsf@news-spur.riddles.org.uk>
	<CAFjFpRcShdm5V_9Je4CzaRw31QhDW4s6VKzZ2m50JvKANL4jjw@mail.gmail.com>
	<87mut5xye8.fsf@news-spur.riddles.org.uk>
	<CAFjFpRdnbgGWxZZ4H3vxJMURvak+DgrkeamRh3ZYJe4X9mqpLw@mail.gmail.com>
	<87efegxn6b.fsf@news-spur.riddles.org.uk>
	<CAFjFpRfX_GMfU7MVSS9kEqd0Fr7JnYRR0wqBDZ8E88XJGc3RGg@mail.gmail.com>

>>>>> "Ashutosh" == Ashutosh Bapat <ashutosh.bapat@enterprisedb.com> writes:

 Ashutosh> Looking at deparseSortGroupClause() this issue looks to be
 Ashutosh> fixed in HEAD. Either the version where bug was found doesn't
 Ashutosh> have this fix or somehow the fix isn't working.

You're misreading the code. The OP's example clearly demonstrates the
bug when tested with HEAD prior to bf2d0462c or with bf2d0462c reverted.

As the code stands, it _cannot_ use deparseSortGroupClause for
generating EXPLAINs for pathkeys that are chosen by postgres_fdw,
because deparseSortGroupClause wants a tlist, not a plain list of
expressions.

(Perhaps you haven't realized that without the additional check, when
remote estimates are enabled we end up sending EXPLAIN commands to the
remote for paths that cannot possibly be of any use in the query?
Round-trips to the remote are not free.)

 >> How do you think that could happen, given that redundant pathkeys
 >> are already removed?

 Ashutosh> I don't have exact answer.

Then you should find out.

 Ashutosh> But deparseSortGroupClause() has code to deparse constants in
 Ashutosh> GROUP BY indicates that we do encounter such pathkeys
 Ashutosh> somewhere.

GROUP BY isn't based on pathkeys (for one thing, grouping columns might
not be sortable).

 Ashutosh> I am thinking about ORDER BY being pushed down for GROUP BY.

Perhaps you should take a look at how the pathkeys for that case are
generated.

-- 
Andrew (irc:RhodiumToad)




view thread (10+ messages)

Message-ID: <87pnxyx6kf.fsf@news-spur.riddles.org.uk>
Permalink:  ../87pnxyx6kf.fsf@news-spur.riddles.org.uk/
Also on:    postgresql.org/message-id/87pnxyx6kf.fsf@news-spur.riddles.org.uk

 · 

reply

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: andrew@tao11.riddles.org.uk, ashutosh.bapat@enterprisedb.com, rhaas@postgresql.org
  Subject: Re: BUG #15352: postgresql FDW error "ERROR: ORDER BY position 0 is not in select list"
  In-Reply-To: <87pnxyx6kf.fsf@news-spur.riddles.org.uk>
  References: <153518420278.1478.14875560810251994661@wrigleys.postgresql.org> <87efemzw0v.fsf@news-spur.riddles.org.uk> <87a7paz8b1.fsf@news-spur.riddles.org.uk> <87r2iiy3if.fsf@news-spur.riddles.org.uk> <CAFjFpRcShdm5V_9Je4CzaRw31QhDW4s6VKzZ2m50JvKANL4jjw@mail.gmail.com> <87mut5xye8.fsf@news-spur.riddles.org.uk> <CAFjFpRdnbgGWxZZ4H3vxJMURvak+DgrkeamRh3ZYJe4X9mqpLw@mail.gmail.com> <87efegxn6b.fsf@news-spur.riddles.org.uk> <CAFjFpRfX_GMfU7MVSS9kEqd0Fr7JnYRR0wqBDZ8E88XJGc3RGg@mail.gmail.com> <87pnxyx6kf.fsf@news-spur.riddles.org.uk>

* 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