From: | Greg Stark <stark(at)mit(dot)edu> |
---|---|
To: | Stephen Frost <sfrost(at)snowman(dot)net> |
Cc: | Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PG Hackers <pgsql-hackers(at)postgresql(dot)org>, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, David Fetter <david(at)fetter(dot)org> |
Subject: | Re: Review: UNNEST (and other functions) WITH ORDINALITY |
Date: | 2013-07-23 21:11:40 |
Message-ID: | CAM-w4HNQ55NqyXiPPoEgOdX7fNy59aA6QAM7VbsNDkv54mWPAA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, Jul 23, 2013 at 9:27 PM, Stephen Frost <sfrost(at)snowman(dot)net> wrote:
>
> Fine- I'd have been as happy leaving this be and letting Greg commit it,
> but if you'd really like to hear my concerns, I'd start with pointing
> out that it's pretty horrid to have to copy every record around like
> this and that the hack of CreateTupleDescCopyExtend is pretty terrible
> and likely to catch people by surprise. Having FunctionNext() operate
> very differently depending on WITH ORDINALITY is ugly and the cause of
> the bug that was found. All-in-all, I'm not convinced that this is
> really a good approach and feel it'd be better off implemented at a
> different level, eg a node type instead of a hack on top of the existing
> SRF code.
Fwiw I've been mulling over the same questions and came to the
conclusion that the existing approach makes the most sense.
In an ideal world an extra executor node would be the prettiest,
cleanest implementation. But the amount of extra code and busywork
that would necessitate just isn't justified for the amount of work it
would be doing.
It might be different if WITH ORDINALITY made sense for any other
types of target tables. But it really only makes sense for SRFs. The
whole motivation for having them in the spec is that UNNEST is taking
an ordered list and turning it into a relation which is unordered. You
can't just do row_number() because there's nothing to make it ordered
by.
By the same token for any other data source you would just use
row_number *precisely because* any other data source is unordered and
you should have to specify an order in order to make row_number
produce something meaningful.
So given that WITH ORDINALITY is really only useful for UNNEST and we
can generalize it to all SRFs on the basis that Postgres SRFs do
produce ordered sets not unordered relations it isn't crazy for the
work to be in the Function node.
Now that I've written that though it occurs to me to wonder whether
FDW tables might be usefully said to be ordered too though?
--
greg
From | Date | Subject | |
---|---|---|---|
Next Message | Stephen Frost | 2013-07-23 21:23:17 | Re: Review: UNNEST (and other functions) WITH ORDINALITY |
Previous Message | Jeff Janes | 2013-07-23 21:02:53 | Re: maintenance_work_mem and CREATE INDEX time |