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

From: Brent Wood <Brent(dot)Wood(at)niwa(dot)co(dot)nz>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>, Brent Wood <Brent(dot)Wood(at)niwa(dot)co(dot)nz>
Subject: Re: hstore each() function - returned order??
Date: 2021-03-12 10:17:49
Message-ID: SY3PR01MB0810712BBBB3DE3B46D4EDF5A16F9@SY3PR01MB0810.ausprd01.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

From: David G. Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
Sent: Friday, March 12, 2021 21:19
To: Brent Wood <Brent(dot)Wood(at)niwa(dot)co(dot)nz>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org <pgsql-general(at)lists(dot)postgresql(dot)org>
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(dot)Wood(at)niwa(dot)co(dot)nz<mailto:Brent(dot)Wood(at)niwa(dot)co(dot)nz>> wrote:
Hi,

I'm using the following in an SQL :

select (EACH(value)).key as measurement_key,
(EACH(value)).value as value
from t_reading_hstore;

Just move the each call to the from clause as a lateral join and treat the result as a two-column table.

David J.

[https://www.niwa.co.nz/static/niwa-2018-horizontal-180.png][https://niwa.co.nz/sites/niwa.co.nz/files/ETNZ_Official-supplier-logo-75h.png]<https://www.niwa.co.nz>
Brent Wood
Principal Technician - GIS and Spatial Data Management
Programme Leader - Environmental Information Delivery
+64-4-386-0529
National Institute of Water & Atmospheric Research Ltd (NIWA)
301 Evans Bay Parade Hataitai Wellington New Zealand
Connect with NIWA: niwa.co.nz<https://www.niwa.co.nz> Facebook<https://www.facebook.com/nzniwa> LinkedIn<https://www.linkedin.com/company/niwa> Twitter<https://twitter.com/niwa_nz> Instagram<https://www.instagram.com/niwa_science>
To ensure compliance with legal requirements and to maintain cyber security standards, NIWA's IT systems are subject to ongoing monitoring, activity logging and auditing. This monitoring and auditing service may be provided by third parties. Such third parties can access information transmitted to, processed by and stored on NIWA's IT systems

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Charles Clavadetscher 2021-03-12 12:59:43 Re: hstore each() function - returned order??
Previous Message David G. Johnston 2021-03-12 08:19:08 Re: hstore each() function - returned order??