Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

domain,executor: ignore restricted sql for statement count metrics #4064

Merged
merged 2 commits into from Aug 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions domain/domain.go
Expand Up @@ -454,6 +454,7 @@ func (do *Domain) SysSessionPool() *pools.ResourcePool {
// LoadPrivilegeLoop create a goroutine loads privilege tables in a loop, it
// should be called only once in BootstrapSession.
func (do *Domain) LoadPrivilegeLoop(ctx context.Context) error {
ctx.GetSessionVars().InRestrictedSQL = true
do.privHandle = privileges.NewHandle()
err := do.privHandle.Update(ctx)
if err != nil {
Expand Down Expand Up @@ -517,6 +518,7 @@ func (do *Domain) CreateStatsHandle(ctx context.Context) {
// UpdateTableStatsLoop creates a goroutine loads stats info and updates stats info in a loop. It
// should be called only once in BootstrapSession.
func (do *Domain) UpdateTableStatsLoop(ctx context.Context) error {
ctx.GetSessionVars().InRestrictedSQL = true
do.statsHandle = statistics.NewHandle(ctx, do.statsLease)
do.ddl.RegisterEventCh(do.statsHandle.DDLEventCh())
err := do.statsHandle.Update(do.InfoSchema())
Expand Down
7 changes: 6 additions & 1 deletion executor/compiler.go
Expand Up @@ -42,7 +42,12 @@ func (c *Compiler) Compile(ctx context.Context, node ast.StmtNode) (ast.Statemen
if err != nil {
return nil, errors.Trace(err)
}
isExpensive := stmtCount(node, p)

var isExpensive bool
if !ctx.GetSessionVars().InRestrictedSQL {
// Don't take restricted SQL into account for metrics.
isExpensive = stmtCount(node, p)
}
sa := &statement{
is: is,
plan: p,
Expand Down