Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize quals on segmentby columns in ColumnarScan #7661

Merged
merged 2 commits into from
Feb 7, 2025

Conversation

erimatnor
Copy link
Contributor

@erimatnor erimatnor commented Feb 6, 2025

When filtering arrow slots in ColumnarScan, quals on segmentby columns should be executed separately from those on other columns because they don't require decompression and might filter the whole arrow slot in one go. Furthermore, the quals only need to be applied once per arrow slot since the segmentby value is the same for all compressed rows in the slot.

This will speed up scans when filters on segmentby columns cannot be pushed down to Hypercore TAM as scankeys. For example, " IN (1, 2, 3)" won't be pushed down as a scankey because only index scans support scankeys with such scalar array expressions.

Disable-check: force-changelog-file
Disable-check: commit-count

Copy link

codecov bot commented Feb 6, 2025

Codecov Report

Attention: Patch coverage is 82.14286% with 15 lines in your changes missing coverage. Please review.

Project coverage is 81.34%. Comparing base (59f50f2) to head (8070393).
Report is 737 commits behind head on main.

Files with missing lines Patch % Lines
tsl/src/nodes/columnar_scan/columnar_scan.c 80.35% 1 Missing and 10 partials ⚠️
tsl/src/hypercore/hypercore_handler.c 60.00% 0 Missing and 2 partials ⚠️
tsl/src/hypercore/arrow_tts.h 88.88% 0 Missing and 1 partial ⚠️
tsl/src/hypercore/vector_quals.c 92.85% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7661      +/-   ##
==========================================
+ Coverage   80.06%   81.34%   +1.28%     
==========================================
  Files         190      242      +52     
  Lines       37181    44890    +7709     
  Branches     9450    11202    +1752     
==========================================
+ Hits        29770    36518    +6748     
- Misses       2997     3981     +984     
+ Partials     4414     4391      -23     

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

@erimatnor erimatnor marked this pull request as ready for review February 6, 2025 09:00
Copy link
Contributor

@mkindahl mkindahl left a comment

Choose a reason for hiding this comment

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

Pretty short one, so not really any comments. You might want to use more distinctive names to make the code easier to maintain and see if you can add tests for the branches not covered.

When filtering arrow slots in ColumnarScan, quals on segmentby columns
should be executed separately from those on other columns because they
don't require decompression and might filter the whole arrow slot in
one go. Furthermore, the quals only need to be applied once per arrow
slot since the segmentby value is the same for all compressed rows in
the slot.

This will speed up scans when filters on segmentby columns cannot be
pushed down to Hypercore TAM as scankeys. For example, "<column> IN
(1, 2, 3)" won't be pushed down as a scankey because only index scans
support scankeys with such scalar array expressions.
Fix a bug when backwards scanning a ColumnarScan and add a test case.
@erimatnor erimatnor force-pushed the hypercore-segmentby-quals branch from 5e8e03e to 8070393 Compare February 7, 2025 08:30
@erimatnor erimatnor enabled auto-merge (rebase) February 7, 2025 08:31
@erimatnor erimatnor merged commit cde8185 into timescale:main Feb 7, 2025
50 checks passed
@erimatnor erimatnor added the force-auto-backport Automatically backport this PR or fix of this issue, even if it's not marked as "bug" label Feb 7, 2025
@mkindahl mkindahl added this to the v2.18.1 milestone Feb 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backported-2.18.x force-auto-backport Automatically backport this PR or fix of this issue, even if it's not marked as "bug" hypercore table-access-method
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants