summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/com/amazon/carbonado/qe/UnionQueryAnalyzer.java10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/main/java/com/amazon/carbonado/qe/UnionQueryAnalyzer.java b/src/main/java/com/amazon/carbonado/qe/UnionQueryAnalyzer.java
index 2f467eb..9ed94fd 100644
--- a/src/main/java/com/amazon/carbonado/qe/UnionQueryAnalyzer.java
+++ b/src/main/java/com/amazon/carbonado/qe/UnionQueryAnalyzer.java
@@ -111,6 +111,11 @@ public class UnionQueryAnalyzer<S extends Storable> {
// Re-calc with specified direction. Only do one property at a time
// since one simple change might alter the query plan.
subResults = splitIntoSubResults(filter, orderings);
+
+ if (subResults.size() < 1) {
+ // Total ordering no longer required.
+ return new Result(subResults);
+ }
}
// Gather all the keys available. As ordering properties touch key
@@ -178,6 +183,11 @@ public class UnionQueryAnalyzer<S extends Storable> {
orderings.add(OrderedProperty.get(bestProperty, best.getBestDirection()));
subResults = splitIntoSubResults(filter, orderings);
+ if (subResults.size() < 1) {
+ // Total ordering no longer required.
+ break;
+ }
+
// Remove property from super key and key set...
superKey.remove(bestProperty);
if (superKey.size() == 0) {