perf(sql): optimise query performance through lazy size calculation#5939
perf(sql): optimise query performance through lazy size calculation#5939
Conversation
limit and interval searcheslimit and interval searches
core/src/main/java/io/questdb/cairo/IntervalBwdPartitionFrameCursor.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/questdb/griffin/engine/table/BwdTableReaderPageFrameCursor.java
Show resolved
Hide resolved
ideoma
left a comment
There was a problem hiding this comment.
Need adjustment for split partitions
ideoma
left a comment
There was a problem hiding this comment.
There is room to optimize the limit query size calculation
create table skip_test AS (
select x, timestamp_sequence('2025-08-01', 60 * 60 * 1000000L) ts
from long_sequence(100)
) timestamp(ts) PARTITION by day wal;
select * from skip_test
where ts > '2025-08-03T11'
limit 10, 20;If I run the SELECT from Web Console, it calls TableRader.openPartition() for partitions 2,3 when fetching data and 2,3,4 when calculating size. Given the query limit of 10 rows and the partition 3 size of 24 rows, there is no need to open partition 4.
limit and interval searches|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing Touches🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
[PR Coverage check]😍 pass : 213 / 222 (95.95%) file detail
|
|
@CodeRabbit please review |
🧩 Analysis chainI'll review the PR changes for you. Let me examine the code modifications and analyze the performance optimizations. @bluestreak01 I've completed my review of the PR. This is an excellent performance optimization with well-structured lazy evaluation implementation. Here are my findings: ✅ Strengths
|
This PR improves query performance by replacing eager size calculation with lazy evaluation for interval queries and hash joins.
Changes
Interval queries:
Hash joins:
Performance impact
This is particularly beneficial for:
Compatibility
No breaking changes. The size() method now returns -1 when size is unknown, with actual calculation moved to the standard calculateSize() method.
Fixes #5915