From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andres Freund <andres@anarazel.de>
Cc: Kevin Grittner <kgrittn@gmail.com>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Subject: Re: Implement targetlist SRFs using ROWS FROM() (was Changed SRF in targetlist handling)
Date: Fri, 02 Sep 2016 10:20:42 -0400
Message-ID: <9965.1472826042@sss.pgh.pa.us> (raw)
In-Reply-To: <20160902141110.6xciuntt5h4i6eni@alap3.anarazel.de>
References: <20160523005327.v2tr7obytitxcnna@alap3.anarazel.de>
<20160822214023.aaxz5l4igypowyri@alap3.anarazel.de>
<CA+TgmoboLaUy71iLKa2GPcnioWmNxhCFdcDj-F05sZOGgRO0NA@mail.gmail.com>
<CACjxUsM7PUBF3_u-+J7j1WsoRZ9OVNTw2+=P15t2pqnv7utktQ@mail.gmail.com>
<20160902141110.6xciuntt5h4i6eni@alap3.anarazel.de>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
Andres Freund <andres@anarazel.de> writes:
> On 2016-09-02 09:05:35 -0500, Kevin Grittner wrote:
>>> In general, we've been skeptical about giving any guarantees about
>>> result ordering.
> Well, it's historically how we behaved for SRFs. I'm pretty sure that
> people will be confused if
> SELECT generate_series(1, 10) FROM sometbl;
> suddenly returns rows in an order that reverse from what
> generate_series() returns.
True, but how much "enforcement" do we need really? This will be a cross
product join, which means that it can only be done as a nestloop not as a
merge or hash (there being no join key to merge or hash on). ISTM all we
need is that the SRF be on the inside of the join, which is automatic
if it's LATERAL.
>> I think it is a very bad idea to move away from the statement that
>> a query generates a set of rows, and that no order is guaranteed
>> unless the top level has an ORDER BY clause. How hard is it to add
>> ORDER BY 1, 2 to the above query? Let the optimizer notice when a
>> node returns data in the needed order and skip the sort if possible.
> There's no such infrastructure for SRFS/ROWS FROM.
And in particular nothing to ORDER BY in this example.
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 using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, andres@anarazel.de, kgrittn@gmail.com, robertmhaas@gmail.com
Subject: Re: Implement targetlist SRFs using ROWS FROM() (was Changed SRF in targetlist handling)
In-Reply-To: <9965.1472826042@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