Search Postgresql Archives

Re: hstore each() function - returned order??

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"David G. Johnston" <david.g.johnston@xxxxxxxxx> writes:
> On Fri, Mar 12, 2021 at 3:18 AM Brent Wood <Brent.Wood@xxxxxxxxxx> wrote:
>> Is this what you mean?
>> 
>> select measurement_key,
>> value
>> from t_reading_hstore,
>> lateral ((EACH(value)).key as measurement_key,
>> lateral ((EACH(value)).value as value;

> The definition of "each" shows that it returns a record type.  That whole
> type can be considered a table and referenced in the select list.

Yeah.  To my mind, the main point here is to run each() just once per
t_reading_hstore row, not twice.  So something like

SELECT e.key, e.value FROM t_reading_hstore AS t, each(t.value) AS e;

(Writing LATERAL is optional.)

			regards, tom lane





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux