summaryrefslogtreecommitdiff
path: root/src/main/java/com/amazon/carbonado
diff options
context:
space:
mode:
authorJesse Morgan <jesse@jesterpm.net>2012-05-18 21:10:12 +0000
committerJesse Morgan <jesse@jesterpm.net>2012-05-18 21:10:12 +0000
commit60b4fa0c1cfacc9ad484c08fbbd0de7b69ea27ca (patch)
tree1c134d4570546c0e9264840b5ede1e9b81a21dd3 /src/main/java/com/amazon/carbonado
parent64f320d5259ac229bf1040bab005d1a72b80a194 (diff)
Adjusted optimization of open ended range queries.
Diffstat (limited to 'src/main/java/com/amazon/carbonado')
-rw-r--r--src/main/java/com/amazon/carbonado/qe/FilteringScore.java22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/main/java/com/amazon/carbonado/qe/FilteringScore.java b/src/main/java/com/amazon/carbonado/qe/FilteringScore.java
index 5b76a6d..57c16a1 100644
--- a/src/main/java/com/amazon/carbonado/qe/FilteringScore.java
+++ b/src/main/java/com/amazon/carbonado/qe/FilteringScore.java
@@ -823,10 +823,21 @@ public class FilteringScore<S extends Storable> {
return 1;
}
- // Compare range match. (index can have at most one range match)
- if (first.hasRangeMatch()) {
- if (second.hasRangeMatch()) {
- // Both have range match, favor clustered index.
+ // Compare ranges. Favor ranges that help find the start.
+ boolean firstPartialRange = first.hasRangeStart();
+ boolean secondPartialRange = second.hasRangeStart();
+
+ if (first.shouldReverseRange()) {
+ firstPartialRange = first.hasRangeEnd();
+ }
+
+ if (second.shouldReverseRange()) {
+ secondPartialRange = second.hasRangeEnd();
+ }
+
+ if (firstPartialRange) {
+ if (secondPartialRange) {
+ // Both have ranges, favor clustered index.
if (first.isIndexClustered()) {
if (!second.isIndexClustered()) {
return -1;
@@ -837,7 +848,8 @@ public class FilteringScore<S extends Storable> {
} else {
return -1;
}
- } else if (second.hasRangeMatch()) {
+
+ } else if (secondPartialRange) {
return 1;
}