private double getNumOfBlocks(double rowCount, double sizeFromDisk, double avgRowSize, PluginCost pluginCostModel) { if (rowCount == ROWCOUNT_UNKNOWN || rowCount == 0) { return Math.ceil(sizeFromDisk / pluginCostModel.getBlockSize(this)); } else { return Math.ceil(rowCount * avgRowSize / pluginCostModel.getBlockSize(this)); } }
@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); }
double numBlocks = Math.ceil((leadRowCount * avgRowSize)/pluginCost.getBlockSize(primaryTableGroupScan)); double diskCost = numBlocks * pluginCost.getSequentialBlockReadCost(primaryTableGroupScan); double numBlocksIndex = Math.ceil((leadRowCount * avgRowSize)/pluginCost.getBlockSize(primaryTableGroupScan)); double diskCostIndex = numBlocksIndex * pluginCost.getSequentialBlockReadCost(primaryTableGroupScan); pluginCost.getBlockSize(primaryTableGroupScan)); double diskBlocksPrimary = Math.min(totalBlocksPrimary, leadRowCount); double diskCostPrimary = diskBlocksPrimary * pluginCost.getRandomBlockReadCost(primaryTableGroupScan);
double totalBlocks = Math.ceil((avgRowSize * fullTableRowCount)/pluginCostModel.getBlockSize(this)); double numBlocks = Math.ceil(((avgRowSize * rowsFromDisk)/pluginCostModel.getBlockSize(this))); numBlocks = Math.min(totalBlocks, numBlocks); double diskCost = numBlocks * pluginCostModel.getSequentialBlockReadCost(this);
private double getNumOfBlocks(double rowCount, double sizeFromDisk, double avgRowSize, PluginCost pluginCostModel) { if (rowCount == ROWCOUNT_UNKNOWN || rowCount == 0) { return Math.ceil(sizeFromDisk / pluginCostModel.getBlockSize(this)); } else { return Math.ceil(rowCount * avgRowSize / pluginCostModel.getBlockSize(this)); } }
@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); }
double numBlocks = Math.ceil((leadRowCount * avgRowSize)/pluginCost.getBlockSize(primaryTableGroupScan)); double diskCost = numBlocks * pluginCost.getSequentialBlockReadCost(primaryTableGroupScan); double numBlocksIndex = Math.ceil((leadRowCount * avgRowSize)/pluginCost.getBlockSize(primaryTableGroupScan)); double diskCostIndex = numBlocksIndex * pluginCost.getSequentialBlockReadCost(primaryTableGroupScan); pluginCost.getBlockSize(primaryTableGroupScan)); double diskBlocksPrimary = Math.min(totalBlocksPrimary, leadRowCount); double diskCostPrimary = diskBlocksPrimary * pluginCost.getRandomBlockReadCost(primaryTableGroupScan);
double totalBlocks = Math.ceil((avgRowSize * fullTableRowCount)/pluginCostModel.getBlockSize(this)); double numBlocks = Math.ceil(((avgRowSize * rowsFromDisk)/pluginCostModel.getBlockSize(this))); numBlocks = Math.min(totalBlocks, numBlocks); double diskCost = numBlocks * pluginCostModel.getSequentialBlockReadCost(this);
Preconditions.checkArgument(primaryTableGroupScan instanceof DbGroupScan); double numBlocksIndex = Math.ceil((leadRowCount * avgRowSize) / costBase.getBlockSize(primaryTableGroupScan)); double diskCostIndex = numBlocksIndex * costBase.getSequentialBlockReadCost(primaryTableGroupScan); totDiskCost += diskCostIndex; costBase.getAverageColumnSize(dbGroupScan) * totalRows) / costBase.getBlockSize(dbGroupScan)); double diskBlocksPrimary = Math.min(totalBlocksPrimary, totLeadRowCount); double diskCostPrimary = diskBlocksPrimary * costBase.getRandomBlockReadCost(dbGroupScan);