Skip to content

Commit

Permalink
fix cost model in table scan (#977) (#1023)
Browse files Browse the repository at this point in the history
(cherry picked from commit 12d53b3)
  • Loading branch information
marsishandsome authored Aug 15, 2019
1 parent 72136f6 commit 509e500
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ public TiKVScanPlan build() {

// TODO: Fine-grained statistics usage
Builder calculateCostAndEstimateCount(long tableColSize) {
cost = 100.0;
cost *= tableColSize * TABLE_SCAN_COST_FACTOR;
return this;
}
Expand Down Expand Up @@ -277,6 +276,8 @@ TiKVScanPlan buildIndexScan(
TiKVScanPlan.Builder planBuilder = TiKVScanPlan.Builder.newBuilder();
ScanSpec result = extractConditions(conditions, table, index);

// this is calcuated for downgrade if there is no statstics info we can
// retrieve from TiKV.
double cost = SelectivityCalculator.calcPseudoSelectivity(result);
planBuilder.setCost(cost);

Expand Down

0 comments on commit 509e500

Please sign in to comment.