Skip to content
This repository was archived by the owner on Jan 7, 2025. It is now read-only.

feat: Support limit operations #58

Merged
merged 10 commits into from
Feb 12, 2024
Merged

feat: Support limit operations #58

merged 10 commits into from
Feb 12, 2024

Conversation

jurplel
Copy link
Member

@jurplel jurplel commented Feb 11, 2024

No description provided.

@jurplel jurplel added the enhancement New feature or request label Feb 11, 2024
@jurplel jurplel marked this pull request as ready for review February 11, 2024 22:31
@jurplel jurplel requested a review from yliang412 February 11, 2024 23:37
Copy link
Member

@yliang412 yliang412 left a comment

Choose a reason for hiding this comment

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

LGTM, left a small comment trying to understand the cost for limit

@@ -107,6 +107,11 @@ impl CostModel<OptRelNodeTyp> for OptCostModel {
Self::cost(row_cnt, 0.0, row_cnt)
}
OptRelNodeTyp::PhysicalEmptyRelation => Self::cost(0.5, 0.01, 0.0),
OptRelNodeTyp::PhysicalLimit => {
Copy link
Member

Choose a reason for hiding this comment

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

Just wondering how is this determined?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't fully understand the cost system in play here just yet, but there are a few things to notice:
-The row_cnt is from the child tuple

  • I multiply by selectivity as a very rough estimate for what the cost might be
    • usually LIMIT clauses are quite selective, so that is my sketchy reasoning for 0.001. Also, it is the same selectivity as FILTER.
  • the computation cost for this one I just set to row_cnt. No reasoning really. Looking again at other examples, I think that should probably be compute_cost from the child, so I will change it.

There is probably a cleverer way to do this by actually reading LIMIT, but I think it might be best to leave that for a real cost model.

@jurplel jurplel merged commit feffd5b into main Feb 12, 2024
@jurplel jurplel deleted the bowad/limit branch February 12, 2024 22:35
jurplel added a commit that referenced this pull request Feb 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request logical_optimizer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants