@Override public ScanStats getScanStats() { // TODO: ideally here we should use the rowcount from index scan, and multiply a factor of restricted scan double rowCount; PluginCost pluginCostModel = formatPlugin.getPluginCostModel(); final int avgColumnSize = pluginCostModel.getAverageColumnSize(this); int numColumns = (columns == null || columns.isEmpty()) ? STAR_COLS: columns.size(); // Get the restricted group scan row count - same as the right side index rows rowCount = computeRestrictedScanRowcount(); // Get the average row size of the primary table double avgRowSize = stats.getAvgRowSize(null, true); if (avgRowSize == Statistics.AVG_ROWSIZE_UNKNOWN || avgRowSize == 0) { avgRowSize = avgColumnSize * numColumns; } // restricted scan does random lookups and each row may belong to a different block, with the number // of blocks upper bounded by the total num blocks in the primary table double totalBlocksPrimary = Math.ceil((avgRowSize * fullTableRowCount)/pluginCostModel.getBlockSize(this)); double numBlocks = Math.min(totalBlocksPrimary, rowCount); double diskCost = numBlocks * pluginCostModel.getRandomBlockReadCost(this); // For non-covering plans, the dominating cost would be of the join back. Reduce it using the factor // for biasing towards non-covering plans. diskCost *= stats.getRowKeyJoinBackIOFactor(); logger.debug("RestrictedJsonGroupScan:{} rowCount:{}, avgRowSize:{}, blocks:{}, totalBlocks:{}, diskCost:{}", System.identityHashCode(this), rowCount, avgRowSize, numBlocks, totalBlocksPrimary, diskCost); return new ScanStats(GroupScanProperty.NO_EXACT_ROW_COUNT, rowCount, 1, diskCost); }
pluginCost.getBlockSize(primaryTableGroupScan)); double diskBlocksPrimary = Math.min(totalBlocksPrimary, leadRowCount); double diskCostPrimary = diskBlocksPrimary * pluginCost.getRandomBlockReadCost(primaryTableGroupScan); double diskCostTotal = diskCostIndex + diskCostPrimary;
@Override public ScanStats getScanStats() { // TODO: ideally here we should use the rowcount from index scan, and multiply a factor of restricted scan double rowCount; PluginCost pluginCostModel = formatPlugin.getPluginCostModel(); final int avgColumnSize = pluginCostModel.getAverageColumnSize(this); int numColumns = (columns == null || columns.isEmpty()) ? STAR_COLS: columns.size(); // Get the restricted group scan row count - same as the right side index rows rowCount = computeRestrictedScanRowcount(); // Get the average row size of the primary table double avgRowSize = stats.getAvgRowSize(null, true); if (avgRowSize == Statistics.AVG_ROWSIZE_UNKNOWN || avgRowSize == 0) { avgRowSize = avgColumnSize * numColumns; } // restricted scan does random lookups and each row may belong to a different block, with the number // of blocks upper bounded by the total num blocks in the primary table double totalBlocksPrimary = Math.ceil((avgRowSize * fullTableRowCount)/pluginCostModel.getBlockSize(this)); double numBlocks = Math.min(totalBlocksPrimary, rowCount); double diskCost = numBlocks * pluginCostModel.getRandomBlockReadCost(this); // For non-covering plans, the dominating cost would be of the join back. Reduce it using the factor // for biasing towards non-covering plans. diskCost *= stats.getRowKeyJoinBackIOFactor(); logger.debug("RestrictedJsonGroupScan:{} rowCount:{}, avgRowSize:{}, blocks:{}, totalBlocks:{}, diskCost:{}", System.identityHashCode(this), rowCount, avgRowSize, numBlocks, totalBlocksPrimary, diskCost); return new ScanStats(GroupScanProperty.NO_EXACT_ROW_COUNT, rowCount, 1, diskCost); }
pluginCost.getBlockSize(primaryTableGroupScan)); double diskBlocksPrimary = Math.min(totalBlocksPrimary, leadRowCount); double diskCostPrimary = diskBlocksPrimary * pluginCost.getRandomBlockReadCost(primaryTableGroupScan); double diskCostTotal = diskCostIndex + diskCostPrimary;
costBase.getAverageColumnSize(dbGroupScan) * totalRows) / costBase.getBlockSize(dbGroupScan)); double diskBlocksPrimary = Math.min(totalBlocksPrimary, totLeadRowCount); double diskCostPrimary = diskBlocksPrimary * costBase.getRandomBlockReadCost(dbGroupScan); totDiskCost += diskCostPrimary;