SpacetimeDB icon indicating copy to clipboard operation
SpacetimeDB copied to clipboard

Lift restriction that multi-col indices only allow = constraints

Open mamcx opened this issue 6 months ago • 0 comments

Description of Changes

Closes #1317

We had to disable this in https://github.com/clockworklabs/SpacetimeDB/pull/1316 but we should lift the restriction eventually for better query performance.

API and ABI breaking changes

Expected complexity level and risk

2

We optimize up to 3 columns in an index, and:

  • When all the comparisons are!= is always a full table scan
  • Multi-column indexes are only used if the query has a prefix match (ie all operators are =)
  • Else are converted to a single column index scan on the leftmost column and a filter on the rest

Testing

  • [*] Expand the testing to verify the plans to all the ops "=", ">", "<", ">=", "<=", !=
  • [*] Expand the testing to verify we return the same rows when executing the query with the above ops

mamcx avatar Jun 16 '25 16:06 mamcx