Skip to content

Commit

Permalink
chore:rule execution time
Browse files Browse the repository at this point in the history
  • Loading branch information
taolx0 committed Apr 1, 2024
1 parent 4fd76e6 commit 1820e2d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion sqle/driver/mysql/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
_driver "database/sql/driver"
"fmt"
"strings"
"time"

"github.com/actiontech/sqle/sqle/driver"
"github.com/actiontech/sqle/sqle/driver/mysql/executor"
Expand Down Expand Up @@ -355,7 +356,8 @@ func (i *MysqlDriverImpl) audit(ctx context.Context, sql string) (*driverV2.Audi
Res: i.result,
Node: nodes[0],
}

startTime := time.Now()
i.Logger().Infof("[audit_rule]rule: %v,start time: %v", rule.Desc, startTime)
if err := handler.Func(input); err != nil {
// todo #1630 临时跳过解析建表语句失败导致的规则
if session.IsParseShowCreateTableContentErr(err) {
Expand All @@ -364,9 +366,12 @@ func (i *MysqlDriverImpl) audit(ctx context.Context, sql string) (*driverV2.Audi
}
return nil, err
}
i.Logger().Infof("[audit_rule]rule: %v,total time: %v", rule.Desc, time.Since(startTime))
}

if i.cnf.optimizeIndexEnabled && index.CanOptimize(i.log, i.Ctx, nodes[0]) {
startTime := time.Now()
i.Logger().Infof("[audit_rule]rule: %v,start time: %v", rulepkg.ConfigOptimizeIndexEnabled, startTime)
optimizer := index.NewOptimizer(
i.log, i.Ctx,
index.WithCalculateCardinalityMaxRow(i.cnf.calculateCardinalityMaxRow),
Expand All @@ -387,6 +392,7 @@ func (i *MysqlDriverImpl) audit(ctx context.Context, sql string) (*driverV2.Audi
}
}
i.result.Add(driverV2.RuleLevelNotice, rulepkg.ConfigOptimizeIndexEnabled, buf.String())
i.Logger().Infof("[audit_rule]rule: %v,total time: %v", rulepkg.ConfigOptimizeIndexEnabled, time.Since(startTime))
}

// dry run gh-ost
Expand Down

0 comments on commit 1820e2d

Please sign in to comment.