Skip to content

Commit

Permalink
Backend: replace UNIX_TIMESTAMP with FROM_UNIXTIME in statement query (
Browse files Browse the repository at this point in the history
…#731)

(cherry picked from commit d50adbf)
  • Loading branch information
ericsyh authored and breezewish committed Sep 8, 2020
1 parent ac6e04a commit 4b57ab6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/apiserver/statement/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func QueryStatementsOverview(
query := db.
Select(strings.Join(fields, ", ")).
Table(statementsTable).
Where("UNIX_TIMESTAMP(summary_begin_time) >= ? AND UNIX_TIMESTAMP(summary_end_time) <= ?", beginTime, endTime).
Where("summary_begin_time >= FROM_UNIXTIME(?) AND summary_end_time <= FROM_UNIXTIME(?)", beginTime, endTime).
Group("schema_name, digest, digest_text").
Order("agg_sum_latency DESC")

Expand Down Expand Up @@ -212,7 +212,7 @@ func QueryPlans(
err = db.
Select(strings.Join(fields, ", ")).
Table(statementsTable).
Where("UNIX_TIMESTAMP(summary_begin_time) >= ? AND UNIX_TIMESTAMP(summary_end_time) <= ?", beginTime, endTime).
Where("summary_begin_time >= FROM_UNIXTIME(?) AND summary_end_time <= FROM_UNIXTIME(?)", beginTime, endTime).
Where("schema_name = ?", schemaName).
Where("digest = ?", digest).
Group("plan_digest").
Expand All @@ -230,7 +230,7 @@ func QueryPlanDetail(
query := db.
Select(strings.Join(fields, ", ")).
Table(statementsTable).
Where("UNIX_TIMESTAMP(summary_begin_time) >= ? AND UNIX_TIMESTAMP(summary_end_time) <= ?", beginTime, endTime).
Where("summary_begin_time >= FROM_UNIXTIME(?) AND summary_end_time <= FROM_UNIXTIME(?)", beginTime, endTime).
Where("schema_name = ?", schemaName).
Where("digest = ?", digest)
if len(plans) > 0 {
Expand Down

0 comments on commit 4b57ab6

Please sign in to comment.