<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">I just replicated Boone's test locally. PostGIS 2.5 versus PostGIS 3.1, exactly the same dependencies, including Proj6, and his example query runs 50x slower on 3.1. Almost certainly Proj setup overhead, but still to be confirmed.<div class=""><font face="Consolas" class=""><span style="font-style: normal;" class=""><br class=""></span></font></div><div class=""><font face="Consolas" class=""><span style="font-style: normal;" class="">CREATE EXTENSION postgis;<br class=""><br class="">CREATE TABLE points AS SELECT * FROM (VALUES ('SRID=4326;POINT(-124.9921 49.6851)'::geometry), ('SRID=4326;POINT(-119.4032 50.0305)'::geometry), ('SRID=4326;POINT(-122.799 49.1671)'::geometry), ('SRID=4326;POINT(-122.3379 49.0597)'::geometry), ('SRID=4326;POINT(-123.1264 49.2671)'::geometry), ('SRID=4326;POINT(-122.7132 49.0519)'::geometry), ('SRID=4326;POINT(-124.3475 49.3042)'::geometry), ('SRID=4326;POINT(-119.389 49.8891)'::geometry), ('SRID=4326;POINT(-123.126 49.281)'::geometry), ('SRID=4326;POINT(-122.6606 49.1134)'::geometry), ('SRID=4326;POINT(-124.3233 49.312)'::geometry), ('SRID=4326;POINT(-124.0478 49.2397)'::geometry), ('SRID=4326;POINT(-119.2683 50.266)'::geometry), ('SRID=4326;POINT(-121.9705 49.081)'::geometry), ('SRID=4326;POINT(-123.8854 49.482)'::geometry), ('SRID=4326;POINT(-123.1528 49.77)'::geometry), ('SRID=4326;POINT(-120.8051 50.488)'::geometry), ('SRID=4326;POINT(-122.6403 49.1652)'::geometry), ('SRID=4326;POINT(-122.7717 49.2433)'::geometry), ('SRID=4326;POINT(-121.9587 49.1661)'::geometry))<br class="">p(g);<br class=""><br class="">CREATE INDEX ON points USING gist(g);<br class=""><br class="">CREATE OR REPLACE FUNCTION get_closest(p geometry(POINT)) RETURNS geometry(POINT) AS $$<br class=""> SELECT g FROM points ORDER BY st_transform(p, 3005) <-> st_transform(points.g, 3005) LIMIT 1<br class="">$$<br class="">STABLE<br class="">LANGUAGE SQL;<br class=""><br class="">SELECT postgis_full_version();<br class=""><br class="">EXPLAIN (ANALYZE) SELECT *, get_closest(g) FROM points ;</span></font></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""><div class=""><br class=""><blockquote type="cite" class="">On May 12, 2021, at 11:46 AM, Paul Ramsey <<a href="mailto:pramsey@cleverelephant.ca" class="">pramsey@cleverelephant.ca</a>> wrote:<br class=""><br class="">I've gotten a message from David Boone with some instructions on replication on Debian docker images that might yield a profile finally. One thing I noticed immediately while doing a quick try at local replication of this setup was that his systems were surprisingly consistent on dependencies: in fact the GEOS/Proj/GDAL versions were constant, while PostGIS went from 2.5 to 3.1. Proj version was 6. <br class=""><br class="">The thing I noticed while trying to build locally was that... I couldn't build PostGIS 2.5 locally. Aha... until PostGIS 3.0 there was no support for the modern proj API. My local proj is proj 8, which has the old API removed, so I cannot build PostGIS 2.5. However, David's setup used Proj 6, and Proj 6 retains support for BOTH the old and new APIs. So you can build PostGIS 2.5 against and also PostGIS 3.0 against it. But you will be building against DIFFERENT APIs, even though the Proj version you are building against is constant. So this is a potential explanation for "I changed nothing but PostGIS version and kept my Proj version constant, and yet my projection performance changed". <br class=""><br class="">If this analysis holds up, this is all going to come back down to caching proj objects and the context within which they are cached, almost certainly. Moving the proj cache up into the transaction context seems like the only way to handle this. Unfortunately, since we did great work in ensuring the cache machinery of all our caches is *shared* (proj, preparedgeom, toastcache, rtreecache, etc, etc) that means busting things up in some way. Maybe can get away with just passing a context parameter that's variable depending on cache type.<br class=""><br class="">I still do not have a reproduceable setup, but these last clues and directions might be enough to finally get there, at which point it's possible to muck out a fix and see if it actually *is* a fix.<br class=""><br class="">P.<br class=""><br class=""><blockquote type="cite" class="">On May 6, 2021, at 3:04 AM, Marco Boeringa <<a href="mailto:marco@boeringa.demon.nl" class="">marco@boeringa.demon.nl</a>> wrote:<br class=""><br class="">Hi Paul and others,<br class=""><br class="">Ok, so that issue with the wrong display of the PROJ version number when calling 'postgis_full_version' after the upgrade of PROJ from 6.3.1 to 7.2.1 using the UbuntuGIS repository available version, is insignificant.<br class=""><br class="">Is there anything else you want me to do? Even if I had the experience, I do not have the infrastructure to debug PostGIS / PROJ or anything else involved, except for the PostgreSQL / PostGIS install on Ubuntu. You posted a GitHub link to a C file (<a href="https://gist.github.com/pramsey/493b2490a8736fd8c00e30efa62e4ec3" class="">https://gist.github.com/pramsey/493b2490a8736fd8c00e30efa62e4ec3</a>), but I am unsure what to do with it. How do I run this?<br class=""><br class="">And what is the status of the speculation about a possible compiler optimization setting issue with PROJ 7.2.1 as available from the UbuntuGIS apt repository? Is there any new information about this?<br class=""><br class="">Marco<br class=""><br class="">Op 30-4-2021 om 17:16 schreef Paul Ramsey:<br class=""><blockquote type="cite" class=""><br class=""><br class=""><blockquote type="cite" class="">On Apr 30, 2021, at 1:05 AM, Marco Boeringa <<a href="mailto:marco@boeringa.demon.nl" class="">marco@boeringa.demon.nl</a>> wrote:<br class=""><br class="">Lastly, I am still a bit worried about the fact that 'SELECT postgis_full_version()' returns the old '6.3.1' PROJ version number after upgrading PROJ to '7.2.1'. Is there any logical explanation for this, e.g. 'postgis_full_version' only ever returning the version number of the PROJ it was originally compiled against, so never displaying the upgrade?<br class=""></blockquote><br class="">Sure, it’s fairly common, all you need is a library where the version information is communicated via compile-time #defines rather than a run-time getversion() function. Or a library that does both (like proj) and the implementing application uses the #defines. Early proj4 only had #defines, so it wouldn’t be surprising to find apps that still use them, even though modern proj has a runtime proj_version() available.<br class=""><br class="">P<br class=""><br class=""><br class="">_______________________________________________<br class="">postgis-devel mailing list<br class=""><br class=""><a href="mailto:postgis-devel@lists.osgeo.org" class="">postgis-devel@lists.osgeo.org</a><br class="">https://lists.osgeo.org/mailman/listinfo/postgis-devel<br class=""></blockquote>_______________________________________________<br class="">postgis-devel mailing list<br class=""><a href="mailto:postgis-devel@lists.osgeo.org" class="">postgis-devel@lists.osgeo.org</a><br class="">https://lists.osgeo.org/mailman/listinfo/postgis-devel<br class=""></blockquote><br class=""></blockquote><br class=""></div></div></body></html>