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.05k stars 3.8k forks source link

sql: remove `DEALLOCATE` statements from statement stats #69482

Open Azhng opened 3 years ago

Azhng commented 3 years ago

See #69375 for discussion.

Summary: we collects stats for DEALLOCATE but not for PREPARE statements. This is PREPARE has its own short circuit execution path in connExecutor that prevents sqlstats from collecting its statistics. As the result, Statement Page would show a lot of DEALLOCATE statements without corresponding PREPARE statements.

If DEALLOCATE is removed from the stats, then perhaps there should be metrics on it (and PREPARE) like these ones: https://github.com/cockroachdb/cockroach/blob/56afa9f4afb8211ef7783b7069cded1e1a880bed/pkg/sql/exec_util.go#L741

Jira issue: CRDB-9621

Epic CRDB-32139

maryliag commented 3 years ago

2 possible solutions: 1) make DEALLOCATE similar to PREPARE, meaning making DEALLOCATE do not appear in the statement stats 2) change PREPARE so that stats are collected

cc @kevin-v-ngo

rafiss commented 3 years ago

Leaving my current findings here. I'm happy to review this or work on it if that would help.

PREPARE doesn't show up in the stats because it is special-cased and returns early here: https://github.com/cockroachdb/cockroach/blob/0254918dfbe7ebc8a624562a8f7d3a9342b2b178/pkg/sql/conn_executor_exec.go#L533-L579

If desired, DEALLOCATE could probably be handled there too, instead of making it a function on planner: https://github.com/cockroachdb/cockroach/blob/0254918dfbe7ebc8a624562a8f7d3a9342b2b178/pkg/sql/deallocate.go#L23-L32

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!