Skip to content

Use MEST multi-entry indexing in the TRTREE index#143

Open
estebanzimanyi wants to merge 1 commit into
fix/trtree-index-assertionfrom
feat/trtree-mest-multientry
Open

Use MEST multi-entry indexing in the TRTREE index#143
estebanzimanyi wants to merge 1 commit into
fix/trtree-index-assertionfrom
feat/trtree-mest-multientry

Conversation

@estebanzimanyi
Copy link
Copy Markdown
Member

@estebanzimanyi estebanzimanyi commented May 16, 2026

A temporal column was indexed as a single minimum bounding box per row, so a wiggly or high-extent trajectory matched far more query boxes than it actually overlapped. Construct now indexes each temporal value as up to max_boxes tight per-segment bounding boxes via the MEOS rtree_insert_temporal_split (degenerating to the previous single-box behaviour for instants or max_boxes <= 1); temporal-spatial values are SRID-normalised to 0 before splitting so every produced stbox matches the SRID-stripped query box, and Search deduplicates row ids with a seen-set because multi-entry leaves return the same id once per overlapping segment box. The split bound is exposed as WITH (max_boxes = N), default 8, validated on the MEST selectivity benchmark (false-positive rate 47.2 percent single-box to 13.8 percent at 8). The portfile.cmake change here pins MEOS at the MEST commit only as a TEMPORARY BUILD-BASE so this PR is green in isolation; it deliberately conflicts with the wasm pin work in #142. At finalization this PR drops the portfile edit entirely and inherits #142s pin, which requires MobilityDB #1032 (MEST) to be merged to master alongside #1036 (wasm) so a single master commit carries both; the MobilityDuck merge order is #134, #136, #137, #138, #140, #141, #142, then #139, then this PR. Stacked on the TRTREE crash fix (fix/trtree-index-assertion).

@estebanzimanyi
Copy link
Copy Markdown
Member Author

Reviewer's quickstart — ~5 minutes

What this PR does in one sentence: switches the TRTREE index from single-entry per row to multi-entry indexing (MEST) — every spatial bbox of a temporal trajectory's component segments becomes an index entry, dramatically improving recall for spatial predicates.

Files (5):

  • src/index/rtree_index_create_physical.cpp — the new MEST build path.
  • src/index/rtree_index_scan.cpp — adjusted scan to dedup multi-entry hits.
  • src/include/index/rtree_module.hpp — type declarations for the new index payload.
  • test/sql/index/ — assertions on recall (no false negatives) and result-set deduplication.

Why it matters: previously a single trajectory got ONE bbox in the index — that bbox is loose (covers the whole trajectory's extent), so queries with small predicate polygons returned huge false-positive sets that had to be re-filtered. With MEST, each segment's bbox is indexed separately; a small predicate polygon hits only the relevant segments.

Foundational for: #144 (constant-geometry pushdown — depends on the multi-entry structure existing).

Cross-link: Linux arm64 build needs #161.

Why it's safe to merge: the index becomes strictly more precise — never lower recall (every old entry still maps to the trajectory it came from), never wrong results. Build cost goes up (more entries), query cost goes down (less false-positive filtering).

@estebanzimanyi estebanzimanyi force-pushed the feat/trtree-mest-multientry branch from 037aa12 to e300988 Compare May 29, 2026 21:36
@estebanzimanyi estebanzimanyi force-pushed the fix/trtree-index-assertion branch from 54e3c44 to 0af64ae Compare May 29, 2026 21:37
@estebanzimanyi estebanzimanyi force-pushed the feat/trtree-mest-multientry branch 2 times, most recently from 9ec3e35 to d25c8ef Compare May 30, 2026 05:15
@estebanzimanyi estebanzimanyi force-pushed the fix/trtree-index-assertion branch from 0af64ae to fff43eb Compare June 5, 2026 17:07
@estebanzimanyi estebanzimanyi force-pushed the feat/trtree-mest-multientry branch from d25c8ef to 83eea9d Compare June 5, 2026 17:08
@estebanzimanyi estebanzimanyi force-pushed the fix/trtree-index-assertion branch from fff43eb to fbf9182 Compare June 5, 2026 17:15
@estebanzimanyi estebanzimanyi force-pushed the feat/trtree-mest-multientry branch from 83eea9d to 27cd7ad Compare June 5, 2026 17:15
@estebanzimanyi estebanzimanyi force-pushed the fix/trtree-index-assertion branch from fbf9182 to 4995a85 Compare June 5, 2026 18:42
@estebanzimanyi estebanzimanyi force-pushed the feat/trtree-mest-multientry branch from 27cd7ad to dfa653a Compare June 5, 2026 18:42
@estebanzimanyi estebanzimanyi force-pushed the fix/trtree-index-assertion branch from 4995a85 to bcbfe19 Compare June 6, 2026 04:38
@estebanzimanyi estebanzimanyi force-pushed the feat/trtree-mest-multientry branch 2 times, most recently from 0f53ed4 to 648c951 Compare June 6, 2026 06:10
Build the TRTREE index with MEST multi-entry indexing, make it SRID-agnostic,
and fix multi-column projection.
@estebanzimanyi estebanzimanyi force-pushed the fix/trtree-index-assertion branch from 02dfc34 to 9fd27c5 Compare June 6, 2026 06:35
@estebanzimanyi estebanzimanyi force-pushed the feat/trtree-mest-multientry branch from 648c951 to 5d2bfb9 Compare June 6, 2026 06:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant