Skip to content

sql: add routine DDL/DCL execution metrics#170899

Draft
spilchen wants to merge 1 commit into
cockroachdb:masterfrom
spilchen:spilchen/gh-170022/260525/0202p/stored-proc-metrics
Draft

sql: add routine DDL/DCL execution metrics#170899
spilchen wants to merge 1 commit into
cockroachdb:masterfrom
spilchen:spilchen/gh-170022/260525/0202p/stored-proc-metrics

Conversation

@spilchen
Copy link
Copy Markdown
Contributor

Operators have no way to attribute DDL or DCL traffic to stored procedures. The existing sql.routine.{select,update,insert,delete}.* counters cover DML inside routines but leave schema and privilege changes invisible, even though those statements are allowed inside procedure bodies.

Extend the routine metric family with per-type counters for CREATE/DROP TABLE (split by permanent vs temporary), CREATE/DROP SCHEMA, CREATE/DROP ROLE, GRANT, REVOKE, and ALTER DEFAULT PRIVILEGES, following the existing routine DML pattern.

Closes #170022

Release note (sql change): Added per-type counters for DDL and DCL statements executed inside stored procedure bodies, exposed as sql.routine..{started.count,count}.

Epic: CRDB-31256

@spilchen spilchen self-assigned this May 25, 2026
@trunk-io
Copy link
Copy Markdown
Contributor

trunk-io Bot commented May 25, 2026

Merging to master in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Operators have no way to attribute DDL or DCL traffic to stored
procedures. The existing sql.routine.{select,update,insert,delete}.*
counters cover DML inside routines but leave schema and privilege
changes invisible, even though those statements are allowed inside
procedure bodies.

Extend the routine metric family with per-type counters for CREATE/DROP
TABLE (split by permanent vs temporary), CREATE/DROP SCHEMA, CREATE/DROP
ROLE, GRANT, REVOKE, and ALTER DEFAULT PRIVILEGES, following the
existing routine DML pattern.

Closes cockroachdb#170022

Release note (sql change): Added per-type counters for DDL and DCL
statements executed inside stored procedure bodies, exposed as
sql.routine.<type>.{started.count,count}.

Epic: CRDB-31256

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@spilchen spilchen force-pushed the spilchen/gh-170022/260525/0202p/stored-proc-metrics branch from dd03732 to f324760 Compare May 25, 2026 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sql: execution metrics for DDL/DCL in routines

2 participants