cockroachdb / cockroach

CockroachDB — the cloud native, distributed SQL database designed for high availability, effortless scale, and control over data placement.
https://www.cockroachlabs.com
Other
30.21k stars 3.82k forks source link

sql: track statement-related queries within the planner instead of connExecutor #71839

Open Azhng opened 3 years ago

Azhng commented 3 years ago

Previously, we track sql.{select, insert, update, delete}.count metrics within the connExecutor. We attempt to classify the statement types and then increment those metrics accordingly.

However, this fails in the case of CTE, statements where all 4 types of the statements can be embedded within a single CTE statement. This causes our metrics to severely under-counting. What we should do instead, is to push down the statement metrics counting down to planner level, where each embedded statements is treated as its own subquery. This is where we can perform more accurate accounting.

cc: @daniel-crlabs

Jira issue: CRDB-10794

Epic CRDB-32139

daniel-crlabs commented 3 years ago

Thank you for the update, this sounds exactly what I thought it was happening. Thanks for getting to the bottom of this and creating this issue.

github-actions[bot] commented 1 year ago

We have marked this issue as stale because it has been inactive for 18 months. If this issue is still relevant, removing the stale label or adding a comment will keep it active. Otherwise, we'll close it in 10 days to keep the issue queue tidy. Thank you for your contribution to CockroachDB!