Answer the PostGIS operators soundly from a multi-entry key - #34
Merged
estebanzimanyi merged 1 commit intoAug 28, 2026
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The operator class
geometry_mgist_ops_2dcarries&&, 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_extractwith 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 thelwtype_is_collectionpredicate 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/sqlstate 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 installcheckruns them against a server holding the installed extension.