summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2009-06-12 23:48:38 +0000
committerBrian S. O'Neill <bronee@gmail.com>2009-06-12 23:48:38 +0000
commit16076fc8e7f4922e924eee0f1c14bc8b86a89bb9 (patch)
tree94b0460b1fa1bbec57769894e41b1276041a1e71
parent1cb409d648a50dbb41de319d6ff7bf1eccff1d5a (diff)
Add extra check before applying join sort optimization.
-rw-r--r--src/main/java/com/amazon/carbonado/qe/JoinedQueryExecutor.java12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/main/java/com/amazon/carbonado/qe/JoinedQueryExecutor.java b/src/main/java/com/amazon/carbonado/qe/JoinedQueryExecutor.java
index 5c11157..fa1d38e 100644
--- a/src/main/java/com/amazon/carbonado/qe/JoinedQueryExecutor.java
+++ b/src/main/java/com/amazon/carbonado/qe/JoinedQueryExecutor.java
@@ -530,10 +530,16 @@ public class JoinedQueryExecutor<S extends Storable, T extends Storable>
mInnerLoopFilterValues = innerLoopExecutorFilter.initialFilterValues();
- // Only perform requested ordering if it index provides it for free.
+ // Only perform requested ordering if inner loop index provides it for
+ // free. This optimization is only valid if outer loop matches at most
+ // one record.
if (targetOrdering != null) {
- targetOrdering =
- expectedOrdering(targetAccess, innerLoopExecutorFilter, targetOrdering);
+ if (outerLoopExecutor instanceof KeyQueryExecutor) {
+ targetOrdering =
+ expectedOrdering(targetAccess, innerLoopExecutorFilter, targetOrdering);
+ } else {
+ targetOrdering = null;
+ }
}
mInnerLoopExecutor = innerLoopExecutorFactory