Skip to content

Commit 01b4e4a

Browse files
committed
fix real read ratio
1 parent 6773990 commit 01b4e4a

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

pkg/estimator/profile.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,6 @@ func (p *Profiler) ReadPhysicalBlocks(ctx context.Context) error {
276276
return errors.Wrap(err, "failed to run")
277277
}
278278

279-
// if err := cmd.Wait(); err != nil {
280-
// return errors.Wrap(err, "failed to wait")
281-
// }
282-
283279
<-p.exitChan
284280

285281
log.Dbg("End read physical")
@@ -497,12 +493,12 @@ func (p *Profiler) EstimateTime(ctx context.Context) (string, error) {
497493
return "", errors.Wrap(err, "failed to collect database stat after sql running")
498494
}
499495

500-
deltaBlocks := afterReads - p.startReadBlocks
501-
realReadsRatio := float64(p.readBytes / defaultBlockSize / deltaBlocks)
496+
deltaBlocks := float64(afterReads - p.startReadBlocks)
497+
realReadsRatio := float64(p.readBytes) / float64(defaultBlockSize) / deltaBlocks
502498

503499
est.SetRealReadRatio(realReadsRatio)
504500

505-
log.Dbg(fmt.Sprintf("Start: %d, after: %d, delta: %d", p.startReadBlocks, afterReads, deltaBlocks))
501+
log.Dbg(fmt.Sprintf("Start: %d, after: %d, delta: %f.6", p.startReadBlocks, afterReads, deltaBlocks))
506502
log.Dbg(fmt.Sprintf("Real read ratio: %v", realReadsRatio))
507503
}
508504

0 commit comments

Comments
 (0)