db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Satheesh Bandaram <sathe...@Sourcery.Org>
Subject Re: [jira] Updated: (DERBY-649) Useful indexes not used in UNION ALL
Date Fri, 16 Dec 2005 02:08:02 GMT
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
<br>
Daniel John Debrunner wrote:<br>
<blockquote cite="mid43A20BFB.1050905@debrunners.com" type="cite">
  <pre wrap="">&gt;From what I understand, your patch will push predicates like

 a = ?
 a = 3

but will not push expressions like

 a = (1 + b)
 a = cost(c)
 a = rate()
  </pre>
</blockquote>
You are right... I get confused between predicates and search
clauses... Search clauses are guaranteed to have a constant on the
right, you don't have to check for them. But a predicate can have a
non-constant expression on the right. I should add a check for this. <b>Thanks
</b>a lot for catching this. BTW, I see search transitive closure
optimizations checking for ConstantNode, but not ParameterNode. I
wonder if we are missing some possible optimizations where a parameter
marker is used, instead of a ConstantNode. This would could make
PreparedStatements go slower than Statements, when most people would
expect it other way. I will investigate and file a bug.<br>
<br>
I will submit this small patch:<br>
<br>
Index: PredicateList.java<br>
===================================================================<br>
--- PredicateList.java&nbsp;&nbsp;&nbsp; (revision 357055)<br>
+++ PredicateList.java&nbsp;&nbsp;&nbsp; (working copy)<br>
@@ -1422,7 +1422,9 @@<br>
&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; continue;<br>
&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; BinaryRelationalOperatorNode opNode =
(BinaryRelationalOperatorNode) andNode.getLeftOperand();<br>
-&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; if(! (opNode.getLeftOperand() instanceof
ColumnReference))<br>
+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; if (! (opNode.getLeftOperand() instanceof
ColumnReference) ||<br>
+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ! (opNode.getRightOperand()
instanceof
ConstantNode ||<br>
+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;opNode.getRightOperand()
instanceof
ParameterNode))<br>
&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; continue;<br>
&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; ColumnReference crNode = (ColumnReference)
opNode.getLeftOperand();<br>
<br>
<blockquote cite="mid43A20BFB.1050905@debrunners.com" type="cite">
  <pre wrap="">
I don't see where predicates of the first type are distinguished from
those of the second type. I'm sure I'm being dumb and it's staring me in
the face.

In PredicateList.pushExpressionsIntoSelect I do see:

  line 1418 - a comment indicating (to me) that there is logic here to
only push "simple" predicates.
  line 1421 - check to see the predicate is a binary relational node
  line 1425 - check to see the left is a column reference
  line 1431 - see if the column is referenced in where it is being pushed to

but I don't see any code that says the right is "simple" so do push, or
the right is "complex" so don't push.

This is as much for my education on the optimizer as well as trying to
understand the patch completely.

Dan.



  </pre>
</blockquote>
</body>
</html>


Mime
View raw message