Merge lp:~mmcm/akiban-server/sql-empty-index-range into lp:~akiban-technologies/akiban-server/trunk

Proposed by Mike McMahon
Status: Merged
Approved by: Nathan Williams
Approved revision: 2718
Merged at revision: 2719
Proposed branch: lp:~mmcm/akiban-server/sql-empty-index-range
Merge into: lp:~akiban-technologies/akiban-server/trunk
Diff against target: 59 lines (+15/-0)
5 files modified
src/main/java/com/akiban/sql/optimizer/rule/OperatorAssembler.java (+5/-0)
src/main/java/com/akiban/sql/optimizer/rule/cost/PlanCostEstimator.java (+3/-0)
src/test/resources/com/akiban/sql/optimizer/rule/operator/README.txt (+2/-0)
src/test/resources/com/akiban/sql/optimizer/rule/operator/select-7.expected (+4/-0)
src/test/resources/com/akiban/sql/optimizer/rule/operator/select-7.sql (+1/-0)
To merge this branch: bzr merge lp:~mmcm/akiban-server/sql-empty-index-range
Reviewer Review Type Date Requested Status
Nathan Williams Approve
Review via email: mp+177219@code.launchpad.net

Description of the change

Properly cost estimate and assemble an empty index scan UNION.

Index range processing merges constant conditions from a disjunction, assemblying the corresponding union of ranges. If each arm of the disjunction is impossible, that is, a contradictory conjunction, then the union is empty. Such contradictions are not always caught earlier. If so, estimate that index scan very cheaply, since it will not do any I/O and assemble it as an empty row set.

To post a comment you must log in.
Revision history for this message
Nathan Williams (nwilliams) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/main/java/com/akiban/sql/optimizer/rule/OperatorAssembler.java'
2--- src/main/java/com/akiban/sql/optimizer/rule/OperatorAssembler.java 2013-07-25 19:48:04 +0000
3+++ src/main/java/com/akiban/sql/optimizer/rule/OperatorAssembler.java 2013-07-26 21:09:25 +0000
4@@ -1248,6 +1248,11 @@
5 stream.rowType = stream.operator.rowType();
6 }
7 }
8+ if (stream.operator == null) {
9+ stream.operator = API.valuesScan_Default(Collections.<BindableRow>emptyList(),
10+ indexRowType);
11+ stream.rowType = indexRowType;
12+ }
13 }
14 stream.fieldOffsets = new IndexFieldOffsets(indexScan, indexRowType);
15 if (explainContext != null)
16
17=== modified file 'src/main/java/com/akiban/sql/optimizer/rule/cost/PlanCostEstimator.java'
18--- src/main/java/com/akiban/sql/optimizer/rule/cost/PlanCostEstimator.java 2013-05-24 21:45:54 +0000
19+++ src/main/java/com/akiban/sql/optimizer/rule/cost/PlanCostEstimator.java 2013-07-26 21:09:25 +0000
20@@ -400,6 +400,9 @@
21 else
22 cost = cost.union(acost);
23 }
24+ if (cost == null) {
25+ cost = new CostEstimate(0, 0); // No segments means no real scan.
26+ }
27 result = cost;
28 }
29 }
30
31=== modified file 'src/test/resources/com/akiban/sql/optimizer/rule/operator/README.txt'
32--- src/test/resources/com/akiban/sql/optimizer/rule/operator/README.txt 2013-06-05 22:32:10 +0000
33+++ src/test/resources/com/akiban/sql/optimizer/rule/operator/README.txt 2013-07-26 21:09:25 +0000
34@@ -28,6 +28,8 @@
35
36 select-6: index intersection with different column counts
37
38+select-7: index scan with empty range (contradictory conditions)
39+
40 update-1: set to literal
41
42 geospatial-1: compute max radius for N neighbors
43
44=== added file 'src/test/resources/com/akiban/sql/optimizer/rule/operator/select-7.expected'
45--- src/test/resources/com/akiban/sql/optimizer/rule/operator/select-7.expected 1970-01-01 00:00:00 +0000
46+++ src/test/resources/com/akiban/sql/optimizer/rule/operator/select-7.expected 2013-07-26 21:09:25 +0000
47@@ -0,0 +1,4 @@
48+PhysicalSelect@65d036ae[name]
49+ Project_Default(Field(1))
50+ GroupLookup_Default(Index(test.customers.PRIMARY) -> test.customers)
51+ ValuesScan_Default()
52\ No newline at end of file
53
54=== added file 'src/test/resources/com/akiban/sql/optimizer/rule/operator/select-7.sql'
55--- src/test/resources/com/akiban/sql/optimizer/rule/operator/select-7.sql 1970-01-01 00:00:00 +0000
56+++ src/test/resources/com/akiban/sql/optimizer/rule/operator/select-7.sql 2013-07-26 21:09:25 +0000
57@@ -0,0 +1,1 @@
58+SELECT name FROM customers WHERE (cid = 1 AND cid = 2) OR (cid = 3 AND cid = 4)
59\ No newline at end of file

Subscribers

People subscribed via source and target branches