use SP-GIST index for building index where available

Point-in-polygon queries are much faster with a SP-GIST geometry
index, so use that for the index used to check if a housenumber
is inside a building.

Only available with Postgis 3. There is an automatic fallback to
GIST for Postgis 2.
This commit is contained in:
Sarah Hoffmann
2021-10-10 14:17:03 +02:00
parent 4b007ae740
commit 3649487f5e
3 changed files with 6 additions and 4 deletions

View File

@@ -46,8 +46,10 @@ def _setup_postgresql_features(conn):
depend on the database version.
"""
pg_version = conn.server_version_tuple()
postgis_version = conn.postgis_version_tuple()
return {
'has_index_non_key_column': pg_version >= (11, 0, 0)
'has_index_non_key_column': pg_version >= (11, 0, 0),
'spgist_geom' : 'SPGIST' if postgis_version >= (3, 0) else 'GIST'
}
class SQLPreprocessor: