Re:

From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re:
Date: 2016-09-12 07:07:33
Message-ID: CAMsr+YF13pTtbsgnsONmZ_pzDLcN_AYdxRxPZJ-40pdqd+C-Uw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 12 September 2016 at 14:29, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote:

>> I would've expected once per query. There's no way the expressions can
>> reference the row data, so there's no reason to evaluate them each
>> time.
>
> I disagree - it is hypothetical situation but it is possible
>
> if somebody store documents like
>
> id, xml
> =====
> id = 1, xml = <doc id = 1> ....<>
> id = 2, xml = <doc id = 2> ....
>
> Then evaluating one per query doesn't allow to use any reference to other
> columns, and doesn't to build expressions like PATH ((dot)(dot)(dot)[(at)id= ' || id || ']

Referencing columns on the same evaluation level? I dunno about that.
You're relying on strict order of evaluation which is pretty unusual
for SQL.

I guess this is why full XQuery would be desirable, but that's a whole
different business.

I would personally expect this sort of thing to be handled by a second
pass; isn't that part of why it's so easy to return xml fields from
xmltable?

Evaluating expressions each time seems likely to be bad for
performance, but I guess it's not going to make a big difference
compared to all the XML crud, so I don't have a super strong opinion
here.

Either way, it's crucial that the behaviour be documented.

> DEFAULT should be evaluated per output row - anybody can use volatile
> function there - example: when I have not data - use some random there

That would be consistent with how we handle DEFAULT on a table, so I
agree. It's a departure from what we do normally, but we didn't have
table functions before either.

--
Craig Ringer http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

  • at 2016-09-12 06:29:36 from Pavel Stehule

Responses

  • Re: at 2016-09-12 07:17:35 from Pavel Stehule

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2016-09-12 07:17:35 Re:
Previous Message Prabhat Sahu 2016-09-12 06:50:45 Re: Aggregate Push Down - Performing aggregation on foreign server