From 16076fc8e7f4922e924eee0f1c14bc8b86a89bb9 Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Fri, 12 Jun 2009 23:48:38 +0000 Subject: Add extra check before applying join sort optimization. --- .../java/com/amazon/carbonado/qe/JoinedQueryExecutor.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/main/java') 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 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 -- cgit v1.2.3