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 mi...@apache.org on 2014/02/27 00:43:35 UTC
svn commit: r1572351 - in /db/derby/code/branches/10.10: ./
java/engine/org/apache/derby/impl/sql/compile/OptimizerImpl.java
Author: mikem
Date: Wed Feb 26 23:43:35 2014
New Revision: 1572351
URL: http://svn.apache.org/r1572351
Log:
DERBY-2130 - Optimizer performance slowdown from 10.1 to 10.2
backporting change #1534465 from trunk to 10.10
Patch contributed by Army Brown
Modified:
db/derby/code/branches/10.10/ (props changed)
db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/OptimizerImpl.java
Propchange: db/derby/code/branches/10.10/
------------------------------------------------------------------------------
Merged /db/derby/code/trunk:r1534465
Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/OptimizerImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/OptimizerImpl.java?rev=1572351&r1=1572350&r2=1572351&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/OptimizerImpl.java (original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/OptimizerImpl.java Wed Feb 26 23:43:35 2014
@@ -231,13 +231,8 @@ public class OptimizerImpl implements Op
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++)
@@ -371,7 +366,27 @@ public class OptimizerImpl implements Op
* 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;
+ }
public int getMaxMemoryPerTable()
{