Обсуждение: Two PostgreSQL instances returning different output for same query
I’m a bit stumped on this one. For one of my application teams both their DEV instance and UAT instance are running pg version12.3 in AWS RDS, and I’ve used the same psql version 13.4. The query is a simple: SELECT to_jsonb(geom) FROM addresses LIMIT 1; On both databases the geom field is of data type geometry from postgis, but the two dbs are running different versions ofPostgis. DEV is 3.0.2 while UAT is 2.5.2, but I don’t think this is causing the issue. Running the query on the DEV instance produces to_jsonb ———————————- {“type”: “Point”, “coordinates”: [-106.54569, 31.82908]} While running it on the UAT instance produces to_jsonb ————————————— “0101000020E610009000000000000000“ If I remove the to_jsonb() so the query becomes SELECT geom FROM addresses; both output the same very long string that theUAT instance produces for the to_jsonb() output. So UAT does not seem to be processing the to_jsonb. I’m thinking that there might be a GUC controlling the output format, but I can’t seem to find any references for one. Any ideas? Jay Sent from my iPad
On Tue, Aug 30, 2022 at 8:21 AM John Scalia <jayknowsunix@gmail.com> wrote:
The query is a simple: SELECT to_jsonb(geom) FROM addresses LIMIT 1;
What is the point of LIMIT 1?
David J.
Re: Two PostgreSQL instances returning different output for same query
От
hubert depesz lubaczewski
Дата:
On Tue, Aug 30, 2022 at 11:21:26AM -0400, John Scalia wrote: > I’m a bit stumped on this one. For one of my application teams both their DEV instance and UAT instance are running pgversion 12.3 in AWS RDS, and I’ve used the same psql version 13.4. > > The query is a simple: SELECT to_jsonb(geom) FROM addresses LIMIT 1; > > On both databases the geom field is of data type geometry from postgis, but the two dbs are running different versionsof Postgis. DEV is 3.0.2 while UAT is 2.5.2, but I don’t think this is causing the issue. > > Running the query on the DEV instance produces > to_jsonb > ———————————- > {“type”: “Point”, “coordinates”: [-106.54569, 31.82908]} > > While running it on the UAT instance produces > to_jsonb > ————————————— > “0101000020E610009000000000000000“ Check installed extensions, and their versions in both dbs. Best regards, depesz
On 8/30/22 10:21, John Scalia wrote:
Obligatory "why are you using 12.3 when 12.11 is the latest?" Upgrading takes all of 15 minutes.
Are you sure that they are the same record? (I always use ORDER BY with "LIMIT 1" when comparing records.)
I’m a bit stumped on this one. For one of my application teams both their DEV instance and UAT instance are running pg version 12.3 in AWS RDS, and I’ve used the same psql version 13.4.
Obligatory "why are you using 12.3 when 12.11 is the latest?" Upgrading takes all of 15 minutes.
The query is a simple: SELECT to_jsonb(geom) FROM addresses LIMIT 1;
Are you sure that they are the same record? (I always use ORDER BY with "LIMIT 1" when comparing records.)
--
Angular momentum makes the world go 'round.
Angular momentum makes the world go 'round.
John Scalia <jayknowsunix@gmail.com> writes: > I’m a bit stumped on this one. For one of my application teams both their DEV instance and UAT instance are running pgversion 12.3 in AWS RDS, and I’ve used the same psql version 13.4. > The query is a simple: SELECT to_jsonb(geom) FROM addresses LIMIT 1; > On both databases the geom field is of data type geometry from postgis, but the two dbs are running different versionsof Postgis. DEV is 3.0.2 while UAT is 2.5.2, but I don’t think this is causing the issue. I think you're being far too hasty to reject a highly probable explanation. Consult the Postgis release notes to see if they changed anything about casting-to-JSON between those two releases. A quick look at to_jsonb's innards shows that for a non-core input type, it will use the type's cast to JSON if there is one, while if there is not, it will just run the type's output function and call the result a JSON string. This seems to fit quite well with the results you show. regards, tom lane
Re: Two PostgreSQL instances returning different output for same query
От
hubert depesz lubaczewski
Дата:
On Tue, Aug 30, 2022 at 11:21:26AM -0400, John Scalia wrote: > I’m a bit stumped on this one. For one of my application teams both their DEV instance and UAT instance are running pgversion 12.3 in AWS RDS, and I’ve used the same psql version 13.4. > > The query is a simple: SELECT to_jsonb(geom) FROM addresses LIMIT 1; > > On both databases the geom field is of data type geometry from postgis, but the two dbs are running different versionsof Postgis. DEV is 3.0.2 while UAT is 2.5.2, but I don’t think this is causing the issue. Changelog for postgis 3.0.0 shows: 3687, Casts json(geometry) and jsonb(geometry) for implicit GeoJSON generation (Paul Ramsey) looks to be very related. Best regards, depesz