-
Notifications
You must be signed in to change notification settings - Fork 623
Add cardinality estimate to AbstractPlan object #1475
Add cardinality estimate to AbstractPlan object #1475
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general looks good. Some minor comments.
src/optimizer/stats_calculator.cpp
Outdated
predicate_stats, op->predicates); | ||
// Use predicates to estimate cardinality | ||
if (table_stats->GetColumnCount() == 0) { | ||
root_group->SetNumRows(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When will this happen? When the table is empty? Or no stats exists? Or the cardinality estimation is 0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would happen if ColumnStatsCatalog::GetTableStats
returned no column stats. I believe this would happen if the catalog did not have stats for the table. This is assuming its not possible to have a table without columns.
* Clarified variable name * Added cardinality and test * Add optimizer testing class * Remove debugging code * Revert default estimate to fix broken test * Formatting * Removed unecessary override in Cardinality test * More comments and clean up tests
This PR adds the optimizer's cardinality estimate to the AbstractPlan object for use during plan execution. Includes test cases to verify it works. This is part of #1467 to add more optimizer estimates to plans.
Additionally, this PR adds an optimizer_test_util class with useful helper functions for creating test tables and generating plans. Future and possibly existing test cases should inherit from this class.