Open Azhng opened 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.
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!
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