-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Slow introspection query in asyncpg #113292
Comments
There was a similar issue with a django introspection query once before but that was due to rewriting the built in as an internal udf: |
I wrote a rttanalysis test that shows that there's only one descriptor lookup happening, but this query still takes ~2-4 seconds. I will merge this test, then I think the next step is to figure out if the query plan can be improved. |
Benchmark is in #113538. The results from running on my laptop show that it takes 7 seconds.
|
113538: rttanalysis: add a benchmark for asyncpg query to load types r=rafiss a=rafiss This benchmark shows that a query made by asyncpg only performs one KV roundtrip, but still takes multiple seconds to complete because of a suboptimal query plan. It's likely that WITH RECURSIVE is part of the problem. informs #113292 Release note: None 113575: roachtest: remove unused config from allocbench r=andrewbaptist a=kvoli The node attributes were not used by any test configuration, remove them. Part of: #110115 Release note: None --- The replication factor config was never used, remove it. Part of #110115 Release note: None Co-authored-by: Rafi Shamim <rafi@cockroachlabs.com> Co-authored-by: Austen McClernon <austen@cockroachlabs.com>
On 22.2 we couldn't execute this query because we couldn't decorrelate the subquery. On 23.1 I got 2s local execution time, on current master I got 2.8s. |
This commit adds a new norm rule, `FoldGroupByAndWindow`, which can merge a Window operator with a parent GroupBy operator when the grouping columns are the same as the partition columns. See the rule comment for the complete list of conditions. In addition to removing a potentially expensive Window operator, this transformation makes way for other rules to match. Fixes cockroachdb#113292 Release note: None
This commit adds a new norm rule, `FoldGroupByAndWindow`, which can merge a Window operator with a parent GroupBy operator when the grouping columns are the same as the partition columns. See the rule comment for the complete list of conditions. In addition to removing a potentially expensive Window operator, this transformation makes way for other rules to match. Fixes cockroachdb#113292 Release note: None
This commit adds a new norm rule, `FoldGroupByAndWindow`, which can merge a Window operator with a parent GroupBy operator when the grouping columns are the same as the partition columns. See the rule comment for the complete list of conditions. In addition to removing a potentially expensive Window operator, this transformation makes way for other rules to match. Fixes cockroachdb#113292 Release note: None
This commit adds a new norm rule, `FoldGroupByAndWindow`, which can merge a Window operator with a parent GroupBy operator when the grouping columns are the same as the partition columns. See the rule comment for the complete list of conditions. In addition to removing a potentially expensive Window operator, this transformation makes way for other rules to match. Fixes cockroachdb#113292 Release note: None
This commit adds a new norm rule, `FoldGroupByAndWindow`, which can merge a Window operator with a parent GroupBy operator when the grouping columns are the same as the partition columns. See the rule comment for the complete list of conditions. In addition to removing a potentially expensive Window operator, this transformation makes way for other rules to match. Fixes cockroachdb#113292 Release note: None
117499: opt: add rule to merge GroupBy and Window operators r=DrewKimball a=DrewKimball #### opt: add method to add strict dependency to FuncDepSet This commit adds a new method, `AddStrictDependency`, to `FuncDepSet`. This will be used in the following commit to add a dependency between a Window operator's partition columns and its functions. Existing methods don't work for this because the dependency is not a key. Epic: None Release note: None #### opt: infer functional dependencies for window functions This commit adds logic to infer strict functional dependencies from a Window operator's partition column(s) to some or all of its window functions when the following conditions are satisfied: 1. The window function must be an aggregate, or first_value or last_value. 2. The window frame must be unbounded. The above conditions ensure that the window function always produces the same result given the same window frame, as well as that every row in a partition has the same window frame. This means that the window function produces the same output for every row in the partition, and therefore, the partition columns functionally determine the output of the window function. Epic: None Release note: None #### opt: add rule to merge GroupBy and Window This commit adds a new norm rule, `FoldGroupByAndWindow`, which can merge a Window operator with a parent GroupBy operator when the grouping columns are the same as the partition columns. See the rule comment for the complete list of conditions. In addition to removing a potentially expensive Window operator, this transformation makes way for other rules to match. Fixes #113292 Release note: None 137069: opt: add implicit SELECT FOR UPDATE to initial scan of DELETE r=yuzefovich a=yuzefovich This commit makes it so that we apply implicit SELECT FOR UPDATE locking behavior to the initial scan of the DELETE operation in some cases. Namely, we do so when the input to the DELETE is either a scan or an index join on top of a scan (with any number of renders on top) - these conditions mean that all filters were pushed down into the scan, so we won't lock any unnecessary rows. I think it's only possible to have at most one render expression on top of the scan, but I chose to be defensive and allowed nested renders too. In such form the conditions are exactly the same as we use for adding SFU to UPDATEs, so the same function is reused. Existing `enable_implicit_select_for_update` session variable is consulted. Fixes: #50181. Release note (sql change): DELETE statements now acquire locks using the FOR UPDATE locking mode during their initial row scan in some comes, which improves performance for contended workloads. This behavior is configurable using the `enable_implicit_select_for_update` session variable. Co-authored-by: Drew Kimball <drewk@cockroachlabs.com> Co-authored-by: Yahor Yuzefovich <yahor@cockroachlabs.com>
Explain Analyze Verbose:
This query takes 1.9 seconds on a 3 node local roachprod cluster. This can cause weird slow latencies when using asyncpg when these checks run.
We should check if rest of the queries here are also slow:
https://github.com/MagicStack/asyncpg/blob/master/asyncpg/introspection.py (edite
Jira issue: CRDB-32853
The text was updated successfully, but these errors were encountered: