Skip to content

Rewrite single chain joins to scan on materialized view if possible#2649

Open
ullingerc wants to merge 84 commits intoad-freiburg:masterfrom
ullingerc:matview-detect-join
Open

Rewrite single chain joins to scan on materialized view if possible#2649
ullingerc wants to merge 84 commits intoad-freiburg:masterfrom
ullingerc:matview-detect-join

Conversation

@ullingerc
Copy link
Member

@ullingerc ullingerc commented Jan 19, 2026

This change introduces the first part of infrastructure for rewriting joins to scans on materialized views. Additionally, a first implementation for rewriting simple chains (as in ?s <p1>/<p2> ?o) is included.

Depends on #2639 and #2653

Example:

Write and load the view for geo;hasGeometry/geo:asWKT:

qlever materialized-view geometries "PREFIX geo: <http://www.opengis.net/ont/geosparql#> SELECT * { ?s geo:hasGeometry ?m . ?m geo:asWKT ?wkt }" # use ?m instead of property path, because we are missing the intermediate variable otherwise
curl 'localhost:PORT?cmd=load-materialized-view&view-name=geometries&access-token=TOKEN'

Then use it implicitly in queries: With variable subject:

PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX osmkey: <https://www.openstreetmap.org/wiki/Key:>
SELECT * {
  ?osm osmkey:railway "rail" .
  ?osm geo:hasGeometry/geo:asWKT ?geometry .
}

or with fixed subject:

PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX osmrel: <https://www.openstreetmap.org/relation/>
SELECT * {
  osmrel:9407 geo:hasGeometry/geo:asWKT ?geometry .
}

@codecov
Copy link

codecov bot commented Jan 19, 2026

Codecov Report

❌ Patch coverage is 86.59794% with 39 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.56%. Comparing base (cca3768) to head (6a8f219).

Files with missing lines Patch % Lines
src/engine/MaterializedViewsQueryAnalysis.cpp 76.15% 13 Missing and 18 partials ⚠️
src/parser/GraphPatternAnalysis.cpp 55.55% 3 Missing and 1 partial ⚠️
src/engine/QueryPlanner.cpp 96.62% 1 Missing and 2 partials ⚠️
src/engine/MaterializedViewsQueryAnalysis.h 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2649      +/-   ##
==========================================
- Coverage   91.60%   91.56%   -0.05%     
==========================================
  Files         483      489       +6     
  Lines       41360    41626     +266     
  Branches     5493     5549      +56     
==========================================
+ Hits        37886    38113     +227     
- Misses       1897     1913      +16     
- Partials     1577     1600      +23     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ullingerc ullingerc marked this pull request as ready for review January 20, 2026 16:18
Copy link
Member

@joka921 joka921 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A first round, but unfortunately only for the stuff in parser and util.
For the sake of progress, I would suggest splitting these + their unit tests to a separate PR, s.t. we can make this one smaller, and get incremental progress.

Comment on lines +22 to +24
// NOTE: This does not guarantee completeness, so it might return `false` even
// though we could be invariant to a `GraphPatternOperation`.
struct BasicGraphPatternsInvariantTo {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand now, but really can't parse the name still, maybe we come up with something... :)

@sparql-conformance
Copy link

Overview

Number of Tests Passed ✅ Intended ✅ Failed ❌ Not tested
547 450 73 24 0

Conformance check passed ✅

No test result changes.

Details: https://qlever.dev/sparql-conformance-ui?cur=6a8f2192814be1a5c2dae1f7a724bf23cd989a03&prev=cca37689eb8be289bc51bcb675030d05dd10f671

@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 3, 2026

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.

3 participants