-
Notifications
You must be signed in to change notification settings - Fork 21
CNDB-15508: Query planner metrics #2130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Checklist before you submit for review
|
ekaterinadimitrova2
left a comment
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.
Not a full review, just started looking into this, just dropped a few quick comments
src/java/org/apache/cassandra/index/sai/metrics/TableQueryMetrics.java
Outdated
Show resolved
Hide resolved
7986ec2 to
52e877c
Compare
ekaterinadimitrova2
left a comment
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.
Looks great, left just some questions.
There are some GH problems today and CI fails. You will need to restart it to check the results.
1729cba to
37f1fa3
Compare
src/java/org/apache/cassandra/index/sai/metrics/TableQueryMetrics.java
Outdated
Show resolved
Hide resolved
test/unit/org/apache/cassandra/index/sai/metrics/QueryMetricsTest.java
Outdated
Show resolved
Hide resolved
test/unit/org/apache/cassandra/index/sai/metrics/QueryMetricsTest.java
Outdated
Show resolved
Hide resolved
ekaterinadimitrova2
left a comment
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.
Overall looks great, I just left some tiny comments.
There is some issue with CI so it did not run.
Regarding testing - shouldn't we add some test for the new flag added - cassandra.sai.metrics.query_plan.enabled?
src/java/org/apache/cassandra/index/sai/metrics/TableQueryMetrics.java
Outdated
Show resolved
Hide resolved
test/unit/org/apache/cassandra/index/sai/metrics/QueryMetricsTest.java
Outdated
Show resolved
Hide resolved
src/java/org/apache/cassandra/index/sai/metrics/TableQueryMetrics.java
Outdated
Show resolved
Hide resolved
2f424cb to
765b18b
Compare
src/java/org/apache/cassandra/index/sai/metrics/TableQueryMetrics.java
Outdated
Show resolved
Hide resolved
Yes, added. |
6e8682d to
dab6384
Compare
adelapena
left a comment
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.
Looks great, +1
ekaterinadimitrova2
left a comment
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.
About SAI_QUERY_PLAN_METRICS_ENABLED:
-
On the other PR there was a mention the new property may work also dynamically, during runtime. I think we need to add a test for that too, if that will be the expectation.
-
I left a comment that we need to reset to default value the property at the end of each test where we toggle it.
-
Thinking about enable/disable at runtime - we should think whether that would persist the metrics we already collected (in case we disable) or not. WDYT?
-
My main concern is that we report 0s instead of not registering the metrics at all once we disable them. That is something we discussed when we added a setting to be able to disable the
IndexMetrics. More in the PR comments.
test/unit/org/apache/cassandra/index/sai/metrics/QueryMetricsTest.java
Outdated
Show resolved
Hide resolved
a39c56f to
dd2eb69
Compare
47135d3 to
ffa84a5
Compare
This commit adds new metrics related to the operation of SAI query planner. The metrics should help checking if the query planner makes proper decisions by correlating them with the other metrics, e.g. the metrics of the actual query execution. Per-query metrics (histograms): - `RowsToReturnEstimated`: the estimated number of rows to be returned by the query - `RowsToFetchEstimated`: the estimated number of rows the query is going to fetch from storage - `KeysToIterateEstimated`: the estimated number of primary keys to read from the indexes when executing the query to completion - `CostEstimated`: the abstract cost of query execution - `LogSelectivityEstimated`: minus decimal logarithm of query selectivity, before applying the query LIMIT (0 means the query selects all rows, 5 means it selects 10^(-5) = 0.00001 subset of rows) - `IndexReferencesInQuery`: the number of index references in the unoptimized query execution plan (the same index may be referenced multiple times and counts separately) - `IndexReferencesInPlan`: the number of index references in the optimized query execution plan (the same index may be referenced multiple times and counts separately) Per-table: - `TotalRowsToReturnEstimated`: the sum of all estimates of returned rows from all completed queries - `TotalRowsToFetchEstimated`: the sum of all estimates of fetched rows from all completed queries - `TotalKeysToIterateEstimated`: the sum of all estimates of iterated primary keys from all completed queries - `TotalCostEstimated`: counts the sum of all cost estimates from all completed queries # Conflicts: # src/java/org/apache/cassandra/index/sai/QueryContext.java
ffa84a5 to
af73a4f
Compare
|



This commit adds new metrics related to the operation of SAI query
planner. The metrics should help checking if the query planner makes
proper decisions by correlating them with the other metrics,
e.g. the metrics of the actual query execution.
Per-query metrics (histograms):
RowsEstimated: the estimated number of rows to be returned bythe query
CostEstimated: the abstract cost of query executionInverseSelectivityEstimated: the inverse of query selectivity,before applying the query LIMIT
(1 means the query selects all rows, 10 means it
selects every 10th row, etc.)
IndexReferencesInQuery: the number of index references in theunoptimized query execution plan (the same index may
be referenced multiple times and counts separately)
IndexReferencesInPlan: the number of index references in theoptimized query execution plan (the same index may
be referenced multiple times and counts separately)
Per-table:
TotalRowsEstimated: counts the sum of all row estimates fromall completed queries
TotalCostEstimated: counts the sum of all cost estimates fromall completed queries
TotalQueriesCompletedInSelectivityGroup{N}, where N in [0, 12):counts the number of completed queries with selectivity S:
10^(-N-1) < S <= 10^(-N) for N < 11,
S <= 10^(-N) for N = 11
In other words, the higher the group N, the smaller fraction of rows
the query is estimated to return. The selectivity calculation
does not include the final LIMIT of the query.