Skip to content

Perf: Use SPARQL VALUES for model ID restrictions - #193

Merged
mdorf merged 1 commit into
developmentfrom
perf/ids-filter-values
Jul 16, 2026
Merged

Perf: Use SPARQL VALUES for model ID restrictions#193
mdorf merged 1 commit into
developmentfrom
perf/ids-filter-values

Conversation

@mdorf

@mdorf mdorf commented Jul 15, 2026

Copy link
Copy Markdown
Member

Summary

  • Replace large disjunctive ID filters with SPARQL VALUES clauses on AllegroGraph, Virtuoso, and GraphDB.
  • Retain the existing FILTER implementation for 4store, which accepts VALUES syntax but does not apply the restriction.
  • Preserve percent-encoded spaces in RDF URIs and make empty ID collections a no-op.
  • Add focused coverage for backend behavior, empty IDs, URI encoding, and 500-ID batches.

Implements #191.

Verification

  • Focused query-builder tests: 5 runs, 20 assertions
  • test:where: 26 runs, 472 assertions
  • Full test suite: 181 runs, 3,159 assertions
  • RuboCop: no offenses

Performance

Measured from a local API process (Ruby 3.2.10) against the staging AllegroGraph instance containing production-equivalent data. The comparison used Goo development at cc806c8 and this branch at cb0b87b.

For each exact 500-ID SPARQL query, the benchmark used 5 warmups followed by 50 alternating measured requests per revision over persistent HTTP connections. The before/after result bindings were identical.

Workload Query bytes (before → after) Median (before → after) p95 (before → after)
UBERON classes 29,361 → 26,873 (-8.5%) 190.8 ms → 186.3 ms (-2.4%) 206.1 ms → 200.9 ms (-2.5%)
NCIT classes 36,520 → 34,032 (-6.8%) 238.2 ms → 233.4 ms (-2.1%) 272.5 ms → 286.7 ms (+5.2%)

An end-to-end UBERON API benchmark (3 warmups, 20 alternating measured requests per revision) was effectively flat: median response time was 732.1 ms before and 736.9 ms after.

The measured benefit is therefore a consistent 6.8–8.5% reduction in generated query size and about a 2% improvement in query median latency for these workloads. Tail latency was mixed, and this benchmark does not demonstrate a material end-to-end API speedup.

@mdorf
mdorf marked this pull request as ready for review July 15, 2026 22:21
@mdorf
mdorf merged commit 752fb6b into development Jul 16, 2026
10 checks passed
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