SpacetimeDB icon indicating copy to clipboard operation
SpacetimeDB copied to clipboard

Add metrics for subscription queries

Open drogus opened this issue 2 months ago • 1 comments

Description of Changes

We have some metrics measuring various lower level things like index scans, but at the moment we have no easy way to figure out which columns might need an index. This commit introduces three new metrics that provide that information by labeling count, latency, and number of rows canned along with the scan type (index scan, table scan, mixed scan) and info about unindexed columns.

API and ABI breaking changes

None

Expected complexity level and risk

2

I'm honestly not sure. I don't think it's overly complex, but it adds some overhead in the subscriptions initial query path.

Testing

  • [x] I've tested the changes locally

drogus avatar Nov 14 '25 12:11 drogus

@joshua-spacetime I guess I wanted to add scan type in case we want to use these metrics for something else, but couldn't a partial index scan also benefit from adding a compound index? Like, you have x, y columns, but you have an index only on x, but for each x value you have 10k rows with different y values. So then SELECT * FROM points WHERE x = 10 AND y = 10 would use an index on the x column, but then it would have to load 10k rows and filter them. Am I missing something?

drogus avatar Nov 15 '25 01:11 drogus