You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by km...@apache.org on 2013/10/22 04:37:12 UTC
svn commit: r1534465 -
/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OptimizerImpl.java
Author: kmarsden
Date: Tue Oct 22 02:37:12 2013
New Revision: 1534465
URL: http://svn.apache.org/r1534465
Log:
DERBY-2130 - Optimizer performance slowdown from 10.1 to 10.2
Patch contributed by Army Brown
Modified:
db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OptimizerImpl.java
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OptimizerImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OptimizerImpl.java?rev=1534465&r1=1534464&r2=1534465&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OptimizerImpl.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OptimizerImpl.java Tue Oct 22 02:37:12 2013
@@ -223,13 +223,8 @@ class OptimizerImpl implements Optimizer
this.numTablesInQuery = numTablesInQuery;
numOptimizables = optimizableList.size();
proposedJoinOrder = new int[numOptimizables];
- if (numTablesInQuery > 6)
- {
- permuteState = READY_TO_JUMP;
- firstLookOrder = new int[numOptimizables];
- }
- else
- permuteState = NO_JUMP;
+ if (initJumpState() == READY_TO_JUMP)
+ firstLookOrder = new int[numOptimizables];
/* Mark all join positions as unused */
for (int i = 0; i < numOptimizables; i++)
@@ -385,7 +380,27 @@ class OptimizerImpl implements Optimizer
* phase in certain situations. DERBY-1866.
*/
desiredJoinOrderFound = false;
- }
+
+ /*
+ * If we JUMPed permutations last round, it's possible that we timed out
+ * before finishing all of the jump processing (most likely we ended in
+ * the middle of a WALK_LOW). So reset the jump state here to make sure
+ * we get a clean start. Failure to do so can lead to execution of
+ * code-paths that are not expected and thus incorrect cost estimates
+ * (most notably, an uninitialized bestCost, which we should never see).
+ * DERBY-1905.
+ */
+ initJumpState();
+ }
+
+ /**
+ * Determine if we want to try "jumping" permutations with this
+ * OptimizerImpl, and (re-)initialize the permuteState field accordingly.
+ */
+ private int initJumpState() {
+ permuteState = (numTablesInQuery >= 6 ? READY_TO_JUMP : NO_JUMP);
+ return permuteState;
+ }
private boolean tracingIsOn() { return lcc.optimizerTracingIsOn(); }