[4/9] phoenix git commit: PHOENIX-4437 Make QueryPlan.getEstimatedBytesToScan() independent of getExplainPlan() and pull optimize() out of getExplainPlan()
PHOENIX-4437 Make QueryPlan.getEstimatedBytesToScan() independent of getExplainPlan() and pull optimize() out of getExplainPlan() Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/7ef96fe1 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/7ef96fe1 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/7ef96fe1 Branch: refs/heads/4.x-HBase-0.98 Commit: 7ef96fe1bed43f3ac3dae900a3e6a83791faf697 Parents: 977699a Author: maryannxueAuthored: Thu Dec 21 10:31:04 2017 -0800 Committer: maryannxue Committed: Tue Mar 13 20:08:24 2018 -0700 -- .../end2end/ExplainPlanWithStatsEnabledIT.java | 4 +- .../apache/phoenix/execute/BaseQueryPlan.java | 45 ++ .../apache/phoenix/execute/HashJoinPlan.java| 59 +- .../phoenix/execute/SortMergeJoinPlan.java | 63 ++-- .../org/apache/phoenix/execute/UnionPlan.java | 53 .../apache/phoenix/jdbc/PhoenixStatement.java | 9 ++- 6 files changed, 120 insertions(+), 113 deletions(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/7ef96fe1/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java -- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java index 76ed7ba..a835e84 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java @@ -303,8 +303,8 @@ public class ExplainPlanWithStatsEnabledIT extends ParallelStatsEnabledIT { try (Connection conn = DriverManager.getConnection(getUrl())) { conn.setAutoCommit(false); Estimate info = getByteRowEstimates(conn, sql, binds); -assertEquals((Long) 200L, info.estimatedBytes); -assertEquals((Long) 2L, info.estimatedRows); +assertEquals((Long) 176l, info.estimatedBytes); +assertEquals((Long) 2l, info.estimatedRows); assertTrue(info.estimateInfoTs > 0); } } http://git-wip-us.apache.org/repos/asf/phoenix/blob/7ef96fe1/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java -- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java b/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java index 38ed926..c4edf31 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java @@ -118,7 +118,7 @@ public abstract class BaseQueryPlan implements QueryPlan { protected Long estimatedRows; protected Long estimatedSize; protected Long estimateInfoTimestamp; -private boolean explainPlanCalled; +private boolean getEstimatesCalled; protected BaseQueryPlan( @@ -500,32 +500,17 @@ public abstract class BaseQueryPlan implements QueryPlan { @Override public ExplainPlan getExplainPlan() throws SQLException { -explainPlanCalled = true; if (context.getScanRanges() == ScanRanges.NOTHING) { return new ExplainPlan(Collections.singletonList("DEGENERATE SCAN OVER " + getTableRef().getTable().getName().getString())); } -// If cost-based optimizer is enabled, we need to initialize a dummy iterator to -// get the stats for computing costs. -boolean costBased = - context.getConnection().getQueryServices().getConfiguration().getBoolean( -QueryServices.COST_BASED_OPTIMIZER_ENABLED, QueryServicesOptions.DEFAULT_COST_BASED_OPTIMIZER_ENABLED); -if (costBased) { -ResultIterator iterator = iterator(); -iterator.close(); -} -// Optimize here when getting explain plan, as queries don't get optimized until after compilation -QueryPlan plan = context.getConnection().getQueryServices().getOptimizer().optimize(context.getStatement(), this); -ExplainPlan exp = plan instanceof BaseQueryPlan ? new ExplainPlan(getPlanSteps(plan.iterator())) : plan.getExplainPlan(); -if (!costBased) { // do not override estimates if they are used for cost calculation. -this.estimatedRows = plan.getEstimatedRowsToScan(); -this.estimatedSize = plan.getEstimatedBytesToScan(); -this.estimateInfoTimestamp = plan.getEstimateInfoTimestamp(); -} -return exp; +ResultIterator
[2/9] phoenix git commit: PHOENIX-4437 Make QueryPlan.getEstimatedBytesToScan() independent of getExplainPlan() and pull optimize() out of getExplainPlan()
PHOENIX-4437 Make QueryPlan.getEstimatedBytesToScan() independent of getExplainPlan() and pull optimize() out of getExplainPlan() Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/56cdcb90 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/56cdcb90 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/56cdcb90 Branch: refs/heads/4.x-HBase-1.1 Commit: 56cdcb9043a8e10933428b2145b0d57b58d3e284 Parents: 33ca96e Author: maryannxueAuthored: Thu Dec 21 10:31:04 2017 -0800 Committer: maryannxue Committed: Tue Mar 13 16:47:25 2018 -0700 -- .../end2end/ExplainPlanWithStatsEnabledIT.java | 4 +- .../apache/phoenix/execute/BaseQueryPlan.java | 45 ++ .../apache/phoenix/execute/HashJoinPlan.java| 59 +- .../phoenix/execute/SortMergeJoinPlan.java | 63 ++-- .../org/apache/phoenix/execute/UnionPlan.java | 53 .../apache/phoenix/jdbc/PhoenixStatement.java | 9 ++- 6 files changed, 120 insertions(+), 113 deletions(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/56cdcb90/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java -- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java index 969bbfb..39bdb67 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java @@ -303,8 +303,8 @@ public class ExplainPlanWithStatsEnabledIT extends ParallelStatsEnabledIT { try (Connection conn = DriverManager.getConnection(getUrl())) { conn.setAutoCommit(false); Estimate info = getByteRowEstimates(conn, sql, binds); -assertEquals((Long) 200L, info.estimatedBytes); -assertEquals((Long) 2L, info.estimatedRows); +assertEquals((Long) 176l, info.estimatedBytes); +assertEquals((Long) 2l, info.estimatedRows); assertTrue(info.estimateInfoTs > 0); } } http://git-wip-us.apache.org/repos/asf/phoenix/blob/56cdcb90/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java -- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java b/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java index 968b259..b152030 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java @@ -118,7 +118,7 @@ public abstract class BaseQueryPlan implements QueryPlan { protected Long estimatedRows; protected Long estimatedSize; protected Long estimateInfoTimestamp; -private boolean explainPlanCalled; +private boolean getEstimatesCalled; protected BaseQueryPlan( @@ -506,32 +506,17 @@ public abstract class BaseQueryPlan implements QueryPlan { @Override public ExplainPlan getExplainPlan() throws SQLException { -explainPlanCalled = true; if (context.getScanRanges() == ScanRanges.NOTHING) { return new ExplainPlan(Collections.singletonList("DEGENERATE SCAN OVER " + getTableRef().getTable().getName().getString())); } -// If cost-based optimizer is enabled, we need to initialize a dummy iterator to -// get the stats for computing costs. -boolean costBased = - context.getConnection().getQueryServices().getConfiguration().getBoolean( -QueryServices.COST_BASED_OPTIMIZER_ENABLED, QueryServicesOptions.DEFAULT_COST_BASED_OPTIMIZER_ENABLED); -if (costBased) { -ResultIterator iterator = iterator(); -iterator.close(); -} -// Optimize here when getting explain plan, as queries don't get optimized until after compilation -QueryPlan plan = context.getConnection().getQueryServices().getOptimizer().optimize(context.getStatement(), this); -ExplainPlan exp = plan instanceof BaseQueryPlan ? new ExplainPlan(getPlanSteps(plan.iterator())) : plan.getExplainPlan(); -if (!costBased) { // do not override estimates if they are used for cost calculation. -this.estimatedRows = plan.getEstimatedRowsToScan(); -this.estimatedSize = plan.getEstimatedBytesToScan(); -this.estimateInfoTimestamp = plan.getEstimateInfoTimestamp(); -} -return exp; +ResultIterator
phoenix git commit: PHOENIX-4437 Make QueryPlan.getEstimatedBytesToScan() independent of getExplainPlan() and pull optimize() out of getExplainPlan()
Repository: phoenix Updated Branches: refs/heads/5.x-HBase-2.0 b2da76c6d -> f0b31ce19 PHOENIX-4437 Make QueryPlan.getEstimatedBytesToScan() independent of getExplainPlan() and pull optimize() out of getExplainPlan() Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/f0b31ce1 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/f0b31ce1 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/f0b31ce1 Branch: refs/heads/5.x-HBase-2.0 Commit: f0b31ce19c7704756fa3ab314c0b35a72c323349 Parents: b2da76c Author: maryannxueAuthored: Thu Dec 21 10:31:04 2017 -0800 Committer: maryannxue Committed: Mon Feb 19 22:38:54 2018 -0800 -- .../end2end/ExplainPlanWithStatsEnabledIT.java | 2 +- .../apache/phoenix/execute/BaseQueryPlan.java | 45 ++ .../apache/phoenix/execute/HashJoinPlan.java| 59 +- .../phoenix/execute/SortMergeJoinPlan.java | 63 ++-- .../org/apache/phoenix/execute/UnionPlan.java | 53 .../apache/phoenix/jdbc/PhoenixStatement.java | 9 ++- 6 files changed, 119 insertions(+), 112 deletions(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/f0b31ce1/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java -- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java index c227b48..fc544cb 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java @@ -304,7 +304,7 @@ public class ExplainPlanWithStatsEnabledIT extends ParallelStatsEnabledIT { try (Connection conn = DriverManager.getConnection(getUrl())) { conn.setAutoCommit(false); Estimate info = getByteRowEstimates(conn, sql, binds); -assertEquals((Long) 200l, info.estimatedBytes); +assertEquals((Long) 176l, info.estimatedBytes); assertEquals((Long) 2l, info.estimatedRows); assertTrue(info.estimateInfoTs > 0); } http://git-wip-us.apache.org/repos/asf/phoenix/blob/f0b31ce1/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java -- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java b/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java index 5f0a094..a7a5552 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java @@ -118,7 +118,7 @@ public abstract class BaseQueryPlan implements QueryPlan { protected Long estimatedRows; protected Long estimatedSize; protected Long estimateInfoTimestamp; -private boolean explainPlanCalled; +private boolean getEstimatesCalled; protected BaseQueryPlan( @@ -500,32 +500,17 @@ public abstract class BaseQueryPlan implements QueryPlan { @Override public ExplainPlan getExplainPlan() throws SQLException { -explainPlanCalled = true; if (context.getScanRanges() == ScanRanges.NOTHING) { return new ExplainPlan(Collections.singletonList("DEGENERATE SCAN OVER " + getTableRef().getTable().getName().getString())); } -// If cost-based optimizer is enabled, we need to initialize a dummy iterator to -// get the stats for computing costs. -boolean costBased = - context.getConnection().getQueryServices().getConfiguration().getBoolean( -QueryServices.COST_BASED_OPTIMIZER_ENABLED, QueryServicesOptions.DEFAULT_COST_BASED_OPTIMIZER_ENABLED); -if (costBased) { -ResultIterator iterator = iterator(); -iterator.close(); -} -// Optimize here when getting explain plan, as queries don't get optimized until after compilation -QueryPlan plan = context.getConnection().getQueryServices().getOptimizer().optimize(context.getStatement(), this); -ExplainPlan exp = plan instanceof BaseQueryPlan ? new ExplainPlan(getPlanSteps(plan.iterator())) : plan.getExplainPlan(); -if (!costBased) { // do not override estimates if they are used for cost calculation. -this.estimatedRows = plan.getEstimatedRowsToScan(); -this.estimatedSize = plan.getEstimatedBytesToScan(); -this.estimateInfoTimestamp = plan.getEstimateInfoTimestamp(); -} -return exp;
[01/35] phoenix git commit: PHOENIX-4437 Make QueryPlan.getEstimatedBytesToScan() independent of getExplainPlan() and pull optimize() out of getExplainPlan()
Repository: phoenix Updated Branches: refs/heads/4.x-cdh5.11.2 519cca954 -> 9994059a0 PHOENIX-4437 Make QueryPlan.getEstimatedBytesToScan() independent of getExplainPlan() and pull optimize() out of getExplainPlan() Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/1229b1eb Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/1229b1eb Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/1229b1eb Branch: refs/heads/4.x-cdh5.11.2 Commit: 1229b1eb5a74a00d6edc8191bcb075156e8fd4ce Parents: 4412856 Author: maryannxueAuthored: Thu Dec 21 18:31:04 2017 + Committer: Pedro Boado Committed: Wed Jan 31 22:24:48 2018 + -- .../end2end/ExplainPlanWithStatsEnabledIT.java | 2 +- .../apache/phoenix/execute/BaseQueryPlan.java | 45 ++ .../apache/phoenix/execute/HashJoinPlan.java| 59 +- .../phoenix/execute/SortMergeJoinPlan.java | 63 ++-- .../org/apache/phoenix/execute/UnionPlan.java | 53 .../apache/phoenix/jdbc/PhoenixStatement.java | 9 ++- 6 files changed, 119 insertions(+), 112 deletions(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/1229b1eb/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java -- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java index 49efa97..f13510b 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java @@ -298,7 +298,7 @@ public class ExplainPlanWithStatsEnabledIT extends ParallelStatsEnabledIT { try (Connection conn = DriverManager.getConnection(getUrl())) { conn.setAutoCommit(false); Estimate info = getByteRowEstimates(conn, sql, binds); -assertEquals((Long) 200l, info.estimatedBytes); +assertEquals((Long) 176l, info.estimatedBytes); assertEquals((Long) 2l, info.estimatedRows); assertTrue(info.estimateInfoTs > 0); } http://git-wip-us.apache.org/repos/asf/phoenix/blob/1229b1eb/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java -- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java b/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java index 31f67b7..380037f 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java @@ -117,7 +117,7 @@ public abstract class BaseQueryPlan implements QueryPlan { protected Long estimatedRows; protected Long estimatedSize; protected Long estimateInfoTimestamp; -private boolean explainPlanCalled; +private boolean getEstimatesCalled; protected BaseQueryPlan( @@ -498,32 +498,17 @@ public abstract class BaseQueryPlan implements QueryPlan { @Override public ExplainPlan getExplainPlan() throws SQLException { -explainPlanCalled = true; if (context.getScanRanges() == ScanRanges.NOTHING) { return new ExplainPlan(Collections.singletonList("DEGENERATE SCAN OVER " + getTableRef().getTable().getName().getString())); } -// If cost-based optimizer is enabled, we need to initialize a dummy iterator to -// get the stats for computing costs. -boolean costBased = - context.getConnection().getQueryServices().getConfiguration().getBoolean( -QueryServices.COST_BASED_OPTIMIZER_ENABLED, QueryServicesOptions.DEFAULT_COST_BASED_OPTIMIZER_ENABLED); -if (costBased) { -ResultIterator iterator = iterator(); -iterator.close(); -} -// Optimize here when getting explain plan, as queries don't get optimized until after compilation -QueryPlan plan = context.getConnection().getQueryServices().getOptimizer().optimize(context.getStatement(), this); -ExplainPlan exp = plan instanceof BaseQueryPlan ? new ExplainPlan(getPlanSteps(plan.iterator())) : plan.getExplainPlan(); -if (!costBased) { // do not override estimates if they are used for cost calculation. -this.estimatedRows = plan.getEstimatedRowsToScan(); -this.estimatedSize = plan.getEstimatedBytesToScan(); -this.estimateInfoTimestamp = plan.getEstimateInfoTimestamp(); -} -return exp; +
[1/2] phoenix git commit: PHOENIX-4437 Make QueryPlan.getEstimatedBytesToScan() independent of getExplainPlan() and pull optimize() out of getExplainPlan()
Repository: phoenix Updated Branches: refs/heads/4.x-HBase-1.2 878a264e5 -> afe21dc72 PHOENIX-4437 Make QueryPlan.getEstimatedBytesToScan() independent of getExplainPlan() and pull optimize() out of getExplainPlan() Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/eb9de14b Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/eb9de14b Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/eb9de14b Branch: refs/heads/4.x-HBase-1.2 Commit: eb9de14b6b70a465c162b9928c4ae466deea3ee2 Parents: 878a264 Author: maryannxueAuthored: Thu Dec 21 18:31:04 2017 + Committer: Pedro Boado Committed: Wed Jan 31 20:55:59 2018 + -- .../end2end/ExplainPlanWithStatsEnabledIT.java | 2 +- .../apache/phoenix/execute/BaseQueryPlan.java | 45 ++ .../apache/phoenix/execute/HashJoinPlan.java| 59 +- .../phoenix/execute/SortMergeJoinPlan.java | 63 ++-- .../org/apache/phoenix/execute/UnionPlan.java | 53 .../apache/phoenix/jdbc/PhoenixStatement.java | 9 ++- 6 files changed, 119 insertions(+), 112 deletions(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/eb9de14b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java -- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java index 49efa97..f13510b 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java @@ -298,7 +298,7 @@ public class ExplainPlanWithStatsEnabledIT extends ParallelStatsEnabledIT { try (Connection conn = DriverManager.getConnection(getUrl())) { conn.setAutoCommit(false); Estimate info = getByteRowEstimates(conn, sql, binds); -assertEquals((Long) 200l, info.estimatedBytes); +assertEquals((Long) 176l, info.estimatedBytes); assertEquals((Long) 2l, info.estimatedRows); assertTrue(info.estimateInfoTs > 0); } http://git-wip-us.apache.org/repos/asf/phoenix/blob/eb9de14b/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java -- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java b/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java index 31f67b7..380037f 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java @@ -117,7 +117,7 @@ public abstract class BaseQueryPlan implements QueryPlan { protected Long estimatedRows; protected Long estimatedSize; protected Long estimateInfoTimestamp; -private boolean explainPlanCalled; +private boolean getEstimatesCalled; protected BaseQueryPlan( @@ -498,32 +498,17 @@ public abstract class BaseQueryPlan implements QueryPlan { @Override public ExplainPlan getExplainPlan() throws SQLException { -explainPlanCalled = true; if (context.getScanRanges() == ScanRanges.NOTHING) { return new ExplainPlan(Collections.singletonList("DEGENERATE SCAN OVER " + getTableRef().getTable().getName().getString())); } -// If cost-based optimizer is enabled, we need to initialize a dummy iterator to -// get the stats for computing costs. -boolean costBased = - context.getConnection().getQueryServices().getConfiguration().getBoolean( -QueryServices.COST_BASED_OPTIMIZER_ENABLED, QueryServicesOptions.DEFAULT_COST_BASED_OPTIMIZER_ENABLED); -if (costBased) { -ResultIterator iterator = iterator(); -iterator.close(); -} -// Optimize here when getting explain plan, as queries don't get optimized until after compilation -QueryPlan plan = context.getConnection().getQueryServices().getOptimizer().optimize(context.getStatement(), this); -ExplainPlan exp = plan instanceof BaseQueryPlan ? new ExplainPlan(getPlanSteps(plan.iterator())) : plan.getExplainPlan(); -if (!costBased) { // do not override estimates if they are used for cost calculation. -this.estimatedRows = plan.getEstimatedRowsToScan(); -this.estimatedSize = plan.getEstimatedBytesToScan(); -this.estimateInfoTimestamp = plan.getEstimateInfoTimestamp(); -} -return exp;
[39/50] [abbrv] phoenix git commit: PHOENIX-4437 Make QueryPlan.getEstimatedBytesToScan() independent of getExplainPlan() and pull optimize() out of getExplainPlan()
PHOENIX-4437 Make QueryPlan.getEstimatedBytesToScan() independent of getExplainPlan() and pull optimize() out of getExplainPlan() Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/412329a7 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/412329a7 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/412329a7 Branch: refs/heads/system-catalog Commit: 412329a7415302831954891285d291055328c28b Parents: 9355a4d Author: maryannxueAuthored: Thu Dec 21 10:31:04 2017 -0800 Committer: maryannxue Committed: Thu Dec 21 10:31:04 2017 -0800 -- .../end2end/ExplainPlanWithStatsEnabledIT.java | 2 +- .../apache/phoenix/execute/BaseQueryPlan.java | 45 ++ .../apache/phoenix/execute/HashJoinPlan.java| 59 +- .../phoenix/execute/SortMergeJoinPlan.java | 63 ++-- .../org/apache/phoenix/execute/UnionPlan.java | 53 .../apache/phoenix/jdbc/PhoenixStatement.java | 9 ++- 6 files changed, 119 insertions(+), 112 deletions(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/412329a7/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java -- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java index 49efa97..f13510b 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java @@ -298,7 +298,7 @@ public class ExplainPlanWithStatsEnabledIT extends ParallelStatsEnabledIT { try (Connection conn = DriverManager.getConnection(getUrl())) { conn.setAutoCommit(false); Estimate info = getByteRowEstimates(conn, sql, binds); -assertEquals((Long) 200l, info.estimatedBytes); +assertEquals((Long) 176l, info.estimatedBytes); assertEquals((Long) 2l, info.estimatedRows); assertTrue(info.estimateInfoTs > 0); } http://git-wip-us.apache.org/repos/asf/phoenix/blob/412329a7/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java -- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java b/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java index 31f67b7..380037f 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java @@ -117,7 +117,7 @@ public abstract class BaseQueryPlan implements QueryPlan { protected Long estimatedRows; protected Long estimatedSize; protected Long estimateInfoTimestamp; -private boolean explainPlanCalled; +private boolean getEstimatesCalled; protected BaseQueryPlan( @@ -498,32 +498,17 @@ public abstract class BaseQueryPlan implements QueryPlan { @Override public ExplainPlan getExplainPlan() throws SQLException { -explainPlanCalled = true; if (context.getScanRanges() == ScanRanges.NOTHING) { return new ExplainPlan(Collections.singletonList("DEGENERATE SCAN OVER " + getTableRef().getTable().getName().getString())); } -// If cost-based optimizer is enabled, we need to initialize a dummy iterator to -// get the stats for computing costs. -boolean costBased = - context.getConnection().getQueryServices().getConfiguration().getBoolean( -QueryServices.COST_BASED_OPTIMIZER_ENABLED, QueryServicesOptions.DEFAULT_COST_BASED_OPTIMIZER_ENABLED); -if (costBased) { -ResultIterator iterator = iterator(); -iterator.close(); -} -// Optimize here when getting explain plan, as queries don't get optimized until after compilation -QueryPlan plan = context.getConnection().getQueryServices().getOptimizer().optimize(context.getStatement(), this); -ExplainPlan exp = plan instanceof BaseQueryPlan ? new ExplainPlan(getPlanSteps(plan.iterator())) : plan.getExplainPlan(); -if (!costBased) { // do not override estimates if they are used for cost calculation. -this.estimatedRows = plan.getEstimatedRowsToScan(); -this.estimatedSize = plan.getEstimatedBytesToScan(); -this.estimateInfoTimestamp = plan.getEstimateInfoTimestamp(); -} -return exp; +ResultIterator iterator = iterator(); +ExplainPlan explainPlan = new
phoenix git commit: PHOENIX-4437 Make QueryPlan.getEstimatedBytesToScan() independent of getExplainPlan() and pull optimize() out of getExplainPlan()
Repository: phoenix Updated Branches: refs/heads/master 9355a4d26 -> 412329a74 PHOENIX-4437 Make QueryPlan.getEstimatedBytesToScan() independent of getExplainPlan() and pull optimize() out of getExplainPlan() Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/412329a7 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/412329a7 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/412329a7 Branch: refs/heads/master Commit: 412329a7415302831954891285d291055328c28b Parents: 9355a4d Author: maryannxueAuthored: Thu Dec 21 10:31:04 2017 -0800 Committer: maryannxue Committed: Thu Dec 21 10:31:04 2017 -0800 -- .../end2end/ExplainPlanWithStatsEnabledIT.java | 2 +- .../apache/phoenix/execute/BaseQueryPlan.java | 45 ++ .../apache/phoenix/execute/HashJoinPlan.java| 59 +- .../phoenix/execute/SortMergeJoinPlan.java | 63 ++-- .../org/apache/phoenix/execute/UnionPlan.java | 53 .../apache/phoenix/jdbc/PhoenixStatement.java | 9 ++- 6 files changed, 119 insertions(+), 112 deletions(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/412329a7/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java -- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java index 49efa97..f13510b 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java @@ -298,7 +298,7 @@ public class ExplainPlanWithStatsEnabledIT extends ParallelStatsEnabledIT { try (Connection conn = DriverManager.getConnection(getUrl())) { conn.setAutoCommit(false); Estimate info = getByteRowEstimates(conn, sql, binds); -assertEquals((Long) 200l, info.estimatedBytes); +assertEquals((Long) 176l, info.estimatedBytes); assertEquals((Long) 2l, info.estimatedRows); assertTrue(info.estimateInfoTs > 0); } http://git-wip-us.apache.org/repos/asf/phoenix/blob/412329a7/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java -- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java b/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java index 31f67b7..380037f 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java @@ -117,7 +117,7 @@ public abstract class BaseQueryPlan implements QueryPlan { protected Long estimatedRows; protected Long estimatedSize; protected Long estimateInfoTimestamp; -private boolean explainPlanCalled; +private boolean getEstimatesCalled; protected BaseQueryPlan( @@ -498,32 +498,17 @@ public abstract class BaseQueryPlan implements QueryPlan { @Override public ExplainPlan getExplainPlan() throws SQLException { -explainPlanCalled = true; if (context.getScanRanges() == ScanRanges.NOTHING) { return new ExplainPlan(Collections.singletonList("DEGENERATE SCAN OVER " + getTableRef().getTable().getName().getString())); } -// If cost-based optimizer is enabled, we need to initialize a dummy iterator to -// get the stats for computing costs. -boolean costBased = - context.getConnection().getQueryServices().getConfiguration().getBoolean( -QueryServices.COST_BASED_OPTIMIZER_ENABLED, QueryServicesOptions.DEFAULT_COST_BASED_OPTIMIZER_ENABLED); -if (costBased) { -ResultIterator iterator = iterator(); -iterator.close(); -} -// Optimize here when getting explain plan, as queries don't get optimized until after compilation -QueryPlan plan = context.getConnection().getQueryServices().getOptimizer().optimize(context.getStatement(), this); -ExplainPlan exp = plan instanceof BaseQueryPlan ? new ExplainPlan(getPlanSteps(plan.iterator())) : plan.getExplainPlan(); -if (!costBased) { // do not override estimates if they are used for cost calculation. -this.estimatedRows = plan.getEstimatedRowsToScan(); -this.estimatedSize = plan.getEstimatedBytesToScan(); -this.estimateInfoTimestamp = plan.getEstimateInfoTimestamp(); -} -return exp; +