Opened 5 years ago

Closed 5 years ago

Last modified 4 years ago

#4672 closed enhancement (fixed)

Cache the return value for getSRSbySRID and getSRIDbySRS per transaction

Reported by: Algunenano Owned by: pramsey
Priority: medium Milestone: PostGIS 3.1.0
Component: postgis Version: master
Keywords: Cc:

Description

Currently the performance of any function that uses getSRSbySRID is defined by the time it takes to get the SRS. Since this won't change during the execution of the function, we should be able to cache the return value and avoid calling it over and over when all the geometries in the relation have the same SRID (which I guess is the most common case).

This affects:

  • ST_AsGML for geometry and geography.
  • ST_AsGeoJSON: geography (always) and geometry (only a crs option is set).
  • ST_AsX3D

Change History (4)

comment:1 by Algunenano, 5 years ago

PR: https://github.com/postgis/postgis/pull/557

I've removed the srs calculation from ST_AsX3D since it was never used.

For a point dataset (same srs for all rows) this greatly improves the performance:

  • ST_AsGML: 20x
  • ST_AsX3D: 90x
  • ST_AsGeoJSON (with srs options): 40x

comment:2 by Algunenano, 5 years ago

Summary: Cache the return value for getSRSbySRID per transactionCache the return value for getSRSbySRID and getSRIDbySRS per transaction

I decided to also cache getSRIDbySRS, which gives a 40x improvement to ST_GeomFromGeoJSON.

comment:3 by Raúl Marín <git@…>, 5 years ago

Resolution: fixed
Status: newclosed

comment:4 by Raúl Marín <git@…>, 4 years ago

In d575a6e/git:

Adapt image generator to the changes in the library

References #4672

Note: See TracTickets for help on using tickets.