Skip to content

Conversation

@natalya-aksman
Copy link
Member

@natalya-aksman natalya-aksman commented Aug 11, 2025

Implement not-NULL mode for SkipScan when we can deduce at planning time that a scan key is guaranteed to be not NULL.
It allows to simplify execution by skipping null-check stages. Multikey SkipScan is much easier implemented in not-NULL mode.

We can say that a skip key is not NULL when it's declared not-NULL in the table or when it is a part of a strict filter on that table, or when there is IS NOT NULL index qual on the key.

Disable-check: force-changelog-file

@github-actions
Copy link

@fabriziomello, @dbeck: please review this pull request.

Powered by pull-review

@codecov
Copy link

codecov bot commented Aug 11, 2025

Codecov Report

❌ Patch coverage is 92.98246% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.37%. Comparing base (21e2212) to head (2be6363).
⚠️ Report is 50 commits behind head on main.

Files with missing lines Patch % Lines
tsl/src/nodes/skip_scan/planner.c 92.45% 1 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8479      +/-   ##
==========================================
+ Coverage   82.28%   82.37%   +0.09%     
==========================================
  Files         248      248              
  Lines       47487    47509      +22     
  Branches    12059    12075      +16     
==========================================
+ Hits        39073    39137      +64     
- Misses       3503     3519      +16     
+ Partials     4911     4853      -58     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@natalya-aksman natalya-aksman force-pushed the implement_notnull_skipscan_mode branch from 65f8255 to a15b1fb Compare August 12, 2025 13:14
@dbeck
Copy link
Member

dbeck commented Aug 14, 2025

I think, if you wanted to increase the test coverage for null accepting filters, maybe you could use:

1, coalesce(intcol, 0) < 10
2, boolcol is not true

The second one passes through, both null and false.

@natalya-aksman
Copy link
Member Author

I think, if you wanted to increase the test coverage for null accepting filters, maybe you could use:

1, coalesce(intcol, 0) < 10 2, boolcol is not true

The second one passes through, both null and false.

Will add the tests. Both filters are recognized as non-strict by PG, i.e. I'm getting expected behavior with both.
Interesting that PG is smart enough to treat boolcol IS NOT true as a filter and boolcol != true as an index condition, with the latter not accepting nulls and former accepting nulls but being flagged as non-strict.

      ->  Custom Scan (SkipScan) on skip_scan  (cost=0.38..0.48 rows=2 width=1)
         ->  Index Only Scan using skip_scan_b_idx on skip_scan  (cost=0.29..250.63 rows=5012 width=1)
               Index Cond: (b > NULL::boolean)
               Filter: (b IS NOT TRUE)

vs.

   ->  Custom Scan (SkipScan) on skip_scan  (cost=0.29..0.64 rows=2 width=1)
         ->  Index Only Scan using skip_scan_b_idx on skip_scan  (cost=0.29..168.00 rows=5012 width=1)
               Index Cond: ((b > NULL::boolean) AND (b = false))

@natalya-aksman natalya-aksman force-pushed the implement_notnull_skipscan_mode branch 2 times, most recently from 00d1357 to d3cf225 Compare August 19, 2025 20:17
@natalya-aksman natalya-aksman force-pushed the implement_notnull_skipscan_mode branch from d3cf225 to 2be6363 Compare August 19, 2025 21:14
@natalya-aksman natalya-aksman merged commit 351fc9e into timescale:main Aug 19, 2025
43 checks passed
@natalya-aksman natalya-aksman added this to the v2.22.0 milestone Aug 21, 2025
@timescale-automation timescale-automation added the released-2.22.0 Released in 2.22.0 label Sep 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released-2.22.0 Released in 2.22.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants