Skip to content

Commit ce23fed

Browse files
fix(oracle): 增加收集间隔时间参数
1 parent 8a32ed3 commit ce23fed

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

sqle/pkg/oracle/db.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func (o *DB) Close() error {
5353
return o.db.Close()
5454
}
5555

56-
func (o *DB) QueryTopSQLs(ctx context.Context, topN int, notInUsers []string, orderBy string) ([]*DynPerformanceSQLArea, error) {
56+
func (o *DB) QueryTopSQLs(ctx context.Context, collectIntervalMinute string, topN int, notInUsers []string, orderBy string) ([]*DynPerformanceSQLArea, error) {
5757
// if notInUsers is empty, notInUsersStr will be empty
5858
// if notInUsers is not empty, notInUsersStr will be formatted as "AND u.username NOT IN ('user1', 'user2')"
5959
var notInUsersStr string
@@ -75,7 +75,7 @@ func (o *DB) QueryTopSQLs(ctx context.Context, topN int, notInUsers []string, or
7575
}
7676
var ret []*DynPerformanceSQLArea
7777
for _, metric := range metrics {
78-
query := fmt.Sprintf(DynPerformanceViewSQLAreaTpl, notInUsersStr, metric, topN)
78+
query := fmt.Sprintf(DynPerformanceViewSQLAreaTpl, collectIntervalMinute, notInUsersStr, metric, topN)
7979
rows, err := o.db.QueryContext(ctx, query)
8080
if err != nil {
8181
rows.Close()

sqle/pkg/oracle/perf.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ SELECT * FROM (
3333
JOIN
3434
DBA_USERS u ON s.parsing_user_id = u.user_id
3535
WHERE
36+
last_active_time >= SYSDATE - INTERVAL '%v' MINUTE AND
3637
s.EXECUTIONS > 0
3738
%v
3839
ORDER BY %v DESC

sqle/server/auditplan/task_type_oracle_topsql.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func (at *OracleTopSQLTaskV2) ExtractSQL(logger *logrus.Entry, ap *AuditPlan, pe
125125
notInUser = append(notInUser, blacklist.FilterContent)
126126
}
127127
// filter db user by
128-
sqls, err := db.QueryTopSQLs(ctx, ap.Params.GetParam("top_n").Int(), notInUser, ap.Params.GetParam("order_by_column").String())
128+
sqls, err := db.QueryTopSQLs(ctx, ap.Params.GetParam("collect_interval_minute").String(), ap.Params.GetParam("top_n").Int(), notInUser, ap.Params.GetParam("order_by_column").String())
129129
if err != nil {
130130
return nil, fmt.Errorf("query top sql fail, error: %v", err)
131131
}

0 commit comments

Comments
 (0)