diff --git a/pkg/sql/sqlstats/persistedsqlstats/BUILD.bazel b/pkg/sql/sqlstats/persistedsqlstats/BUILD.bazel index bebb211be831..50547d7b0656 100644 --- a/pkg/sql/sqlstats/persistedsqlstats/BUILD.bazel +++ b/pkg/sql/sqlstats/persistedsqlstats/BUILD.bazel @@ -36,6 +36,7 @@ go_library( "//pkg/sql/isql", "//pkg/sql/sem/tree", "//pkg/sql/sessiondata", + "//pkg/sql/sessiondatapb", "//pkg/sql/sqlstats", "//pkg/sql/sqlstats/persistedsqlstats/sqlstatsutil", "//pkg/sql/sqlstats/sslocal", diff --git a/pkg/sql/sqlstats/persistedsqlstats/compaction_exec.go b/pkg/sql/sqlstats/persistedsqlstats/compaction_exec.go index 1c26a128e714..6fcb0ff8a6b6 100644 --- a/pkg/sql/sqlstats/persistedsqlstats/compaction_exec.go +++ b/pkg/sql/sqlstats/persistedsqlstats/compaction_exec.go @@ -20,6 +20,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/isql" "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" "github.com/cockroachdb/cockroach/pkg/sql/sessiondata" + "github.com/cockroachdb/cockroach/pkg/sql/sessiondatapb" "github.com/cockroachdb/cockroach/pkg/sql/sqlstats" "github.com/cockroachdb/cockroach/pkg/util/metric" "github.com/cockroachdb/cockroach/pkg/util/timeutil" @@ -207,10 +208,14 @@ func (c *StatsCompactor) removeStaleRowsForShard( func (c *StatsCompactor) executeDeleteStmt( ctx context.Context, delStmt string, qargs []interface{}, ) (lastRow tree.Datums, rowsDeleted int64, err error) { + qosLevel := sessiondatapb.UserLow it, err := c.db.Executor().QueryIteratorEx(ctx, "delete-old-sql-stats", nil, /* txn */ - sessiondata.NodeUserSessionDataOverride, + sessiondata.InternalExecutorOverride{ + User: sessiondata.NodeUserSessionDataOverride.User, + QualityOfService: &qosLevel, + }, delStmt, qargs..., )