Support Postgres filters in columnar aggregation#9443
Open
akuzm wants to merge 12 commits intotimescale:mainfrom
Open
Support Postgres filters in columnar aggregation#9443akuzm wants to merge 12 commits intotimescale:mainfrom
akuzm wants to merge 12 commits intotimescale:mainfrom
Conversation
For some filters we don't have a vectorized implementation, but can still evaluate them inside the columnar pipeline using our standard way to evaluate the Postgres function. This allows us to use columnar aggregation when such filters are present, speeding up the queries.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
@kpan2034, @dbeck: please review this pull request.
|
antekresic
approved these changes
Apr 14, 2026
Member
antekresic
left a comment
There was a problem hiding this comment.
Couple of nits/questions otherwise lgtm
| DecompressContext *dcontext = &decompress_state->decompress_context; | ||
| BatchQueue *batch_queue = decompress_state->batch_queue; | ||
| DecompressBatchState *batch_state = batch_array_get_at(&batch_queue->batch_array, 0); | ||
| List *pg_quals = |
Member
There was a problem hiding this comment.
Is it really necessary to fetch these quals for every slot?
Member
Author
There was a problem hiding this comment.
I don't know, maybe we could copy them into a VectorAggState field, but on the other hand it's just an array access.
dbeck
approved these changes
Apr 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For some filters we don't have a vectorized implementation, but can still evaluate them inside the columnar pipeline using our standard way to evaluate the Postgres function. This allows us to use columnar aggregation when such filters are present, speeding up the queries.
In tsbench, the queries speed up 2x to 30%, cagg refresh included: https://grafana.dev-us-east-1.ops.dev.timescale.com/d/fasYic_4z/compare-benchmark-runs?orgId=1&var-run1=5528&var-run2=5526&var-postgres=16&var-branch=All&var-threshold=0.02&var-use_historical_thresholds=true&var-threshold_expression=2.0%20%2A%20percentile_cont%280.90%29&var-exact_suite_version=false