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: maxim.boguk@gmail.com
Cc: rhaas@postgresql.org
Subject: Re: BUG #15352: postgresql FDW error "ERROR: ORDER BY position 0 is not in select list"
Date: Wed, 29 Aug 2018 12:02:46 +0100
Message-ID: <87mut5xye8.fsf@news-spur.riddles.org.uk> (raw)
In-Reply-To: <CAFjFpRcShdm5V_9Je4CzaRw31QhDW4s6VKzZ2m50JvKANL4jjw@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>

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

 Andrew> It seems obviously wrong that a constant pathkey with no actual
 Andrew> reference to the foreign table should be being pushed down, so
 Andrew> so far I suspect that get_useful_pathkeys_for_relation isn't
 Andrew> being selective enough about what is "useful". In this context
 Andrew> I find it suspicious that find_em_expr_for_rel will return an
 Andrew> expr with no vars as being "for" every rel, since it's just
 Andrew> looking for a subset.

 Ashutosh> Sorry for replying late. I am not able to understand why it's
 Ashutosh> wrong to push a constant or for the matter any shippable
 Ashutosh> expression which doesn't refer to the foreign table/s (for
 Ashutosh> that matter any tables) under consideration down to the
 Ashutosh> foreign server.

Well, it's certainly pointless.

But the failure in this case is specifically about pushing down an
_integer_ constant, because the deparse code for pushing down an ORDER
BY does not understand that integer literals in ORDER BY clauses are a
special case.

 Ashutosh> The context in the original mail doesn't help. I haven't
 Ashutosh> checked the original thread on bugs mailing list. I agree
 Ashutosh> that ordering by such an expression is useless, but if we are
 Ashutosh> getting that done from a foreign server, what's the harm? But
 Ashutosh> by not doing it we might be loosing some optimization since
 Ashutosh> postgres_fdw pushes all or none of pathkeys.

I'm pretty sure that constant (hence redundant) clauses have been
removed from pathkeys before postgres_fdw will see them. The problem
only occurs because postgres_fdw tries inventing _new_ pathkeys for
possible orderings from eclasses (in order to try for mergejoin
opportunities) in addition to using the requested pathkeys, and it's
clearly pointless to do that with constants.

-- 
Andrew (irc:RhodiumToad)




view thread (10+ messages)  latest in thread

Message-ID: <87mut5xye8.fsf@news-spur.riddles.org.uk>
Permalink:  ../87mut5xye8.fsf@news-spur.riddles.org.uk/
Also on:    postgresql.org/message-id/87mut5xye8.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, maxim.boguk@gmail.com, rhaas@postgresql.org
  Subject: Re: BUG #15352: postgresql FDW error "ERROR: ORDER BY position 0 is not in select list"
  In-Reply-To: <87mut5xye8.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>

* 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