From: David G. Johnston <david.g.johnston@xxxxxxxxx>
Sent: Friday, March 12, 2021 21:19
To: Brent Wood <Brent.Wood@xxxxxxxxxx> Cc: pgsql-general@xxxxxxxxxxxxxxxxxxxx <pgsql-general@xxxxxxxxxxxxxxxxxxxx> Subject: Re: hstore each() function - returned order?? Thanks David,
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;
I'll try it with \timing & explain to look at performance, but I don't see how this provides any greater assurance that the keys & values are provided in the same order, and so the correct value is in the same row as its key?
This still seems to depend on just how the EACH() function returns the values rather than any use of lateral joins, and was the question I was asking.
Cheers
Brent Wood
On Thursday, March 11, 2021, Brent Wood <Brent.Wood@xxxxxxxxxx> wrote:
Just move the each call to the from clause as a lateral join and treat the result as a two-column table.
David J.
|