From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
Cc: | Brent Wood <Brent(dot)Wood(at)niwa(dot)co(dot)nz>, "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: hstore each() function - returned order?? |
Date: | 2021-03-12 14:52:13 |
Message-ID: | 2439589.1615560733@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
"David G. Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> writes:
> On Fri, Mar 12, 2021 at 3:18 AM Brent Wood <Brent(dot)Wood(at)niwa(dot)co(dot)nz> 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
From | Date | Subject | |
---|---|---|---|
Next Message | Brent Wood | 2021-03-12 20:44:12 | Re: hstore each() function - returned order?? |
Previous Message | David G. Johnston | 2021-03-12 14:28:32 | Re: hstore each() function - returned order?? |