perf(sql): apply scan optimization for first/last/min/max(timestamp) as function argument #6690
Conversation
WalkthroughThis PR optimizes first/last/min/max timestamp functions when used as arguments to other functions (e.g., Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ast-grep (0.40.5)core/src/main/java/io/questdb/griffin/SqlOptimiser.javaThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
first/last/min/max(timestamp) as function argument
first/last/min/max(timestamp) as function argument first/last/min/max(timestamp) as function argument
[PR Coverage check]😍 pass : 24 / 25 (96.00%) file detail
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@CodeRabbit, what is the story? |
|
Tip For best results, initiate chat on the files or code changes.
The ProblemWhen users wrote queries like The InconsistencyInterestingly, these faster alternatives already worked:
The FixThe PR reorders the optimizer passes - specifically moving The ImpactQueries using The coverage looks solid at 96%, and the change is focused on the optimizer control flow in |
Fixes #6633
Move
rewriteSingleFirstLastGroupByafterrewriteSelectClauseto optimise queries likeSELECT dateadd('m', -15, max(ts)) FROM twheremaxaggregate function as function argument