PHOENIX-2702 Show estimate rows and bytes touched in explain plan.
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/8a1aa2e5 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/8a1aa2e5 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/8a1aa2e5 Branch: refs/heads/4.x-HBase-0.98 Commit: 8a1aa2e522ceacd39430222075941fe79c888c7a Parents: b6c8b8e Author: Lars Hofhansl <[email protected]> Authored: Sun Feb 21 22:32:09 2016 -0800 Committer: Lars Hofhansl <[email protected]> Committed: Sun Feb 21 22:33:07 2016 -0800 ---------------------------------------------------------------------- .../apache/phoenix/iterate/BaseResultIterators.java | 14 +++++++++++++- .../java/org/apache/phoenix/iterate/ExplainTable.java | 2 +- .../phoenix/schema/stats/GuidePostsInfoBuilder.java | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/8a1aa2e5/phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterators.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterators.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterators.java index 01b790a..fc3edbe 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterators.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterators.java @@ -120,6 +120,8 @@ public abstract class BaseResultIterators extends ExplainTable implements Result private final ParallelScanGrouper scanGrouper; // TODO: too much nesting here - breakup into new classes. private final List<List<List<Pair<Scan,Future<PeekingResultIterator>>>>> allFutures; + private long estimatedRows; + private long estimatedSize; static final Function<HRegionLocation, KeyRange> TO_KEY_RANGE = new Function<HRegionLocation, KeyRange>() { @Override @@ -558,6 +560,8 @@ public abstract class BaseResultIterators extends ExplainTable implements Result while (guideIndex < gpsSize && (currentGuidePost.compareTo(endKey) <= 0 || endKey.length == 0)) { Scan newScan = scanRanges.intersectScan(scan, currentKeyBytes, currentGuidePostBytes, keyOffset, false); + estimatedRows += gps.getRowCounts().get(guideIndex); + estimatedSize += gps.getByteCounts().get(guideIndex); scans = addNewScan(parallelScans, scans, newScan, currentGuidePostBytes, false, regionLocation); currentKeyBytes = currentGuidePost.copyBytes(); currentGuidePost = PrefixByteCodec.decode(decoder, input); @@ -851,7 +855,15 @@ public abstract class BaseResultIterators extends ExplainTable implements Result QueryServices.EXPLAIN_CHUNK_COUNT_ATTRIB, QueryServicesOptions.DEFAULT_EXPLAIN_CHUNK_COUNT); StringBuilder buf = new StringBuilder(); - buf.append("CLIENT " + (displayChunkCount ? (this.splits.size() + "-CHUNK ") : "") + getName() + " " + size() + "-WAY "); + buf.append("CLIENT "); + if (displayChunkCount) { + buf.append(this.splits.size()).append("-CHUNK "); + if (estimatedRows > 0) { + buf.append(estimatedRows).append(" ROWS "); + buf.append(estimatedSize).append(" BYTES "); + } + } + buf.append(getName()).append(" ").append(size()).append("-WAY "); explain(buf.toString(),planSteps); } http://git-wip-us.apache.org/repos/asf/phoenix/blob/8a1aa2e5/phoenix-core/src/main/java/org/apache/phoenix/iterate/ExplainTable.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/iterate/ExplainTable.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/ExplainTable.java index df7b4c3..74797e7 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/iterate/ExplainTable.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/ExplainTable.java @@ -116,7 +116,7 @@ public abstract class ExplainTable { } else { explainSkipScan(buf); } - buf.append("OVER " + tableRef.getTable().getPhysicalName().getString()); + buf.append("OVER ").append(tableRef.getTable().getPhysicalName().getString()); if (!scanRanges.isPointLookup()) { appendKeyRanges(buf); } http://git-wip-us.apache.org/repos/asf/phoenix/blob/8a1aa2e5/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/GuidePostsInfoBuilder.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/GuidePostsInfoBuilder.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/GuidePostsInfoBuilder.java index c85b1d6..2133349 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/GuidePostsInfoBuilder.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/GuidePostsInfoBuilder.java @@ -104,7 +104,7 @@ public class GuidePostsInfoBuilder { } public boolean addGuidePosts(byte[] row, long byteCount, long rowCount) { - return addGuidePosts(new ImmutableBytesWritable(row), byteCount, 0); + return addGuidePosts(new ImmutableBytesWritable(row), byteCount, rowCount); } private void close() {
