Re: coalesce function

From: David Johnston <polobo(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: coalesce function
Date: 2013-06-21 15:20:55
Message-ID: 1371828055818-5760342.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Chris Angelico wrote
> On Fri, Jun 21, 2013 at 7:36 AM, David Johnston &lt;

> polobo@

> &gt; wrote:
>> SELECT input
>> FROM ( SELECT unnest($1) AS input ) src
>> WHERE input IS NOT NULL AND input <> ''
>> LIMIT 1;
>
> Does this guarantee the order of the results returned? Using LIMIT
> without ORDER BY is something I've learned to avoid.
>
> ChrisA

I have thought about this and while I'm not 100% positive on the guarantee
the fact the input data is small means the planner should not be re-ordering
"src" in order to apply the where clause (if it would anyway...I think
re-ordering may only happen during joins). To my knowledge the result of
unnest returns in the same order as the array so "src" already has an
implicit "ORDER BY" attached to it. It is only when return physical
relation data is the order undefined. Arrays and "VALUES" both are returned
in the order defined.

David J.

--
View this message in context: http://postgresql.1045698.n5.nabble.com/coalesce-function-tp5760161p5760342.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alan Nilsson 2013-06-21 16:23:40 Re: variadic args to C functions
Previous Message David Johnston 2013-06-21 15:09:01 Re: Circular references