Skip to content

Answer the PostGIS operators soundly from a multi-entry key - #34

Merged
estebanzimanyi merged 1 commit into
MobilityDB:masterfrom
estebanzimanyi:fix/postgis-mest-sound
Aug 28, 2026
Merged

Answer the PostGIS operators soundly from a multi-entry key#34
estebanzimanyi merged 1 commit into
MobilityDB:masterfrom
estebanzimanyi:fix/postgis-mest-sound

Conversation

@estebanzimanyi

Copy link
Copy Markdown
Member

The operator class geometry_mgist_ops_2d carries &&, which PostGIS answers on the bounding box of a geometry, so the whole geometry is the first key a value extracts and every operator answered on that box is witnessed by a key of the value. A query box meeting the box of a geometry in a gap between its members is answered by that key, where a key covering only a member leaves the row unreachable.

Each member of a multi-part geometry is a key of its own, kept whatever its dimension, so the point of a GEOMETRYCOLLECTION(POINT, POLYGON) carries an entry alongside the polygon; lwcollection_extract with a self-discovered type keeps only the largest dimension. The type decides which geometries have members, so the rings of a curve polygon and the arcs of a compound curve stay part of the single geometry they bound, a distinction the lwtype_is_collection predicate does not draw. A value that extracts a single key hands back a palloc'd array holding it, which the caller reads after the extract method returns.

Against PostgreSQL 18.3 and PostGIS 3.6.3, two hundred query boxes over two hundred and forty geometries whose members lie far apart match 2000 pairs sequentially, and the multi-entry scan reaches all 2000 of them and invents none. The regression tests in contrib/postgis/sql state those counts for a multi-entry scan and a sequential scan and read the sequential count as positive, so the comparison cannot hold vacuously. cmake --build <dir> --target installcheck runs them against a server holding the installed extension.

The operator class carries the overlaps operator, which PostGIS answers on the
bounding box of a geometry, so the whole geometry is the first key a value
extracts and every operator answered on that box is witnessed by a key. Each
member of a multi-part geometry is a key of its own, kept whatever its
dimension, and the type decides which geometries have members, so the rings of a
curve polygon and the arcs of a compound curve stay part of the single geometry
they bound. A value that extracts one key hands back a palloc'd array holding it.

The regression tests state the counts a multi-entry scan and a sequential scan
give for the operator over geometries whose members lie far apart, and read the
sequential count as positive so the comparison cannot hold vacuously.
@estebanzimanyi
estebanzimanyi merged commit 20727f9 into MobilityDB:master Aug 28, 2026
1 check passed
@estebanzimanyi
estebanzimanyi deleted the fix/postgis-mest-sound branch August 28, 2026 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant