Smells like oracle bug? 2006-07-14 - By Niall Litchfield
I'll agree that you may get no result - though I'm not sure the halting problem is relevant in most cases here, just reasonable timescales to wait for bad plans. I'll agree with the first one only as so far as to say that if you get a result it will be the same as the unhinted plan (anything else is a bug). The third is just wrong
SQL> set autotrace on explain SQL> create index idx1 on dept(deptno); create index idx1 on dept(deptno) * ERROR at line 1: ORA-01408 (See ORA-01408.ora-code.com): such column list already indexed
SQL> create index idx1 on dept(dname);
Index created.
SQL> select /*+ index dept(dname) */ empno,ename 2 from emp;
EMPNO ENAME -- ---- -- -- ---- -- 7369 SMITH 7499 ALLEN 7521 WARD 7566 JONES 7654 MARTIN 7698 BLAKE 7782 CLARK 7788 SCOTT 7839 KING 7844 TURNER 7876 ADAMS
EMPNO ENAME -- ---- -- -- ---- -- 7900 JAMES 7902 FORD 7934 MILLER
14 rows selected.
Execution Plan -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----- Plan hash value: 3956160932
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ | 0 | SELECT STATEMENT | | 14 | 280 | 3 (0)| 00:00:01 | | 1 | TABLE ACCESS FULL| EMP | 14 | 280 | 3 (0)| 00:00:01 | -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
Note -- -- - dynamic sampling used for this statement
SQL> Hints are not designed to allow users to hint access paths that don't satisfy the query correctly. They are designed to say either "set this strategic goal for optimisation (RULE,FIRST_ROWS_N ....) or else "I know that the best access path for this query (or part of it) is the following, please don't bother second guessing me. Can you imagine how unreliable Oracle based systems would be in general if the hints that developers have added to various code around the planet for the last decade weren't checked to make sure they were valid. Come to think of it there are more than enough hints in various versions of the data dictionary for that possibility to be worrying. On 7/13/06, jaromir nemec <jaromir@(protected)> wrote: > > Hi, > > > > You cannot (or at least shouldn't be able to) provide a hint to an > access path that > > > gives wrong results. > > > > Conscious or unconscious abuse of hints in a SQL statement may lead only > to three kind of results: > - you get some result > - you get no result (see halting problem of Alan Tuning:) > - you get an error > Other behavior (i.e. receiving two different results) is in my opinion a > bug. > > > > Regards > > Jaromir > > -- -- Original Message -- -- > *From:* Niall Litchfield <niall.litchfield@(protected)> > *To:* jkstill@(protected) > *Cc:* gints.plivna@(protected) ; oracle-l <oracle-l@(protected)> > *Sent:* Thursday, July 13, 2006 10:31 PM > *Subject:* Re: Smells like oracle bug? > >
-- Niall Litchfield Oracle DBA http://www.orawin.info
I'll agree that you may get no result - though I'm not sure the halting problem is relevant in most cases here, just reasonable timescales to wait for bad plans. I'll agree with the first one only as so far as to say that if you get a result it will be the same as the unhinted plan (anything else is a bug). The third is just wrong <br><br><span style="font-family: courier new,monospace;">SQL> set autotrace on explain</span><br style="font-family: courier new,monospace;"><span style= "font-family: courier new,monospace;">SQL> create index idx1 on dept(deptno); </span><br style="font-family: courier new,monospace;"><span style="font-family : courier new,monospace;">create index idx1 on dept(deptno)</span><br style= "font-family: courier new,monospace;"><span style="font-family: courier new ,monospace;"> *</span ><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">ERROR at line 1:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> ORA-01408 (See ORA-01408.ora-code.com): such column list already indexed</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> SQL> create index idx1 on dept(dname);</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style= "font-family: courier new,monospace;">Index created.</span><br style="font -family: courier new,monospace;"> <br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">SQL> select /*+ index dept(dname) */ empno,ename< /span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> 2 from emp;</span><br style="font-family: courier new,monospace;"> <br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> EMPNO ENAME</span><br style= "font-family: courier new,monospace;"> <span style="font-family: courier new,monospace;">-- ---- -- -- ---- --</span> <br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> 7369 SMITH</span><br style="font-family: courier new,monospace;"> <span style="font-family: courier new,monospace;">   ; 7499 ALLEN</span><br style="font-family: courier new,monospace;"><span style= "font-family: courier new,monospace;"> 7521 WARD< /span><br style="font-family: courier new,monospace;"> <span style="font-family: courier new,monospace;">   ; 7566 JONES</span><br style="font-family: courier new,monospace;"><span style= "font-family: courier new,monospace;"> 7654 MARTIN </span><br style="font-family: courier new,monospace;"> <span style="font-family: courier new,monospace;">   ; 7698 BLAKE</span><br style="font-family: courier new,monospace;"><span style= "font-family: courier new,monospace;"> 7782 CLARK< /span><br style="font-family: courier new,monospace;"> <span style="font-family: courier new,monospace;">   ; 7788 SCOTT</span><br style="font-family: courier new,monospace;"><span style= "font-family: courier new,monospace;"> 7839 KING< /span><br style="font-family: courier new,monospace;"> <span style="font-family: courier new,monospace;">   ; 7844 TURNER</span><br style="font-family: courier new,monospace;"><span style= "font-family: courier new,monospace;"> 7876 ADAMS< /span><br style="font-family: courier new,monospace;"> <br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> EMPNO ENAME</span><br style= "font-family: courier new,monospace;"><span style="font-family: courier new ,monospace;">-- ---- -- -- ---- -- </span><br style="font-family: courier new,monospace;"><span style="font-family : courier new,monospace;"> 7900 JAMES</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> 7902 FORD</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> 7934 MILLER</span><br style="font-family: courier new ,monospace;"><br style="font-family: courier new,monospace;"> <span style="font-family: courier new,monospace;">14 rows selected.</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new ,monospace;"><br style="font-family: courier new,monospace;"><span style="font -family: courier new,monospace;"> Execution Plan</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">-- ---- ---- ---- ---- ---- ---- -- -- ---- ---- ---- -----</span><br style="font-family: courier new,monospace;"> <span style="font-family: courier new,monospace;">Plan hash value: 3956160932< /span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------< /span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | </span><br style="font-family: courier new,monospace;"><span style="font-family : courier new,monospace;">-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ -- ---- ---- ---- --</span><br style="font-family: courier new,monospace;"> <span style="font-family: courier new,monospace;">| 0 | SELECT STATEMENT | | 14 | 280 | 3 (0)| 00:00:01 |</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> | 1 | TABLE ACCESS FULL| EMP | 14 | 280 | 3 (0)| 00:00:01 |</span> <br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- -- ---- ---- ------ </span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">Note< /span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> -- --</span><br style="font-family: courier new,monospace;"><span style="font -family: courier new,monospace;"> - dynamic sampling used for this statement</span><br style="font-family: courier new,monospace;"><br style="font -family: courier new,monospace;"> <span style="font-family: courier new,monospace;">SQL> <br></span>Hints are not designed to allow users to hint access paths that don't satisfy the query correctly. They are designed to say either "set this strategic goal for optimisation (RULE ,FIRST_ROWS_N ....) or else "I know that the best access path for this query (or part of it) is the following, please don't bother second guessing me. Can you imagine how unreliable Oracle based systems would be in general if the hints that developers have added to various code around the planet for the last decade weren't checked to make sure they were valid. Come to think of it there are more than enough hints in various versions of the data dictionary for that possibility to be worrying. <span style="font-family: courier new,monospace;"> </span ><br>On 7/13/06, <b class="gmail_sendername">jaromir nemec</b> <<a href= "mailto:jaromir@(protected)"> jaromir@(protected)</a>> wrote:<div><span class="gmail_quote"></span> <blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204) ; margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div>
<div bgcolor="#ffffff"> <div><font face="Arial" size="2">Hi,</font></div> <div><font face="Arial" size="2"></font> </div> <div></div><div><span class="q"> <p style="margin: 0cm 0cm 0pt;"><span lang="EN-US">> You cannot (or at least shouldn't be able to) provide a hint to an access path that </span></p> <p style="margin: 0cm 0cm 0pt;"><span lang="EN-US">> gives wrong results.< /span></p> <p style="margin: 0cm 0cm 0pt;"><span style="font-size: 8pt;" lang="EN-US"> </span></p></span></div><div> <p style="margin: 0cm 0cm 0pt;"><span lang="EN-US">Conscious or unconscious abuse of hints in a SQL statement may lead only to three kind of results:<br>- you get some result<br>- you get no result (see halting problem of Alan Tuning:)<br>- you get an error<br>Other behavior (i.e. receiving two different results) is in my opinion a bug.</span></p> <p style="margin: 0cm 0cm 0pt;"><span lang="EN-US"> </span></p> <p style="margin: 0cm 0cm 0pt;"><span lang="EN-US">Regards</span></p></div><div ><span class="sg"> <p style="margin: 0cm 0cm 0pt;"><span lang="EN-US">Jaromir</span></p></span>< /div><div></div></div><div><span class="q"> <blockquote style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;"> <div style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">-- -- Original Message -- -- </div> <div style="background: rgb(228, 228, 228) none repeat scroll 0% 50%; -moz -background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz -background-inline-policy: -moz-initial; font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal ; font-size-adjust: none; font-stretch: normal;"> <b>From:</b> <a title="niall.litchfield@(protected) (mailto:niall.litchfield@(protected))" href="mailto:niall.litchfield@(protected)" target="_blank" onclick="return top.js .OpenExtLink(window,event,this)">Niall Litchfield</a> </div> <div style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>To:</b> <a title="jkstill@(protected) (mailto :jkstill@(protected))" href="mailto:jkstill@(protected)" target="_blank" onclick= "return top.js.OpenExtLink(window,event,this)"> jkstill@(protected)</a> </div> <div style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>Cc:</b> <a title="gints.plivna@(protected) (mailto:gints.plivna@(protected))" href="mailto:gints.plivna@(protected)" target=" _blank" onclick="return top.js.OpenExtLink(window,event,this)"> gints.plivna@(protected)</a> ; <a title="oracle-l@(protected) (mailto:oracle-l @(protected))" href="mailto:oracle-l@(protected)" target="_blank" onclick= "return top.js.OpenExtLink(window,event,this)">oracle-l</a> </div> <div style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>Sent:</b> Thursday, July 13, 2006 10:31 PM</div> <div style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>Subject:</b> Re: Smells like oracle bug?</div> <div><br></div></blockquote></span></div><div></div>
</div></blockquote></div><br><br clear="all"><br>-- <br>Niall Litchfield<br >Oracle DBA<br><a href="http://www.orawin.info">http://www.orawin.info</a>
|
|