Skip to content

Commit

Permalink
This is an automated cherry-pick of pingcap#39395
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
  • Loading branch information
xuyifangreeneyes authored and ti-chi-bot committed Feb 9, 2023
1 parent 52ae590 commit 2d2efe5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion statistics/handle/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ import (
"github.com/pingcap/tidb/util/ranger"
"github.com/pingcap/tidb/util/sqlexec"
"github.com/pingcap/tidb/util/timeutil"
"github.com/tikv/client-go/v2/oracle"
"go.uber.org/atomic"
"go.uber.org/zap"
)
Expand Down Expand Up @@ -963,9 +962,13 @@ func TableAnalyzed(tbl *statistics.Table) bool {
func NeedAnalyzeTable(tbl *statistics.Table, limit time.Duration, autoAnalyzeRatio float64) (bool, string) {
analyzed := TableAnalyzed(tbl)
if !analyzed {
<<<<<<< HEAD
t := time.Unix(0, oracle.ExtractPhysical(tbl.Version)*int64(time.Millisecond))
dur := time.Since(t)
return dur >= limit, fmt.Sprintf("table unanalyzed, time since last updated %v", dur)
=======
return true, "table unanalyzed"
>>>>>>> ddfa6db728 (statistics: remove 1min no write check for unanalyzed table in auto analyze (#39395))
}
// Auto analyze is disabled.
if autoAnalyzeRatio == 0 {
Expand Down
4 changes: 2 additions & 2 deletions statistics/handle/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1532,8 +1532,8 @@ func (s *testStatsSuite) TestNeedAnalyzeTable(c *C) {
tbl: &statistics.Table{Version: oracle.GoTimeToTS(time.Now())},
limit: time.Hour,
ratio: 0,
result: false,
reason: "",
result: true,
reason: "table unanalyzed",
},
// table was already analyzed but auto analyze is disabled
{
Expand Down

0 comments on commit 2d2efe5

Please sign in to comment.