Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
aadityasondhi committed Jan 29, 2024
1 parent 0fe4a72 commit 78ed64a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions pkg/sql/stats/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ go_library(
"//pkg/kv/kvclient/rangefeed",
"//pkg/kv/kvpb",
"//pkg/roachpb",
"//pkg/security/username",
"//pkg/settings",
"//pkg/settings/cluster",
"//pkg/sql/catalog",
Expand All @@ -45,6 +46,7 @@ go_library(
"//pkg/sql/sem/eval",
"//pkg/sql/sem/tree",
"//pkg/sql/sessiondata",
"//pkg/sql/sessiondatapb",
"//pkg/sql/sqlerrors",
"//pkg/sql/types",
"//pkg/util/cache",
Expand Down
12 changes: 11 additions & 1 deletion pkg/sql/stats/automatic_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (

"github.com/cockroachdb/cockroach/pkg/jobs/jobspb"
"github.com/cockroachdb/cockroach/pkg/keys"
"github.com/cockroachdb/cockroach/pkg/security/username"
"github.com/cockroachdb/cockroach/pkg/settings"
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
"github.com/cockroachdb/cockroach/pkg/sql/catalog"
Expand All @@ -28,6 +29,8 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/catalog/descs"
"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/util/log"
"github.com/cockroachdb/cockroach/pkg/util/protoutil"
"github.com/cockroachdb/cockroach/pkg/util/stop"
Expand Down Expand Up @@ -891,11 +894,18 @@ func (r *Refresher) refreshStats(ctx context.Context, tableID descpb.ID, asOf ti
AutomaticStatisticsMaxIdleTime.Get(&r.st.SV),
asOf.String(),
)
// We use the lowest quality of service level here since these statistics jobs
// are not time sensitive and should yield to other work.
qosLevel := sessiondatapb.SystemLow
log.Infof(ctx, "automatically executing %q", stmt)
_ /* rows */, err := r.ex.Exec(
_ /* rows */, err := r.ex.ExecEx(
ctx,
"create-stats",
nil, /* txn */
sessiondata.InternalExecutorOverride{
User: username.RootUserName(),
QualityOfService: &qosLevel,
},
stmt,
)
return err
Expand Down

0 comments on commit 78ed64a

Please sign in to comment.