<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3116559472841364402</id><updated>2011-10-26T23:54:20.739+02:00</updated><category term='OOW11'/><category term='dbms_monitor'/><category term='cursor'/><category term='sql'/><category term='wait event'/><category term='event 10046'/><category term='bind variables'/><category term='Oracle Open World'/><category term='force'/><category term='peeking'/><category term='invalidation'/><category term='invalidate'/><category term='trace file'/><category term='oracle'/><title type='text'>Understanding Oracle</title><subtitle type='html'>This blog is about understanding how Oracle database works.&lt;br&gt;The learning process never ends and this is espeacially true &lt;br&gt;when one tries to understand what is hidden in the magic box called Oracle database.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://joze-senegacnik.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://joze-senegacnik.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Jože Senegačnik - Joc</name><uri>http://www.blogger.com/profile/10478214001612631485</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://4.bp.blogspot.com/_SOd0WN7CXgU/Svv9TjGM0lI/AAAAAAAAAU8/xGVOpqkTFDY/S220/joc_with_piper.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>24</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3116559472841364402.post-6803449626094653805</id><published>2011-10-05T05:06:00.007+02:00</published><updated>2011-10-05T19:05:54.941+02:00</updated><title type='text'>My Presentation "Getting the Best from the Cost Based Optimizer" at Oracle Open World 2011</title><content type='html'>Today (Tuesday, October 4th 2011) I had my presentation at OOW 2011 in Hotel InterContinental at 13:15 titled "Getting the Best from the Cost Based Optimizer".  The room was already sold out on Thursday and I really expected to have a full room - cca 270 people. The room was too small for all who want attending the presentation. Although there were no seats available quite a lot of them were standing in the back.&lt;br /&gt;&lt;br /&gt;This time my presentation was  not very technical one  (in my eyes).  I just wanted to point out problems I see many times in real life when people don't really know about some features or behavior of the CBO. Unfortunately one hour was not enough to explain in details why things are going wrong and also show all relevant details. But as I said, the aim was to point out the problems and also give directions what one has to do to get rid of them and according to the reactions of the audience after the presentation the goal was achieved.&lt;br /&gt;&lt;br /&gt;After the presentation I was answering the questions more than half an hour so I almost missed the meeting for the beta program of next release of the database. Because so many were interested to get the presentation slides I have uploaded it to my home web page immediately upon arrival at SFO airport.&lt;br /&gt;&lt;br /&gt;Here is the abstract for "Getting the Best from the Cost Based Optimizer":&lt;br /&gt;&lt;span style="font-style:italic;"&gt;Oracle Database 11g brings many new enhancements to PL/SQL. These will improve the performance, functionality, and security of your applications and will increase your productivity as a developer. This session will present the Oracle database 11g new PL/SQL language features and enhancements that can be used to improve programming functionality, performance and usability. Participants will learn about new trigger options, PL/SQL function result cache, bulk binding, new security features and more.&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;The agenda was:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Misused Initialization Parameters &amp;amp; System Statistics&lt;/li&gt;&lt;li&gt;Extended Statistics&lt;/li&gt;&lt;li&gt;Cost of execution of PL/SQL functions&lt;/li&gt;&lt;li&gt;Constraints&lt;/li&gt;&lt;li&gt;SQL Plan Management&lt;/li&gt;&lt;li&gt;SQL Monitoring&lt;/li&gt;&lt;li&gt;Automatic Cardinality Feedback Tuning&lt;/li&gt;&lt;/ul&gt;The presentation is available &lt;a href="http://www.dbprof.com/index.php?option=com_jdownloads&amp;amp;Itemid=57&amp;amp;view=viewcategory&amp;amp;catid=3"&gt;here for download&lt;/a&gt;, but you must be registered.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
&lt;/script&gt;
&lt;script type="text/javascript"&gt;
try {
var pageTracker = _gat._getTracker("UA-5265495-3");
pageTracker._trackPageview();
} catch(err) {}&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3116559472841364402-6803449626094653805?l=joze-senegacnik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://joze-senegacnik.blogspot.com/feeds/6803449626094653805/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://joze-senegacnik.blogspot.com/2011/10/my-presentation-at-oracle-open-world.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/6803449626094653805'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/6803449626094653805'/><link rel='alternate' type='text/html' href='http://joze-senegacnik.blogspot.com/2011/10/my-presentation-at-oracle-open-world.html' title='My Presentation &quot;Getting the Best from the Cost Based Optimizer&quot; at Oracle Open World 2011'/><author><name>Jože Senegačnik - Joc</name><uri>http://www.blogger.com/profile/10478214001612631485</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://4.bp.blogspot.com/_SOd0WN7CXgU/Svv9TjGM0lI/AAAAAAAAAU8/xGVOpqkTFDY/S220/joc_with_piper.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3116559472841364402.post-1882841402762157864</id><published>2011-10-02T18:31:00.003+02:00</published><updated>2011-10-02T19:14:43.859+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Oracle Open World'/><category scheme='http://www.blogger.com/atom/ns#' term='OOW11'/><title type='text'>Flying over Golden Gate bridge</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/-GGxc6CFT7d0/ToiUp3cPUkI/AAAAAAAADNo/sjNpRtPAGq0/s1600/011020111209.jpg"&gt;&lt;img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;width: 320px; height: 240px;" src="http://1.bp.blogspot.com/-GGxc6CFT7d0/ToiUp3cPUkI/AAAAAAAADNo/sjNpRtPAGq0/s320/011020111209.jpg" alt="" id="BLOGGER_PHOTO_ID_5658936378768970306" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Saturday was perfect day for activities not related to the Oracle Open World 2011 event. So I decided to do my first flying in USA. The details about this 1h20 long flight are available in my &lt;a href="http://jsenegacnik.blogspot.com/2011/10/flying-over-golden-gate-in-san.html"&gt;blog about flying&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;table style="width:194px;"&gt;&lt;tr&gt;&lt;td align="center" style="height:194px;background:url(https://picasaweb.google.com/s/c/transparent_album_background.gif) no-repeat left"&gt;&lt;a href="https://picasaweb.google.com/100242941829189131461/FlyingOverGoldenGateAtOOW2011?authuser=0&amp;feat=embedwebsite"&gt;&lt;img src="https://lh6.googleusercontent.com/-wjlXUQNvFdA/ToiKDaQ5GeE/AAAAAAAADNY/f-JfBo1237k/s160-c/FlyingOverGoldenGateAtOOW2011.jpg" width="160" height="160" style="margin:1px 0 0 4px;"&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="text-align:center;font-family:arial,sans-serif;font-size:11px"&gt;&lt;a href="https://picasaweb.google.com/100242941829189131461/FlyingOverGoldenGateAtOOW2011?authuser=0&amp;feat=embedwebsite" style="color:#4D4D4D;font-weight:bold;text-decoration:none;"&gt;Flying Over Golden Gate at OOW2011&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
&lt;/script&gt;
&lt;script type="text/javascript"&gt;
try {
var pageTracker = _gat._getTracker("UA-5265495-3");
pageTracker._trackPageview();
} catch(err) {}&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3116559472841364402-1882841402762157864?l=joze-senegacnik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://joze-senegacnik.blogspot.com/feeds/1882841402762157864/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://joze-senegacnik.blogspot.com/2011/10/flying-over-golden-gate-bridge.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/1882841402762157864'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/1882841402762157864'/><link rel='alternate' type='text/html' href='http://joze-senegacnik.blogspot.com/2011/10/flying-over-golden-gate-bridge.html' title='Flying over Golden Gate bridge'/><author><name>Jože Senegačnik - Joc</name><uri>http://www.blogger.com/profile/10478214001612631485</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://4.bp.blogspot.com/_SOd0WN7CXgU/Svv9TjGM0lI/AAAAAAAAAU8/xGVOpqkTFDY/S220/joc_with_piper.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-GGxc6CFT7d0/ToiUp3cPUkI/AAAAAAAADNo/sjNpRtPAGq0/s72-c/011020111209.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3116559472841364402.post-3094622305153038512</id><published>2011-09-30T18:57:00.003+02:00</published><updated>2011-09-30T19:04:50.062+02:00</updated><title type='text'>Oracle Open World 2011</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/-NK1v0X-LPBo/ToX1oncTWLI/AAAAAAAADJ4/dJwJXBeobw0/s1600/290920111184.jpg"&gt;&lt;img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;width: 320px; height: 240px;" src="http://1.bp.blogspot.com/-NK1v0X-LPBo/ToX1oncTWLI/AAAAAAAADJ4/dJwJXBeobw0/s320/290920111184.jpg" alt="" id="BLOGGER_PHOTO_ID_5658198584992159922" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;This year I have the opportunity to attend Oracle ACE Directors briefing  before the Oracle Open World 2011 event which is taking place at Oracle  Headquarters. It is great to get almost all important things which will  be announced in several days packed together and communicated by those  responsible people in Oracle. So I am really thankful for this  opportunity. A lot of ACE Directors gathered here and it is nice to meet  old friends and make personal contacts with all those who we know only  by name.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;My presentation titled "&lt;span style="font-weight: bold;"&gt;Getting The Best From The Cost Based Optimizer&lt;/span&gt;" is on Tuesday, October 4th  at 1:15 PM in InterContinental - Grand Ballroom B and it looks like the room will be full so come there on time to get your seat.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
&lt;/script&gt;
&lt;script type="text/javascript"&gt;
try {
var pageTracker = _gat._getTracker("UA-5265495-3");
pageTracker._trackPageview();
} catch(err) {}&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3116559472841364402-3094622305153038512?l=joze-senegacnik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://joze-senegacnik.blogspot.com/feeds/3094622305153038512/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://joze-senegacnik.blogspot.com/2011/09/oracle-open-world-2011.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/3094622305153038512'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/3094622305153038512'/><link rel='alternate' type='text/html' href='http://joze-senegacnik.blogspot.com/2011/09/oracle-open-world-2011.html' title='Oracle Open World 2011'/><author><name>Jože Senegačnik - Joc</name><uri>http://www.blogger.com/profile/10478214001612631485</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://4.bp.blogspot.com/_SOd0WN7CXgU/Svv9TjGM0lI/AAAAAAAAAU8/xGVOpqkTFDY/S220/joc_with_piper.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-NK1v0X-LPBo/ToX1oncTWLI/AAAAAAAADJ4/dJwJXBeobw0/s72-c/290920111184.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3116559472841364402.post-8887256784886381302</id><published>2011-03-24T14:43:00.003+01:00</published><updated>2011-03-24T14:56:57.868+01:00</updated><title type='text'>Update on Chris Date's Seminar in Ljubljana May 23-24 2011</title><content type='html'>The registration for the seminar is now open and there is a substantial early bird registration discount. Beside this the members of Slovenian, Croatian and Serbian Oracle User Group have additional discount. Please see the details on &lt;a href="http://www.dbprof.com/index.php?option=com_content&amp;amp;view=article&amp;amp;id=57:chris-date-seminar-in-ljubljana-&amp;amp;catid=1:latest-news&amp;amp;Itemid=50"&gt;www.dbprof.com&lt;/a&gt; about the seminar registration.&lt;br /&gt;&lt;br /&gt;I tried really hard to organize this unique event at the affordable prices for everybody especially in times when the financial crisis is still striking the budget for education.&lt;br /&gt;&lt;br /&gt;Interesting opinion about Chris Date's seminar in Ljubljana was published today by &lt;span style="font-weight: bold;"&gt;Dejan Sarka&lt;/span&gt;, worldwide known Slovenian expert for Microsoft SQL server .  He wrote: "&lt;span style="font-weight: bold;"&gt;Well, IMHO C. J. Date is the most important contemporary theorist on the  Relational Model. If there is a single person in the world I would like  to listen, this is Date&lt;/span&gt;." ..."&lt;span style="font-weight: bold;"&gt;If you have opportunity to join the Date's seminar, do not hesitate! it  is a unique opportunity, and I find the price, thanks to great  organization of the DbProf company, very attractive.&lt;/span&gt;" Details &lt;a href="http://blogs.solidq.com/dsarka/Post.aspx?ID=125&amp;amp;title=C.J.+Date+in+Ljubljana"&gt;here&lt;/a&gt;. Because he is a speaker at Slovenian NT Conference which is unfortunately taking place at the same time, he is not able to attend this unique event.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
&lt;/script&gt;
&lt;script type="text/javascript"&gt;
try {
var pageTracker = _gat._getTracker("UA-5265495-3");
pageTracker._trackPageview();
} catch(err) {}&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3116559472841364402-8887256784886381302?l=joze-senegacnik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://joze-senegacnik.blogspot.com/feeds/8887256784886381302/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://joze-senegacnik.blogspot.com/2011/03/update-on-chris-dates-seminar-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/8887256784886381302'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/8887256784886381302'/><link rel='alternate' type='text/html' href='http://joze-senegacnik.blogspot.com/2011/03/update-on-chris-dates-seminar-in.html' title='Update on Chris Date&apos;s Seminar in Ljubljana May 23-24 2011'/><author><name>Jože Senegačnik - Joc</name><uri>http://www.blogger.com/profile/10478214001612631485</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://4.bp.blogspot.com/_SOd0WN7CXgU/Svv9TjGM0lI/AAAAAAAAAU8/xGVOpqkTFDY/S220/joc_with_piper.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3116559472841364402.post-3459690367973240503</id><published>2011-02-26T12:33:00.004+01:00</published><updated>2011-02-26T12:51:33.248+01:00</updated><title type='text'>Organizing Chris Date's seminar in Ljubljana May 23-24 2011</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.dbprof.com/images/stories/cjd.jpg"&gt;&lt;img style="float: right; margin: 0pt 0pt 10px 10px; cursor: pointer; width: 79px; height: 101px;" src="http://www.dbprof.com/images/stories/cjd.jpg" alt="" border="0" /&gt;&lt;/a&gt;I have invited Chris J. Date, an independent author, lecturer, researcher, and consultant of international renown, specializing in relational database technology, to have a 2 day seminar &lt;span style="font-weight: bold;"&gt;"How to Write Correct SQL and Know It: A Relational Approach to SQL"&lt;/span&gt;. The 2-day seminar will take place in &lt;span style="font-weight: bold;"&gt;Ljubljana&lt;/span&gt;, Slovenia,  on &lt;span style="font-weight: bold;"&gt;May 23-24 2011&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;Chris is best known for his book "&lt;i&gt;An Introduction to Database Systems&lt;/i&gt;" (eighth edition, Addison-Wesley, 2004), which has sold some 725,000 copies and is used by several hundred colleges and universities worldwide.&lt;br /&gt;For more details about this seminar please read on my &lt;a href="http://www.dbprof.com/index.php?option=com_content&amp;amp;view=article&amp;amp;id=57:chris-date-seminar-in-ljubljana-&amp;amp;catid=1:latest-news&amp;amp;Itemid=50"&gt;home page&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Why this seminar? So many times I am involved in performance troubleshooting and in more than 80% of all cases the fault is bad design and poorly written SQL statements. With organizing this event I would like to give a good opportunity to all developers (either on Oracle database or any other database) to get more theoretical knowledge about SQL.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
&lt;/script&gt;
&lt;script type="text/javascript"&gt;
try {
var pageTracker = _gat._getTracker("UA-5265495-3");
pageTracker._trackPageview();
} catch(err) {}&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3116559472841364402-3459690367973240503?l=joze-senegacnik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://joze-senegacnik.blogspot.com/feeds/3459690367973240503/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://joze-senegacnik.blogspot.com/2011/02/organizing-chris-dates-seminar-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/3459690367973240503'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/3459690367973240503'/><link rel='alternate' type='text/html' href='http://joze-senegacnik.blogspot.com/2011/02/organizing-chris-dates-seminar-in.html' title='Organizing Chris Date&apos;s seminar in Ljubljana May 23-24 2011'/><author><name>Jože Senegačnik - Joc</name><uri>http://www.blogger.com/profile/10478214001612631485</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://4.bp.blogspot.com/_SOd0WN7CXgU/Svv9TjGM0lI/AAAAAAAAAU8/xGVOpqkTFDY/S220/joc_with_piper.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3116559472841364402.post-7379241083927851491</id><published>2010-10-19T09:09:00.010+02:00</published><updated>2010-10-19T10:46:56.483+02:00</updated><title type='text'>Presenting at Croatian Oracle User Group - HROUG</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.hroug.hr"&gt;&lt;img style="float: right; margin: 0pt 0pt 10px 10px; cursor: pointer; width: 460px; height: 235px;" src="http://www.hroug.hr/var/hroug/storage/images/hroug_konferencija/u_pripremi/hroug2010_rovinj/4295-72-cro-HR/hroug2010_rovinj.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;This week I'll be presenting at Croatian Oracle User Group Conference (HROUG) which will take place in Rovinj in Croatia, a beautiful old city in Istria at the Adriatic coast.&lt;br /&gt;&lt;br /&gt;HROUG is a very strong and active user group. Every year they organize excellent conference, so this year it is already the 15th. Last year I was presenting about execution plan stability and my presentation was selected as the best presentation in the "Database and Technology" track.&lt;br /&gt;&lt;br /&gt;Rovinj is only about 2.5 hour drive away from my home in neighbor country. My presentation is scheduled for Thursday, 21.10.2010 at 15:00 hours and I will repeat my presentation from Oracle Open World 2010. Friday morning I'll be talking about the Oracle ACE Program together with other Oracle ACEs / ACE Directors who will be there as well. Currently Croatia has no Oracle ACE yet.  Therefore the Croatian Oracle User Group would like to make people aware of this Oracle program and at the same time they would like to discuss their first nominations.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
&lt;/script&gt;
&lt;script type="text/javascript"&gt;
try {
var pageTracker = _gat._getTracker("UA-5265495-3");
pageTracker._trackPageview();
} catch(err) {}&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3116559472841364402-7379241083927851491?l=joze-senegacnik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://joze-senegacnik.blogspot.com/feeds/7379241083927851491/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://joze-senegacnik.blogspot.com/2010/10/presenting-at-croatian-oracle-user.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/7379241083927851491'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/7379241083927851491'/><link rel='alternate' type='text/html' href='http://joze-senegacnik.blogspot.com/2010/10/presenting-at-croatian-oracle-user.html' title='Presenting at Croatian Oracle User Group - HROUG'/><author><name>Jože Senegačnik - Joc</name><uri>http://www.blogger.com/profile/10478214001612631485</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://4.bp.blogspot.com/_SOd0WN7CXgU/Svv9TjGM0lI/AAAAAAAAAU8/xGVOpqkTFDY/S220/joc_with_piper.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3116559472841364402.post-3522646874609428665</id><published>2010-10-19T08:52:00.005+02:00</published><updated>2010-10-19T09:02:54.937+02:00</updated><title type='text'>Query Transformations - follow up</title><content type='html'>Despite the doubts about the topic "Query Transformations" (described in my &lt;a href="http://joze-senegacnik.blogspot.com/2010/09/my-oracle-open-world-2010-presentation.html"&gt;previous post&lt;/a&gt;)  presented at OOW which was quite technical I found extremely nice comments in different blog posts written by the attendees of my presentation. Thanks for sharing that with others. I was really happy and at same time surprised to have the room almost full and I hope everybody has learned at least something useful.&lt;br /&gt;&lt;br /&gt;For those, who don't have access to presentations at OOW 2010 I uploaded the presentation to my &lt;a href="http://www.dbprof.com/joomla/index.php?option=com_jdownloads&amp;amp;view=viewcategories&amp;amp;Itemid=57"&gt;home site&lt;/a&gt; and it is ready for download. You have to login (or register first if you have no login yet).&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
&lt;/script&gt;
&lt;script type="text/javascript"&gt;
try {
var pageTracker = _gat._getTracker("UA-5265495-3");
pageTracker._trackPageview();
} catch(err) {}&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3116559472841364402-3522646874609428665?l=joze-senegacnik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://joze-senegacnik.blogspot.com/feeds/3522646874609428665/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://joze-senegacnik.blogspot.com/2010/10/query-transformations-follow-up.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/3522646874609428665'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/3522646874609428665'/><link rel='alternate' type='text/html' href='http://joze-senegacnik.blogspot.com/2010/10/query-transformations-follow-up.html' title='Query Transformations - follow up'/><author><name>Jože Senegačnik - Joc</name><uri>http://www.blogger.com/profile/10478214001612631485</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://4.bp.blogspot.com/_SOd0WN7CXgU/Svv9TjGM0lI/AAAAAAAAAU8/xGVOpqkTFDY/S220/joc_with_piper.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3116559472841364402.post-2193072632960284255</id><published>2010-09-22T18:30:00.006+02:00</published><updated>2010-10-19T10:30:08.498+02:00</updated><title type='text'>Stanley at OOW 2010</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_SOd0WN7CXgU/TJowV8EtVYI/AAAAAAAADFo/1gPIsGpq-8E/s1600/210920101077.jpg"&gt;&lt;img style="float: right; margin: 0pt 0pt 10px 10px; cursor: pointer; width: 320px; height: 240px;" src="http://1.bp.blogspot.com/_SOd0WN7CXgU/TJowV8EtVYI/AAAAAAAADFo/1gPIsGpq-8E/s320/210920101077.jpg" alt="" id="BLOGGER_PHOTO_ID_5519777446757225858" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Yesterday, on Tuesday September 21st, I met with Debra Lilley, Robyn Sands, Mogens Norgard and Dan Norris at the Chevys. When we exited I took some funny pictures of Dan, Debra and Mogens and, of course, &lt;a href="http://www.wtfistheacevest.com/"&gt;Stanley-Oracle ACE Director&lt;/a&gt;. And I'm pretty sure everybody knows Stanley. If not, go to his home page and learn more about him.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/_SOd0WN7CXgU/TJowK8gn_6I/AAAAAAAADFg/xN6Dsp9-mEY/s1600/210920101074.jpg"&gt;&lt;img style="float: right; margin: 0pt 0pt 10px 10px; cursor: pointer; width: 320px; height: 240px;" src="http://3.bp.blogspot.com/_SOd0WN7CXgU/TJowK8gn_6I/AAAAAAAADFg/xN6Dsp9-mEY/s320/210920101074.jpg" alt="" id="BLOGGER_PHOTO_ID_5519777257895755682" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_SOd0WN7CXgU/TJowcIMtvnI/AAAAAAAADFw/b1MtKeFT9zU/s1600/210920101079.jpg"&gt;&lt;img style="float: right; margin: 0pt 0pt 10px 10px; cursor: pointer; width: 320px; height: 240px;" src="http://2.bp.blogspot.com/_SOd0WN7CXgU/TJowcIMtvnI/AAAAAAAADFw/b1MtKeFT9zU/s320/210920101079.jpg" alt="" id="BLOGGER_PHOTO_ID_5519777553091247730" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
&lt;/script&gt;
&lt;script type="text/javascript"&gt;
try {
var pageTracker = _gat._getTracker("UA-5265495-3");
pageTracker._trackPageview();
} catch(err) {}&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3116559472841364402-2193072632960284255?l=joze-senegacnik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://joze-senegacnik.blogspot.com/feeds/2193072632960284255/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://joze-senegacnik.blogspot.com/2010/09/stanley-at-oow-2010.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/2193072632960284255'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/2193072632960284255'/><link rel='alternate' type='text/html' href='http://joze-senegacnik.blogspot.com/2010/09/stanley-at-oow-2010.html' title='Stanley at OOW 2010'/><author><name>Jože Senegačnik - Joc</name><uri>http://www.blogger.com/profile/10478214001612631485</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://4.bp.blogspot.com/_SOd0WN7CXgU/Svv9TjGM0lI/AAAAAAAAAU8/xGVOpqkTFDY/S220/joc_with_piper.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_SOd0WN7CXgU/TJowV8EtVYI/AAAAAAAADFo/1gPIsGpq-8E/s72-c/210920101077.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3116559472841364402.post-1034957072131371699</id><published>2010-09-22T14:58:00.014+02:00</published><updated>2010-10-19T09:00:21.338+02:00</updated><title type='text'>My Oracle Open World 2010 Presentation - "Query Transformations"</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_SOd0WN7CXgU/TJoDP16QKUI/AAAAAAAADFY/X9X-LwCk-OE/s1600/qt.JPG"&gt;&lt;img style="float: right; margin: 0pt 0pt 10px 10px; cursor: pointer; width: 320px; height: 238px;" src="http://4.bp.blogspot.com/_SOd0WN7CXgU/TJoDP16QKUI/AAAAAAAADFY/X9X-LwCk-OE/s320/qt.JPG" alt="" id="BLOGGER_PHOTO_ID_5519727864000293186" border="0" /&gt;&lt;/a&gt;This year I have a presentation titled "&lt;span style="font-weight: bold;"&gt;Query Transformations&lt;/span&gt;"  in Moscone South, Room 300 on Thursday, September 23 at 12:00. In last years I had done a similar presentation several times at different conferences. However, this presentation contains new transformations  which came in Oracle 11gR2. The list of query transformations I will talk about is the following:&lt;br /&gt;&lt;br /&gt;&lt;!--[if !mso]&gt; &lt;style&gt; v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} p\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} v\:textbox {display:none;} &lt;/style&gt; &lt;![endif]--&gt;&lt;!--[if !ppt]--&gt;&lt;!--[endif]--&gt;  &lt;div&gt;  &lt;div class="O1" style=""&gt;&lt;span style="font-size:89%;"&gt;&lt;span style="position: absolute; left: -4.7%;"&gt;–&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:16pt;"&gt;&lt;/span&gt;&lt;/div&gt;–JPPD - join predicate push-down&lt;br /&gt;–FPD - filter push-down&lt;br /&gt;–PM - predicate move-around&lt;br /&gt;–CVM - complex view merging&lt;br /&gt;–SPJ - select-project-join&lt;br /&gt;–SJC - set join conversion&lt;br /&gt;–SU - subquery unnesting&lt;br /&gt;–OBYE - order by elimination&lt;br /&gt;–CNT - count(col) to count(*) transformation&lt;br /&gt;–JE - Join Elimination&lt;br /&gt;–JF - join factorization&lt;br /&gt;&lt;br /&gt;Especially the last one added in 11gR2 is quite interesting and has the background in the patent registration application which could be found &lt;a href="http://www.freepatentsonline.com/7644062.pdf"&gt;here&lt;/a&gt;.  Another very interesting source of information is the paper presented by several Oracle employees at VLDB'09 which is available &lt;a href="http://www.vldb.org/pvldb/2/vldb09-423.pdf"&gt;here&lt;/a&gt;. During the whole presentation I am showing excerpts from CBO trace file in order that the audience can learn how CBO reports about performed transformation. Some useful pieces about transformations are also available in &lt;a href="http://blogs.oracle.com/optimizer"&gt;Optimizer Development Team blog&lt;/a&gt;.&lt;br /&gt;&lt;div class="O1" style=""&gt;&lt;br /&gt;According to number of enrolled attendees it looks like the room will be almost full. Yesterday I had a discussion with Mohamed Zait who is in the Optimizer development team and he was surprised that the topic about query transformations is so interesting for OOW attendees. My personal opinion  shared also by many others is that the content of too many presentations at OOW contains just a "helicopter" view of what is available but doesn't show or explain anything what is going on "behind the scene".  However, with great pleasure I must admit that I was able to find some very good presentation during last 3 days what just confirms the fact that the speakers feel the need to go beyond the "usual" level of expertize and I am very thankful for that. One of such presentation was prepared by Maria Colgan titled "Explaining the Explain Plan: Interpreting Execution Plans for SQL Statements" where I haven't heard some new stuff but liked very much the way she presented the topic and the contents of the presentation. One of the very important messages she gave was that people should not change database parameters unless they really know what they are doing. She especially mentioned famous OPTIMIZER_INDEX_COST_ADJ which should be left at it's default value of 100. I was missing at least some words about system statistics. The other one I found also very interesting was "Oracle Database Performance Secrets Finally Revealed" presented by Greg Rahn and Michael Hallas.&lt;br /&gt;&lt;br /&gt;My presentation is available for downloading at my &lt;a href="http://www.dbprof.com/joomla/index.php?option=com_jdownloads&amp;amp;view=viewcategories&amp;amp;Itemid=57"&gt;home site&lt;/a&gt;. You have to login in (or register first if you have no login yet).&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
&lt;/script&gt;
&lt;script type="text/javascript"&gt;
try {
var pageTracker = _gat._getTracker("UA-5265495-3");
pageTracker._trackPageview();
} catch(err) {}&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3116559472841364402-1034957072131371699?l=joze-senegacnik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://joze-senegacnik.blogspot.com/feeds/1034957072131371699/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://joze-senegacnik.blogspot.com/2010/09/my-oracle-open-world-2010-presentation.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/1034957072131371699'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/1034957072131371699'/><link rel='alternate' type='text/html' href='http://joze-senegacnik.blogspot.com/2010/09/my-oracle-open-world-2010-presentation.html' title='My Oracle Open World 2010 Presentation - &quot;Query Transformations&quot;'/><author><name>Jože Senegačnik - Joc</name><uri>http://www.blogger.com/profile/10478214001612631485</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://4.bp.blogspot.com/_SOd0WN7CXgU/Svv9TjGM0lI/AAAAAAAAAU8/xGVOpqkTFDY/S220/joc_with_piper.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_SOd0WN7CXgU/TJoDP16QKUI/AAAAAAAADFY/X9X-LwCk-OE/s72-c/qt.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3116559472841364402.post-8255217892596428607</id><published>2010-09-17T17:51:00.004+02:00</published><updated>2010-09-17T19:45:32.829+02:00</updated><title type='text'>Michigan OakTable Symposium - Day 2</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_SOd0WN7CXgU/TJOhjMAO3LI/AAAAAAAADFQ/TwheUZIhsZ0/s1600/OakTable.jpg"&gt;&lt;img style="float: right; margin: 0pt 0pt 10px 10px; cursor: pointer; width: 320px; height: 240px;" src="http://4.bp.blogspot.com/_SOd0WN7CXgU/TJOhjMAO3LI/AAAAAAAADFQ/TwheUZIhsZ0/s320/OakTable.jpg" alt="" id="BLOGGER_PHOTO_ID_5517931594348682418" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Today I had my presentation in the first slot in the morning and I was pleasantly surprised as the room was full. Obviously the "execution plan stability" is one of the biggest concerns of every DBA. After the presentation Jonathan Lewis told me that he made 4 pages of notes while attending the presentation and now he has a lot of new stuff to investigate.&lt;br /&gt;Next session I attended  was Cristian Antognini's presentation about obtaining the execution plans which was part of two slot presentation about execution plans. As usually, Cristian had a very good presentation.&lt;br /&gt;&lt;br /&gt;The next session was Jeremiah Wilton's  battle between SQL server and Oracle, both running in Amazon cloud environment. Again, a very nice presentation.&lt;br /&gt;&lt;br /&gt;Before the lunch we made a group picture of all Oakies gathered at the event. Unfortunately some of them are missing on the picture.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
&lt;/script&gt;
&lt;script type="text/javascript"&gt;
try {
var pageTracker = _gat._getTracker("UA-5265495-3");
pageTracker._trackPageview();
} catch(err) {}&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3116559472841364402-8255217892596428607?l=joze-senegacnik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://joze-senegacnik.blogspot.com/feeds/8255217892596428607/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://joze-senegacnik.blogspot.com/2010/09/michigan-oaktable-symposium-day-2.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/8255217892596428607'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/8255217892596428607'/><link rel='alternate' type='text/html' href='http://joze-senegacnik.blogspot.com/2010/09/michigan-oaktable-symposium-day-2.html' title='Michigan OakTable Symposium - Day 2'/><author><name>Jože Senegačnik - Joc</name><uri>http://www.blogger.com/profile/10478214001612631485</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://4.bp.blogspot.com/_SOd0WN7CXgU/Svv9TjGM0lI/AAAAAAAAAU8/xGVOpqkTFDY/S220/joc_with_piper.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_SOd0WN7CXgU/TJOhjMAO3LI/AAAAAAAADFQ/TwheUZIhsZ0/s72-c/OakTable.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3116559472841364402.post-5125120288272480811</id><published>2010-09-16T16:54:00.011+02:00</published><updated>2010-09-17T12:38:59.421+02:00</updated><title type='text'>Michigan Oak Table Symposium 2010 (MOTS) in Ann Arbor, MI, USA</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_SOd0WN7CXgU/TJIwQbO1DRI/AAAAAAAADE4/o5ULB0emeTs/s1600/160920101051.jpg"&gt;&lt;img style="float: right; margin: 0pt 0pt 10px 10px; cursor: pointer; width: 320px; height: 240px;" src="http://3.bp.blogspot.com/_SOd0WN7CXgU/TJIwQbO1DRI/AAAAAAAADE4/o5ULB0emeTs/s320/160920101051.jpg" alt="" id="BLOGGER_PHOTO_ID_5517525552228273426" border="0" /&gt;&lt;/a&gt;This morning we started with probably the biggest gathering of OakTable members ever. We gathered in Ann Arbor in Michigan for a two day event just before the Oracle Open World in San Francisco. The seminar is running in 3 parallel sessions.&lt;br /&gt;Cary Millsap, one of the founders of OakTable, told a short story how OakTable was founded and then he introduced Mogens Norgard - "Moans The Magnificent" who was answering to the secret questions even before he knew for them. Believe, we had a lot of fun with the answers and questions as well. On the picture you can see Mogens answering the questions and wearing the magic hat.&lt;br /&gt;As Doug Burns couldn't make to this event I offered to have another presentation which I had already in the past and was proposed by Carol - "Optimizing Access Paths".&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;Tomorrow I'll be talking about "SQL Plan Baselines, Adaptive Cursor Sharing , Automatic Cardinality Feedback SQL Tuning in Oracle 11gR2".&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_SOd0WN7CXgU/TJIxJvT61kI/AAAAAAAADFI/JEJcqFThIjs/s1600/160920101054.jpg"&gt;&lt;img style="float: right; margin: 0pt 0pt 10px 10px; cursor: pointer; width: 320px; height: 240px;" src="http://1.bp.blogspot.com/_SOd0WN7CXgU/TJIxJvT61kI/AAAAAAAADFI/JEJcqFThIjs/s320/160920101054.jpg" alt="" id="BLOGGER_PHOTO_ID_5517526536870876738" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
&lt;/script&gt;
&lt;script type="text/javascript"&gt;
try {
var pageTracker = _gat._getTracker("UA-5265495-3");
pageTracker._trackPageview();
} catch(err) {}&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3116559472841364402-5125120288272480811?l=joze-senegacnik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://joze-senegacnik.blogspot.com/feeds/5125120288272480811/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://joze-senegacnik.blogspot.com/2010/09/michigan-oak-table-day-2010-motd-in-ann.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/5125120288272480811'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/5125120288272480811'/><link rel='alternate' type='text/html' href='http://joze-senegacnik.blogspot.com/2010/09/michigan-oak-table-day-2010-motd-in-ann.html' title='Michigan Oak Table Symposium 2010 (MOTS) in Ann Arbor, MI, USA'/><author><name>Jože Senegačnik - Joc</name><uri>http://www.blogger.com/profile/10478214001612631485</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://4.bp.blogspot.com/_SOd0WN7CXgU/Svv9TjGM0lI/AAAAAAAAAU8/xGVOpqkTFDY/S220/joc_with_piper.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_SOd0WN7CXgU/TJIwQbO1DRI/AAAAAAAADE4/o5ULB0emeTs/s72-c/160920101051.jpg' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3116559472841364402.post-346791336957921005</id><published>2009-12-17T08:26:00.009+01:00</published><updated>2009-12-18T02:07:10.512+01:00</updated><title type='text'>Miracle Open World 2010, April 14-16, Legoland</title><content type='html'>Finally Miracle has published the first official advertisement for Miracle Open World 2010 event, which will take place in Legoland, Billund, Jutland, Denmark, from 14-16 April 2010. Here is the link to the &lt;a href="http://mow2010.dk/"&gt;event site&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;I'll be presenting at this spectacular and unique event. Hopefully the weather will permit me to fly to Legoland by myself and land at &lt;a href="http://www.billund-airport.com/"&gt;Billund airport&lt;/a&gt; which is just several hundred meters away from the conference venue.&lt;br /&gt;&lt;br /&gt;&lt;object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" style="width: 480px; height: 320px;" width="240" height="160"&gt;&lt;param name="movie" value="http://www.miraclechannel.dk/v.swf"&gt;&lt;param name="FlashVars" value="album%5fid=544142&amp;amp;autoPlay=0"&gt;&lt;param name="allowfullscreen" value="true"&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;embed src="http://www.miraclechannel.dk/v.swf" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" flashvars="album%5fid=544142&amp;amp;autoPlay=0" width="240" height="160"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
&lt;/script&gt;
&lt;script type="text/javascript"&gt;
try {
var pageTracker = _gat._getTracker("UA-5265495-3");
pageTracker._trackPageview();
} catch(err) {}&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3116559472841364402-346791336957921005?l=joze-senegacnik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://joze-senegacnik.blogspot.com/feeds/346791336957921005/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://joze-senegacnik.blogspot.com/2009/12/miracle-open-world-2010-april-14-16.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/346791336957921005'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/346791336957921005'/><link rel='alternate' type='text/html' href='http://joze-senegacnik.blogspot.com/2009/12/miracle-open-world-2010-april-14-16.html' title='Miracle Open World 2010, April 14-16, Legoland'/><author><name>Jože Senegačnik - Joc</name><uri>http://www.blogger.com/profile/10478214001612631485</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://4.bp.blogspot.com/_SOd0WN7CXgU/Svv9TjGM0lI/AAAAAAAAAU8/xGVOpqkTFDY/S220/joc_with_piper.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3116559472841364402.post-6765238541908934437</id><published>2009-12-16T09:35:00.008+01:00</published><updated>2009-12-16T10:08:12.455+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sql'/><category scheme='http://www.blogger.com/atom/ns#' term='invalidation'/><category scheme='http://www.blogger.com/atom/ns#' term='peeking'/><category scheme='http://www.blogger.com/atom/ns#' term='invalidate'/><category scheme='http://www.blogger.com/atom/ns#' term='cursor'/><category scheme='http://www.blogger.com/atom/ns#' term='force'/><category scheme='http://www.blogger.com/atom/ns#' term='oracle'/><category scheme='http://www.blogger.com/atom/ns#' term='bind variables'/><title type='text'>Force Cursor Invalidation</title><content type='html'>Many times it occurs that an inappropriate execution plan is used which was produced by using the current values of bind variables provided at the time of the hard parse. But later on the variables change so much that another execution plan would be required. Unfortunately there is no automatism in 9i and 10g that would spot this fact. Oracle finally resolved this problem in 11g.&lt;br /&gt;&lt;br /&gt;The trick is to virtually set the statistics for the object which is involved in the query. What I mean by virtually is that I read the current statistics and store the same statistics back what makes no harm but the side effect is that the cursor is invalidated and hence it will be re-parsed and hopefully this time optimized for the right values of bind variables. &lt;br /&gt;&lt;br /&gt;Here is the code:&lt;br /&gt;&lt;div class="codesnippet"&gt;&lt;br /&gt;CREATE OR REPLACE PROCEDURE Invalidate_statistics (&lt;br /&gt;   p_ownname   VARCHAR2,&lt;br /&gt;   p_tabname   VARCHAR2&lt;br /&gt;) IS&lt;br /&gt;   m_srec      DBMS_STATS.STATREC;&lt;br /&gt;   m_distcnt   NUMBER;&lt;br /&gt;   m_density   NUMBER;&lt;br /&gt;   m_nullcnt   NUMBER;&lt;br /&gt;   m_avgclen   NUMBER;&lt;br /&gt;   m_colname   VARCHAR2(30);&lt;br /&gt;--&lt;br /&gt;-- This procedure invalidates all cursors present in v$sql&lt;br /&gt;-- which refer to the table passed as input parameter&lt;br /&gt;--&lt;br /&gt;-- requires DBA privileges&lt;br /&gt;--&lt;br /&gt;-- This is a workaround to solve the problem of bind variable peeking &lt;br /&gt;--&lt;br /&gt;BEGIN&lt;br /&gt;   -- first find column definition for the first column - doesn't matter for which &lt;br /&gt;   -- column we reset the statistics &lt;br /&gt;   BEGIN&lt;br /&gt;      SELECT column_name INTO m_colname &lt;br /&gt;      FROM   DBA_TAB_COLUMNS&lt;br /&gt;      WHERE  owner = p_ownname&lt;br /&gt;      AND    table_name = p_tabname&lt;br /&gt;      AND    ROWNUM = 1;&lt;br /&gt;   EXCEPTION&lt;br /&gt;      WHEN NO_DATA_FOUND THEN RAISE_APPLICATION_ERROR( -20000, &lt;br /&gt;          'Table '||p_ownname||'.'||p_tabname||' does not exist');&lt;br /&gt;   END;&lt;br /&gt;   -- virtually change the statistics - replace with the same values what will cause&lt;br /&gt;   -- invalidation of all cursors which refer to this table - NO_INVALIDATE must be FALSE&lt;br /&gt;   DBMS_STATS.GET_COLUMN_STATS (ownname      =&gt; p_ownname,&lt;br /&gt;                                tabname      =&gt; p_tabname,&lt;br /&gt;                                colname      =&gt; m_colname,&lt;br /&gt;                                distcnt      =&gt; m_distcnt,&lt;br /&gt;                                density      =&gt; m_density,&lt;br /&gt;                                nullcnt      =&gt; m_nullcnt,&lt;br /&gt;                                srec         =&gt; m_srec,&lt;br /&gt;                                avgclen      =&gt; m_avgclen&lt;br /&gt;                               );&lt;br /&gt;   DBMS_STATS.SET_COLUMN_STATS (ownname            =&gt; p_ownname,&lt;br /&gt;                                tabname            =&gt; p_tabname,&lt;br /&gt;                                colname            =&gt; m_colname,&lt;br /&gt;                                distcnt            =&gt; m_distcnt,&lt;br /&gt;                                density            =&gt; m_density,&lt;br /&gt;                                nullcnt            =&gt; m_nullcnt,&lt;br /&gt;                                srec               =&gt; m_srec,&lt;br /&gt;                                avgclen            =&gt; m_avgclen,&lt;br /&gt;                                no_invalidate      =&gt; FALSE&lt;br /&gt;                               );&lt;br /&gt;END;&lt;br /&gt;/&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The procedure reads and stores back the statistics for the first column of the table.&lt;br /&gt;&lt;div class="codesnippet"&gt;&lt;br /&gt;SQL&gt; exec Invalidate_statistics('SCOTT','EMP')&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Sometimes it requires to re-execute the invalidation as the cursor is currently executing. One can use this in 9i,10g,11g.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
&lt;/script&gt;
&lt;script type="text/javascript"&gt;
try {
var pageTracker = _gat._getTracker("UA-5265495-3");
pageTracker._trackPageview();
} catch(err) {}&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3116559472841364402-6765238541908934437?l=joze-senegacnik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://joze-senegacnik.blogspot.com/feeds/6765238541908934437/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://joze-senegacnik.blogspot.com/2009/12/force-cursor-invalidation.html#comment-form' title='10 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/6765238541908934437'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/6765238541908934437'/><link rel='alternate' type='text/html' href='http://joze-senegacnik.blogspot.com/2009/12/force-cursor-invalidation.html' title='Force Cursor Invalidation'/><author><name>Jože Senegačnik - Joc</name><uri>http://www.blogger.com/profile/10478214001612631485</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://4.bp.blogspot.com/_SOd0WN7CXgU/Svv9TjGM0lI/AAAAAAAAAU8/xGVOpqkTFDY/S220/joc_with_piper.jpg'/></author><thr:total>10</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3116559472841364402.post-1738247261659330577</id><published>2009-12-10T01:17:00.005+01:00</published><updated>2009-12-10T07:52:54.859+01:00</updated><title type='text'>"Optimizer Internals" - Celebrity Seminar in Netherlands</title><content type='html'>On June 15th 2010 I will be speaking about &lt;a href="http://education.oracle.com/pls/web_prod-plq-dad/db_pages.getCourseDesc?dc=D70365_1060216&amp;amp;p_org_id=41&amp;amp;lang=NL%20"&gt;internals of the Cost Based Optimizer&lt;/a&gt; in Netherlands. This is a &lt;span style="font-weight: bold;"&gt;one day seminar &lt;/span&gt;&lt;span&gt;organized by Oracle University&lt;/span&gt;&lt;span style="font-weight: bold;"&gt; &lt;/span&gt; which goes in details in some sections of the cost based optimization. The topics are related to hot themes for which people would like to get a good explanation. Here is a &lt;a href="http://www.dbprof.com/CBO_Internals_TOC.pdf"&gt;detailed table of contents&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;This seminar is one of four that I have contributed to the series of celebrity seminars organized by Oracle University.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
&lt;/script&gt;
&lt;script type="text/javascript"&gt;
try {
var pageTracker = _gat._getTracker("UA-5265495-3");
pageTracker._trackPageview();
} catch(err) {}&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3116559472841364402-1738247261659330577?l=joze-senegacnik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://joze-senegacnik.blogspot.com/feeds/1738247261659330577/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://joze-senegacnik.blogspot.com/2009/12/optimizer-internals-celebrity-seminar.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/1738247261659330577'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/1738247261659330577'/><link rel='alternate' type='text/html' href='http://joze-senegacnik.blogspot.com/2009/12/optimizer-internals-celebrity-seminar.html' title='&quot;Optimizer Internals&quot; - Celebrity Seminar in Netherlands'/><author><name>Jože Senegačnik - Joc</name><uri>http://www.blogger.com/profile/10478214001612631485</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://4.bp.blogspot.com/_SOd0WN7CXgU/Svv9TjGM0lI/AAAAAAAAAU8/xGVOpqkTFDY/S220/joc_with_piper.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3116559472841364402.post-2935026310034006569</id><published>2009-12-08T23:45:00.005+01:00</published><updated>2009-12-17T13:05:39.781+01:00</updated><title type='text'>CBO oddities in determining selectivity on NVARCHAR2 data type</title><content type='html'>Some time ago I was involved in solving of a performance problem which was really weird - a simple select on a indexed column with unique value always resulted in a full table scan. The key column was of type NVARCHAR2. To better understand the behavior I created a simple reproducible test case.&lt;br /&gt;&lt;br /&gt;Let us start with table and index creation.&lt;br /&gt;&lt;div class="codesnippet"&gt;&lt;br /&gt;SQL&gt; select * from v$version;&lt;br /&gt;&lt;br /&gt;BANNER&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production&lt;br /&gt;PL/SQL Release 11.1.0.6.0 - Production&lt;br /&gt;CORE    11.1.0.6.0      Production&lt;br /&gt;TNS for 32-bit Windows: Version 11.1.0.6.0 - Production&lt;br /&gt;NLSRTL Version 11.1.0.6.0 - Production&lt;br /&gt;&lt;br /&gt;SQL&gt; show parameter semant&lt;br /&gt;&lt;br /&gt;NAME                                 TYPE        VALUE&lt;br /&gt;------------------------------------ ----------- ------------------------------&lt;br /&gt;nls_length_semantics                 string      CHAR&lt;br /&gt;&lt;br /&gt;SQL&gt; create table x2 (id varchar2(32), idn nvarchar2(32), id16 nvarchar2(16), id20 nvarchar2(20));&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;SQL&gt; insert into x2 select lpad(rownum,32,'0'), lpad(rownum,32,'0'),lpad(rownum,16,'0'),lpad(rownum,20,'0')&lt;br /&gt;   from dual connect by level &lt;= 20000;  20000 rows created.  SQL&gt; commit;&lt;br /&gt;&lt;br /&gt;Commit complete.&lt;br /&gt;&lt;br /&gt;SQL&gt; create index x2_idn on x2(idn);&lt;br /&gt;&lt;br /&gt;Index created.&lt;br /&gt;&lt;br /&gt;SQL&gt; analyze table x2 compute statistics;&lt;br /&gt;&lt;br /&gt;Table analyzed.&lt;br /&gt;&lt;br /&gt;SQL&gt; explain plan for select * from x2 where idn=U'00000000000000000000000000000009';&lt;br /&gt;&lt;br /&gt;Explained.&lt;br /&gt;&lt;br /&gt;SQL&gt; select * from table(dbms_xplan.display);&lt;br /&gt;&lt;br /&gt;PLAN_TABLE_OUTPUT&lt;br /&gt;--------------------------------------------------------------------------&lt;br /&gt;Plan hash value: 156302112&lt;br /&gt;&lt;br /&gt;--------------------------------------------------------------------------&lt;br /&gt;| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |&lt;br /&gt;--------------------------------------------------------------------------&lt;br /&gt;|   0 | SELECT STATEMENT  |      | 20000 |  3281K|   136   (0)| 00:00:02 |&lt;br /&gt;|*  1 |  TABLE ACCESS FULL| X2   | 20000 |  3281K|   136   (0)| 00:00:02 |&lt;br /&gt;--------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Predicate Information (identified by operation id):&lt;br /&gt;---------------------------------------------------&lt;br /&gt;&lt;br /&gt; 1 - filter("IDN"=U'00000000000000000000000000000009')&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;We have 20,000 rows with unique values in IDN column in the table, we have statistics and still the CBO produces an execution plan with FULL TABLE SCAN and with a very strange estimate of 20,000 rows reurned by this query.&lt;br /&gt;Therefore our first question should be: What is wrong with the statistics? A simple query on USER_TAB_COLS shows the following results:&lt;br /&gt;&lt;div class="codesnippet"&gt;&lt;br /&gt;SQL&gt; select column_name,num_distinct, low_value,high_value from user_tab_cols where table_name='X2';&lt;br /&gt;&lt;br /&gt;COLUMN_NAME                    NUM_DISTINCT LOW_VALUE                                                        HIGH_VALUE&lt;br /&gt;------------------------------ ------------ ---------------------------------------------------------------- ----------------------------------------------------------------&lt;br /&gt;ID                                    20000 3030303030303030303030303030303030303030303030303030303030303031 3030303030303030303030303030303030303030303030303030303230303030&lt;br /&gt;IDN                                       1 0030003000300030003000300030003000300030003000300030003000300030 0030003000300030003000300030003000300030003000300030003000300030&lt;br /&gt;ID16                                  20000 0030003000300030003000300030003000300030003000300030003000300031 0030003000300030003000300030003000300030003000320030003000300030&lt;br /&gt;ID20                                      3 0030003000300030003000300030003000300030003000300030003000300030 0030003000300030003000300030003000300030003000300030003000300032&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;To display raw values I used function developed by &lt;a href="http://askdba.org/weblog/2009/06/dbms_stats-copy_table_stats-does-not-alter-lowhigh-value/"&gt;Greg Rahn&lt;/a&gt; which gives the following result:&lt;br /&gt;&lt;div class="codesnippet"&gt;&lt;br /&gt;SQL&gt; column lo_val format a32&lt;br /&gt;SQL&gt; column hi_val format a32&lt;br /&gt;SQL&gt; select column_name,&lt;br /&gt; 2        num_distinct,&lt;br /&gt; 3        display_raw(low_value,data_type) lo_val,&lt;br /&gt; 4        display_raw(high_value,data_type) hi_val&lt;br /&gt; 5 from user_tab_cols&lt;br /&gt; 6 where table_name='X2';&lt;br /&gt;&lt;br /&gt;COLUMN_NAME                    NUM_DISTINCT LO_VAL                           HI_VAL&lt;br /&gt;------------------------------ ------------ -------------------------------- --------------------------------&lt;br /&gt;ID                                    20000 00000000000000000000000000000001 00000000000000000000000000020000&lt;br /&gt;IDN                                       1  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0&lt;br /&gt;ID16                                  20000  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1  0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0&lt;br /&gt;ID20                                      3  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;We can see that the NUM_DISTINCT column has quite strange values. Reason for this is that Oracle analyzes only first 32 bytes (and not characters) of the string. The default character set for NVARCHAR2 type is AL16UTF16 - a 2 byte character set.&lt;br /&gt;The column IDN was defined as NVARCHAR2(32) and was actually completely filled so every row stores 64 bytes in this column. Here is the proof:&lt;br /&gt;&lt;br /&gt;&lt;div class="codesnippet"&gt;&lt;br /&gt;SQL&gt; select dump(idn) from x2 where rownum = 1;&lt;br /&gt;&lt;br /&gt;DUMP(IDN)&lt;br /&gt;-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------&lt;br /&gt;Typ=1 Len=64: 0,48,0,48,0,48,0,48,0,48,0,48,0,48,0,48,0,48,0,48,0,48,0,48,0,48,0,48,0,48,0,48,0,48,0,48,0,48,0,48,0,48,0,48,0,48,0,48,0,48,0,48,0,48,0,48,0,48,0,48,0,56,0,51&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Due to considering only first &lt;span style="font-weight: bold;"&gt;32 bytes&lt;/span&gt; analyze comes back with a strange result that there is only one distinct value, what is of course true, as all distinct digits are beyond first 32 bytes.&lt;br /&gt;&lt;br /&gt;Let us continue and use DBMS_STATS.GATHER_TABLE_STATS for analysis.&lt;br /&gt;&lt;div class="codesnippet"&gt;&lt;br /&gt;SQL&gt; begin&lt;br /&gt;2    dbms_stats.gather_table_stats(&lt;br /&gt;3    ownname=&gt; user ,&lt;br /&gt;4    tabname=&gt; 'X2',&lt;br /&gt;5    cascade=&gt; TRUE,&lt;br /&gt;6    estimate_percent=&gt; DBMS_STATS.AUTO_SAMPLE_SIZE,&lt;br /&gt;7    degree=&gt; DBMS_STATS.AUTO_DEGREE,&lt;br /&gt;8    no_invalidate=&gt; FALSE,&lt;br /&gt;9    granularity=&gt; 'ALL',&lt;br /&gt;10    method_opt=&gt; 'FOR ALL COLUMNS SIZE AUTO');&lt;br /&gt;11  end;&lt;br /&gt;12  /&lt;br /&gt;&lt;br /&gt;SQL&gt; select column_name,num_distinct,&lt;br /&gt;2         display_raw(low_value,data_type) lo_val,&lt;br /&gt;3         display_raw(high_value,data_type) hi_val&lt;br /&gt;4    from user_tab_cols where table_name='X2'&lt;br /&gt;5  /&lt;br /&gt;&lt;br /&gt;COLUMN_NAME                    NUM_DISTINCT LO_VAL                           HI_VAL&lt;br /&gt;------------------------------ ------------ -------------------------------- --------------------------------&lt;br /&gt;ID                                    19820 00000000000000000000000000000001 00000000000000000000000000020000&lt;br /&gt;IDN                                   20000  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0&lt;br /&gt;ID16                                  20000  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1  0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0&lt;br /&gt;ID20                                  19942  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;DBMS_STATS produces much more reliable cardinalities but the low/high values are still showing only 0 for IDN column. Here there is no difference between ANALYZE and DBMS_STATS as it can't be. Oracle looks only at first 32 bytes and that is the fact.  Therefore the CBO will be not able to properly determine the cardinality for the range predicates. We will look closer this in the continuation of this post.&lt;br /&gt;This fact might become dangerous also for all databases which use multi-byte character set as default character set. Actually Oracle will always look only at first 32 bytes and in case that the column will contain many many multi-byte characters this can become pretty odd. All this is something new and becomes more critical in now days when a lot of databases are migrated from single-byte character set to a multi-byte character sets. For sure migrating to any flavor of UTF-8/AL32UTF8 character set represent such a thread.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Conclusions about statistics for NVARCHAR2 data type&lt;br /&gt;&lt;/span&gt;When I realized what is the reason behind for such behavior I suggested to my customer to switch back to rule based optimizer what solved the problem. The other possibility would be to change all NVARCHAR2 columns to VARCHAR2 but the customer accept this.&lt;br /&gt;First, but the most important conclusion would be &lt;span style="font-weight: bold;"&gt;not to use NVARCHAR2&lt;/span&gt; data type for key columns, but rather VARCHAR2. Or paraphrasing Mogens Norgard: "We don't use NVARCHAR2 data type!" :-)&lt;br /&gt;&lt;br /&gt;*Range cardinalities on columns of NVARCHAR2 data type*&lt;br /&gt;Reason for this part of post is my involvement in one thread on OTN where a lady from Austria, my neighbor country, was complaining about the "strange" execution plans and consequently also "un-wanted" performance. In one mail she explained me that they are experiencing performance problems since they have upgraded from Oracle9i to 10g. She also said that at the same time they moved from VARCHAR2 data type to NVARCHAR2 datatype.&lt;br /&gt;My first impression was that this might be the same situation as I have already explained above. But after digging deeply in the problem, I realized that the problem lies in completely mis-estimated selectivity and consequently also the cardinality when NVARCHAR2 data type column is in question.&lt;br /&gt;&lt;br /&gt;To be able to study the case I prepared an extremely simple reproducible test case. Let us start with the setup of the test environment:      &lt;br /&gt;&lt;br /&gt;&lt;div class="codesnippet"&gt;&lt;br /&gt;SQL&gt; create table x1 (cv varchar2(10), cn nvarchar2(10));&lt;br /&gt;&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;SQL&gt; insert into x1 select lpad(rownum,8,'0'), lpad(rownum,8,'0')&lt;br /&gt;   from dual connect by level &lt;= 20000;   20000 rows created.   SQL&gt; commit;&lt;br /&gt;&lt;br /&gt;Commit complete.&lt;br /&gt;&lt;br /&gt;SQL&gt; select cv,cn from x1 where rownum &lt;= 10;     CV         CN  ---------- ----------  00000469   00000469   00000470   00000470  00000471   00000471  00000472   00000472  00000473   00000473  00000474   00000474  00000475   00000475  00000476   00000476  00000477   00000477  00000478   00000478  10 rows selected.     SQL&gt;  begin&lt;br /&gt;2  dbms_stats.gather_table_stats(&lt;br /&gt;3  ownname=&gt; user ,&lt;br /&gt;4  tabname=&gt; 'X1',&lt;br /&gt;5  cascade=&gt; TRUE,&lt;br /&gt;6  estimate_percent=&gt; DBMS_STATS.AUTO_SAMPLE_SIZE,&lt;br /&gt;7  degree=&gt; DBMS_STATS.AUTO_DEGREE,&lt;br /&gt;8  no_invalidate=&gt; FALSE,&lt;br /&gt;9  granularity=&gt; 'ALL',&lt;br /&gt;10  method_opt=&gt; 'FOR ALL COLUMNS SIZE 1');&lt;br /&gt;11* end;&lt;br /&gt;SQL&gt; /&lt;br /&gt;&lt;br /&gt;PL/SQL procedure successfully completed.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Let us run our first test SQL. I have used bind variables named :a1, :a2 of type VARCHAR2 and :n1, :n2 of type NVARCHAR2. I have event written a simple anonymous PL/SQL block where I selected the values for bind variables from the same table in order to be sure that the binding is done properly. While I was running the tests I enabled events 10053 and 10046.&lt;br /&gt;&lt;br /&gt;&lt;div class="codesnippet"&gt;&lt;br /&gt;SQL&gt; select * from table(dbms_xplan.display_cursor(null,null,'allstats last'));&lt;br /&gt;SQL_ID  1fj17ram77n5w, child number 0&lt;br /&gt;-------------------------------------&lt;br /&gt;select /*+ gather_plan_statistics */ /* run 20 */ *&lt;br /&gt;from x1&lt;br /&gt;where cn &gt;= to_nchar(:a1)&lt;br /&gt;  and cn &lt;= to_nchar(:a2)   Plan hash value: 2189453339  ------------------------------------------------------------------------------------- | Id  | Operation          | Name | Starts | E-Rows | A-Rows |   A-Time   | Buffers | ------------------------------------------------------------------------------------- |*  1 |  FILTER            |      |      1 |        |   9999 |00:00:00.08 |     102 | |*  2 |   TABLE ACCESS FULL| X1   |      1 |      1 |   9999 |00:00:00.03 |     102 | -------------------------------------------------------------------------------------  Predicate Information (identified by operation id): ---------------------------------------------------      1 - filter(SYS_OP_C2C(:A1)&lt;=SYS_OP_C2C(:A2))      2 - filter(("CN"&lt;=SYS_OP_C2C(:A2) AND "CN"&gt;=SYS_OP_C2C(:A1)))&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;PARSING IN CURSOR #12 len=111 dep=0 uid=88 oct=3 lid=88 tim=254514943459 hv=2792607932 ad='23f7056c' sqlid='1fj17ram77n5w'&lt;br /&gt;select /*+ gather_plan_statistics */ /* run 20 */ *&lt;br /&gt;from x1&lt;br /&gt;where cn &gt;= to_nchar(:a1)&lt;br /&gt;  and cn &lt;= to_nchar(:a2) END OF STMT  PARSE #12:c=0,e=734,p=0,cr=0,cu=0,mis=1,r=0,dep=0,og=1,tim=254514943452  BINDS #12:   Bind#0 oacdty=01 mxl=32(10) mxlc=10 mal=00 scl=00 pre=00          oacflg=03 fl2=1000010 frm=01 csi=170 siz=64 off=0          kxsbbbfp=0fec0abc  bln=32  avl=08  flg=05             value="00000000"   Bind#1 oacdty=01 mxl=32(10) mxlc=10 mal=00 scl=00 pre=00          oacflg=03 fl2=1000010 frm=01 csi=170 siz=0 off=32          kxsbbbfp=0fec0adc  bln=32  avl=08  flg=01             value="00009999"  &lt;/div&gt;&lt;br /&gt;I got a hard parse (mis=1), optimizer peeked at the values of bind variables and the estimated cardinality was 1 while the actual one was 9999. From 10046 trace we can clearly see the values of bind variables used by optimizer for the optimization. I used VARCHAR2 type of columns as bind variables but used TO_NCHAR function to convert to NVARCHAR2 data type. The optimizer internally rewrote the SQL so that instead of TO_NCHAR used internal function &lt;a href="http://joze-senegacnik.blogspot.com/2009/12/what-is-purpose-of-sysopc2c-internal.html"&gt;SYS_OP_C2C&lt;/a&gt; which performs conversion from one character set to another.&lt;br /&gt;&lt;br /&gt;&lt;div class="codesnippet"&gt;&lt;br /&gt;SQL&gt; select SYS_OP_C2C('Š') from dual;&lt;br /&gt;&lt;br /&gt;S&lt;br /&gt;-&lt;br /&gt;S&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;For next run I used NVARCHAR2 type bind variables and here is the result:&lt;br /&gt;&lt;div class="codesnippet"&gt;&lt;br /&gt;SQL_ID  d1bn5vyb6dcgn, child number 0&lt;br /&gt;-------------------------------------&lt;br /&gt;select /*+ gather_plan_statistics */ /* run 15 */ *&lt;br /&gt;from x1&lt;br /&gt;where cn &gt;= to_nchar(:n1)&lt;br /&gt;  and cn &lt;= to_nchar(:n2)    Plan hash value: 2189453339  ------------------------------------------------------------------------------------- | Id  | Operation          | Name | Starts | E-Rows | A-Rows |   A-Time   | Buffers | ------------------------------------------------------------------------------------- |*  1 |  FILTER            |      |      1 |        |   9999 |00:00:00.08 |     759 | |*  2 |   TABLE ACCESS FULL| X1   |      1 |     50 |   9999 |00:00:00.04 |     759 | -------------------------------------------------------------------------------------  Predicate Information (identified by operation id): ---------------------------------------------------      1 - filter(:N1&lt;=:N2)          2 - filter(("CN"&gt;=:N1 AND "CN"&lt;=:N2))    PARSING IN CURSOR #15 len=111 dep=0 uid=88 oct=3 lid=88 tim=254434564390 hv=2523312628 ad='2c8d2200' sqlid='d1bn5vyb6dcgn'   select /*+ gather_plan_statistics */ /* run 15 */ *    from x1    where cn &gt;= to_nchar(:n1)&lt;br /&gt;  and cn &lt;= to_nchar(:n2)  END OF STMT  PARSE #15:c=0,e=746,p=0,cr=0,cu=0,mis=1,r=0,dep=0,og=1,tim=254434564383  BINDS #15:   Bind#0   oacdty=01 mxl=128(40) mxlc=20 mal=00 scl=00 pre=00            oacflg=03 fl2=1000010 frm=02 csi=2000 siz=256 off=0            kxsbbbfp=0febbee0  bln=128  avl=16  flg=05    value=""   Bind#1   oacdty=01 mxl=128(40) mxlc=20 mal=00 scl=00 pre=00          oacflg=03 fl2=1000010 frm=02 csi=2000 siz=0 off=128          kxsbbbfp=0febbf60  bln=128  avl=16  flg=01    value="" &lt;/div&gt;&lt;br /&gt;Here we got the estimated number of rows 50 what is exactly the default use by the CBO for ranges - selectivity is 0.0025. So the CBO simply decided to throw in the default selectivity. The values of bind variables are empty ("") - CBO just ignored them during the optimization phase but they were of course respected by the runtime engine. &lt;br /&gt;&lt;br /&gt;&lt;div class="codesnippet"&gt;&lt;br /&gt;SQL_ID  cx88wv0q05tst, child number 0&lt;br /&gt;-------------------------------------&lt;br /&gt;select /*+ gather_plan_statistics */ /* run 14 */ *&lt;br /&gt;from x1&lt;br /&gt;where substr(cn,1,10) &gt;= to_nchar(:a1)&lt;br /&gt;  and substr(cn,1,10) &lt;= to_nchar(:a2)  Plan hash value: 2189453339  ------------------------------------------------------------------------------------- | Id  | Operation          | Name | Starts | E-Rows | A-Rows |   A-Time   | Buffers | ------------------------------------------------------------------------------------- |*  1 |  FILTER            |      |      1 |        |   9999 |00:00:00.09 |     759 | |*  2 |   TABLE ACCESS FULL| X1   |      1 |     50 |   9999 |00:00:00.05 |     759 | -------------------------------------------------------------------------------------  Predicate Information (identified by operation id): ---------------------------------------------------         1 - filter(SYS_OP_C2C(:A1)&lt;=SYS_OP_C2C(:A2))    2 - filter((SUBSTR("CN",1,10)&gt;=SYS_OP_C2C(:A1) AND&lt;br /&gt;             SUBSTR("CN",1,10)&lt;=SYS_OP_C2C(:A2)))     PARSING IN CURSOR #12 len=137 dep=0 uid=88 oct=3 lid=88 tim=254227180414 hv=2415463600 ad='23f7e900' sqlid='f5wapff7zk35h'    select /*+ gather_plan_statistics */ /* run 16 */ *    from x1    where substr(cn,1,10) &gt;= to_nchar(:a1)&lt;br /&gt;  and substr(cn,1,10) &lt;= to_nchar(:a2) END OF STMT  PARSE #12:c=0,e=767,p=0,cr=0,cu=0,mis=1,r=0,dep=0,og=1,tim=254227180407 BINDS #12:      Bind#0   oacdty=01 mxl=32(10) mxlc=10 mal=00 scl=00 pre=00             oacflg=03 fl2=1000010 frm=01 csi=170 siz=64 off=0             kxsbbbfp=0ff75ac0  bln=32  avl=08  flg=05             value="00000000"      Bind#1   oacdty=01 mxl=32(10) mxlc=10 mal=00 scl=00 pre=00             oacflg=03 fl2=1000010 frm=01 csi=170 siz=0 off=32             kxsbbbfp=0ff75ae0  bln=32  avl=08  flg=01             value="00009999"  &lt;/div&gt;&lt;br /&gt;In this case I added used SUBSTR function on the column and VARCHAR2 type bind variables and again the CBO threw in the default for range 0.0025, but we can see the values of bind variables.&lt;br /&gt;&lt;br /&gt;&lt;div class="codesnippet"&gt;&lt;br /&gt;SQL_ID  auyacfyb6bj9r, child number 0&lt;br /&gt;-------------------------------------&lt;br /&gt;select /*+ gather_plan_statistics */ /* run 14 */ *&lt;br /&gt;  from x1&lt;br /&gt; where substr(cn,1,10) &gt;= to_nchar(:n1)&lt;br /&gt;   and substr(cn,1,10) &lt;= to_nchar(:n2)  Plan hash value: 2189453339  ------------------------------------------------------------------------------------- | Id  | Operation          | Name | Starts | E-Rows | A-Rows |   A-Time   | Buffers | ------------------------------------------------------------------------------------- |*  1 |  FILTER            |      |      1 |        |   9999 |00:00:00.09 |     759 | |*  2 |   TABLE ACCESS FULL| X1   |      1 |     50 |   9999 |00:00:00.05 |     759 | -------------------------------------------------------------------------------------  Predicate Information (identified by operation id): ---------------------------------------------------      1 - filter(:N1&lt;=:N2)      2 - filter((SUBSTR("CN",1,10)&gt;=:N1 AND SUBSTR("CN",1,10)&lt;=:N2))    PARSING IN CURSOR #16 len=137 dep=0 uid=88 oct=3 lid=88 tim=254203929826 hv=1230940210 ad='23f78074' sqlid='13u552p4pxa1k'    select /*+ gather_plan_statistics */ /* run 15 */ *     from x1         where substr(cn,1,10) &gt;= to_nchar(:n1)&lt;br /&gt;    and substr(cn,1,10) &lt;= to_nchar(:n2)  END OF STMT  PARSE #16:c=0,e=770,p=0,cr=0,cu=0,mis=1,r=0,dep=0,og=1,tim=254203929819  BINDS #16:      Bind#0   oacdty=01 mxl=128(40) mxlc=20 mal=00 scl=00 pre=00             oacflg=03 fl2=1000010 frm=02 csi=2000 siz=256 off=0             kxsbbbfp=10460bd0  bln=128  avl=16  flg=05                value=""     Bind#1   oacdty=01 mxl=128(40) mxlc=20 mal=00 scl=00 pre=00             oacflg=03 fl2=1000010 frm=02 csi=2000 siz=0 off=128             kxsbbbfp=10460c50  bln=128  avl=16  flg=01             value=""  &lt;/div&gt;&lt;br /&gt;In the CBO trace the inforamation was:&lt;br /&gt;&lt;div class="codesnippet"&gt;&lt;br /&gt;*******************************************              &lt;br /&gt;Peeked values of the binds in SQL statement              &lt;br /&gt;*******************************************              &lt;br /&gt;----- Bind Info (kkscoacd) -----                         &lt;br /&gt;Bind#0                                                  &lt;br /&gt;oacdty=01 mxl=32(20) mxlc=10 mal=00 scl=00 pre=00      &lt;br /&gt;oacflg=03 fl2=1000010 frm=02 csi=2000 siz=64 off=0     &lt;br /&gt;kxsbbbfp=0f1f5a1c  bln=32  avl=16  flg=05              &lt;br /&gt;value=""                                               &lt;br /&gt;Bind#1                                                  &lt;br /&gt;oacdty=01 mxl=32(20) mxlc=10 mal=00 scl=00 pre=00      &lt;br /&gt;oacflg=03 fl2=1000010 frm=02 csi=2000 siz=0 off=32     &lt;br /&gt;kxsbbbfp=0f1f5a3c  bln=32  avl=16  flg=01              &lt;br /&gt;value=""                                               &lt;br /&gt;&lt;/div&gt;&lt;br /&gt;In the last case I just changed from VARCHAR2 to NVARCHAR2 bind variables and the result was expected - the default selectivity and the values of bind variables were again "".&lt;br /&gt;&lt;br /&gt;Every time, when the CBO used binds for estimating selectivity I could see the following section after the execution plan:&lt;br /&gt;&lt;div class="codesnippet"&gt;&lt;br /&gt;Peeked Binds                             &lt;br /&gt;============                             &lt;br /&gt;Bind variable information              &lt;br /&gt;  position=1                           &lt;br /&gt;  datatype(code)=1                     &lt;br /&gt;  datatype(string)=VARCHAR2(32)        &lt;br /&gt;  char set id=170                      &lt;br /&gt;  char format=1                        &lt;br /&gt;  max length=32                        &lt;br /&gt;  value=00000000                       &lt;br /&gt;Bind variable information              &lt;br /&gt;  position=2                           &lt;br /&gt;  datatype(code)=1                     &lt;br /&gt;  datatype(string)=VARCHAR2(32)        &lt;br /&gt;  char set id=170                      &lt;br /&gt;  char format=1                        &lt;br /&gt;  max length=32                        &lt;br /&gt;  value=00009999                       &lt;br /&gt;Outline Data:                          &lt;br /&gt;/*+                                    &lt;br /&gt;  BEGIN_OUTLINE_DATA                   &lt;br /&gt;    IGNORE_OPTIM_EMBEDDED_HINTS        &lt;br /&gt;    OPTIMIZER_FEATURES_ENABLE('11.1.0.6')&lt;br /&gt;    DB_VERSION('11.1.0.6')             &lt;br /&gt;    ALL_ROWS                           &lt;br /&gt;    OUTLINE_LEAF(@"SEL$1")             &lt;br /&gt;    FULL(@"SEL$1" "X1"@"SEL$1")        &lt;br /&gt;  END_OUTLINE_DATA                     &lt;br /&gt;*/                                     &lt;br /&gt;&lt;/div&gt;&lt;br /&gt;And finally one case with VARCHAR2 data type.&lt;br /&gt;&lt;div class="codesnippet"&gt;&lt;br /&gt;SQL_ID  bznnx6zk4hm11, child number 0&lt;br /&gt;-------------------------------------&lt;br /&gt;select /*+ gather_plan_statistics */ /* run 22 */ *&lt;br /&gt;from x1 where cv &gt;=:a1&lt;br /&gt; and cv &lt;= :a2  Plan hash value: 2189453339  ------------------------------------------------------------------------------------- | Id  | Operation          | Name | Starts | E-Rows | A-Rows |   A-Time   | Buffers | ------------------------------------------------------------------------------------- |*  1 |  FILTER            |      |      1 |        |   9999 |00:00:00.07 |     102 | |*  2 |   TABLE ACCESS FULL| X1   |      1 |   9999 |   9999 |00:00:00.02 |     102 | -------------------------------------------------------------------------------------  Predicate Information (identified by operation id): ---------------------------------------------------        1 - filter(:A1&lt;=:A2)       2 - filter(("CV"&lt;=:A2 AND "CV"&gt;=:A1))&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;PARSING IN CURSOR #13 len=89 dep=0 uid=88 oct=3 lid=88 tim=265619391820 hv=3829943329 ad='2e0c3568' sqlid='bznnx6zk4hm11'&lt;br /&gt;select /*+ gather_plan_statistics */ /* run 22 */ *&lt;br /&gt;from x1&lt;br /&gt;where cv &gt;= :a1&lt;br /&gt; and cv &lt;= :a2 END OF STMT  PARSE #13:c=0,e=762,p=0,cr=0,cu=0,mis=1,r=0,dep=0,og=1,tim=265619391813  BINDS #13:      Bind#0   oacdty=01 mxl=32(10) mxlc=10 mal=00 scl=00 pre=00             oacflg=03 fl2=1000010 frm=01 csi=170 siz=64 off=0                kxsbbbfp=0fec0abc  bln=32  avl=08  flg=05                value="00000000"      Bind#1   oacdty=01 mxl=32(10) mxlc=10 mal=00 scl=00 pre=00             oacflg=03 fl2=1000010 frm=01 csi=170 siz=0 off=32             kxsbbbfp=0fec0adc  bln=32  avl=08  flg=01    value="00009999" &lt;/div&gt;&lt;br /&gt;In this last case I was querying the VARCHAR2 column and using bind variables of VARCHAR2 type and this time the optimizer estimated cardinality correctly. Of course it performed peeking at the values of bind variables.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://oracle-randolf.blogspot.com/"&gt;Randolf Geist&lt;/a&gt; responded to my post on OTN and he suggested to confuse the CBO by using values like 'A0000000' to 'A00009999'. According to his observations also the selectivity for range predicates on VARCHAR2 data types is quite off after using this trick. Building a histogram returns things back to normal on both data types.&lt;br /&gt;He pointed out that the CBO is obviously so smart to spot stored digits in VARCHAR2 columns and do good estimations by treating them as numbers while this is not true for the VARCHAR2 data type.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;CONCLUSION&lt;/span&gt;&lt;br /&gt;It is obvious that the CBO is not capable to perforem same estimates for ranges on NVARCHAR2 column as it is capable to do on VARCHAR2 column when numbers are stored as strings.&lt;br /&gt;But the most important conclusion to be made is that one should use *appropriate* data types.&lt;br /&gt;&lt;br /&gt;Of course that are many possibilities that the CBO might behave differently (like using DYNAMIC_SAMPLING, ...). So I am looking forward for the contributions of others, not just &lt;a href="http://oracle-randolf.blogspot.com/"&gt;Randolf Geist&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;This case was used to raise SR #3-1193039441:  CBO and nvarchar2 --&gt; A new Bug: 9220704  has been filed with development.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
&lt;/script&gt;
&lt;script type="text/javascript"&gt;
try {
var pageTracker = _gat._getTracker("UA-5265495-3");
pageTracker._trackPageview();
} catch(err) {}&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3116559472841364402-2935026310034006569?l=joze-senegacnik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://joze-senegacnik.blogspot.com/feeds/2935026310034006569/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://joze-senegacnik.blogspot.com/2009/12/cbo-oddities-in-determing-selectivity.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/2935026310034006569'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/2935026310034006569'/><link rel='alternate' type='text/html' href='http://joze-senegacnik.blogspot.com/2009/12/cbo-oddities-in-determing-selectivity.html' title='CBO oddities in determining selectivity on NVARCHAR2 data type'/><author><name>Jože Senegačnik - Joc</name><uri>http://www.blogger.com/profile/10478214001612631485</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://4.bp.blogspot.com/_SOd0WN7CXgU/Svv9TjGM0lI/AAAAAAAAAU8/xGVOpqkTFDY/S220/joc_with_piper.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3116559472841364402.post-5330087199856620471</id><published>2009-12-07T17:06:00.005+01:00</published><updated>2009-12-07T17:28:15.014+01:00</updated><title type='text'>What is the purpose of SYS_OP_C2C internal function</title><content type='html'>Recently I was involved in one problem with CBO's selectivity estimations on NVARCHAR2 data type column. What I spotted in predicate information was the usage of internal Oracle function SYS_OP_C2C.&lt;br /&gt;&lt;br /&gt;Here is an example of the run-time execution plan using bind variables:  &lt;br /&gt;&lt;div class="codesnippet"&gt;&lt;br /&gt;&lt;br /&gt;SQL_ID  1fj17ram77n5w, child number 0&lt;br /&gt;-------------------------------------&lt;br /&gt;  select /*+ gather_plan_statistics */ * &lt;br /&gt;  from x1 where cn &gt;= to_nchar(:a1) and cn &lt;= to_nchar(:a2)&lt;br /&gt;&lt;br /&gt;Plan hash value: 2189453339&lt;br /&gt;&lt;br /&gt;-------------------------------------------------------------------------------------&lt;br /&gt;| Id  | Operation          | Name | Starts | E-Rows | A-Rows |   A-Time   | Buffers |&lt;br /&gt;-------------------------------------------------------------------------------------&lt;br /&gt;|*  1 |  FILTER            |      |      1 |        |   9999 |00:00:00.08 |     102 |&lt;br /&gt;|*  2 |   TABLE ACCESS FULL| X1   |      1 |      1 |   9999 |00:00:00.03 |     102 |&lt;br /&gt;-------------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Predicate Information (identified by operation id):&lt;br /&gt;---------------------------------------------------&lt;br /&gt;&lt;br /&gt;   1 - filter(SYS_OP_C2C(:A1)&lt;=SYS_OP_C2C(:A2))&lt;br /&gt;   2 - filter(("CN"&lt;=SYS_OP_C2C(:A2) AND "CN"&gt;=SYS_OP_C2C(:A1)))&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;As you can see the bind variables are converted to national character set using TO_NCHAR function. Column X1.CN is of type NVARCHAR2. It is easy to spot the difference between the SQL statement and the predicate information from the execution plan: &lt;span style="font-weight:bold;"&gt;to_nchar(:a2)&lt;/span&gt; from SQL statement is transformed to &lt;span style="font-weight:bold;"&gt;SYS_OP_C2C(:A2)&lt;/span&gt; in predicate information. The internal Oracle function &lt;span style="font-weight:bold;"&gt;SYS_OP_C2C&lt;/span&gt; performs conversion from one character set to another character set - C(haracterSet)2C(haracterSet). There are situations when one will see this conversion going on without explicit command as in this case what should be a sign that the data types are not the same and implicit conversion is taking place and this might be also a problem from performance perspective as it may disable index usage.&lt;br /&gt;&lt;br /&gt;Jonathan Lewis and Charles Hooper, my fellows from the OakTable, had a &lt;a href="http://jonathanlewis.wordpress.com/2007/07/29/nls/"&gt;discussion about this internal function&lt;/a&gt; back in 2007.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
&lt;/script&gt;
&lt;script type="text/javascript"&gt;
try {
var pageTracker = _gat._getTracker("UA-5265495-3");
pageTracker._trackPageview();
} catch(err) {}&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3116559472841364402-5330087199856620471?l=joze-senegacnik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://joze-senegacnik.blogspot.com/feeds/5330087199856620471/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://joze-senegacnik.blogspot.com/2009/12/what-is-purpose-of-sysopc2c-internal.html#comment-form' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/5330087199856620471'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/5330087199856620471'/><link rel='alternate' type='text/html' href='http://joze-senegacnik.blogspot.com/2009/12/what-is-purpose-of-sysopc2c-internal.html' title='What is the purpose of SYS_OP_C2C internal function'/><author><name>Jože Senegačnik - Joc</name><uri>http://www.blogger.com/profile/10478214001612631485</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://4.bp.blogspot.com/_SOd0WN7CXgU/Svv9TjGM0lI/AAAAAAAAAU8/xGVOpqkTFDY/S220/joc_with_piper.jpg'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3116559472841364402.post-2848723603682791835</id><published>2009-12-05T22:28:00.025+01:00</published><updated>2009-12-12T23:13:28.326+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='wait event'/><category scheme='http://www.blogger.com/atom/ns#' term='event 10046'/><category scheme='http://www.blogger.com/atom/ns#' term='dbms_monitor'/><category scheme='http://www.blogger.com/atom/ns#' term='trace file'/><title type='text'>Measurement Error Trap In Trace File (event 10046)</title><content type='html'>&lt;div style="text-align: left;"&gt;&lt;br /&gt;Some time ago I had an interesting case which I can use to clearly describe how one can be caught in measurement error trap.&lt;br /&gt;&lt;br /&gt;But let us start at the beginning with this response time analysis:&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;" class="codesnippet"&gt;&lt;br /&gt;Response Time Component                     Time      % Elap   AvgEla&lt;br /&gt;---------------------------------------- ----------- ------- ---------&lt;br /&gt;CPU service                                 3934.97s  48.39%  0.000716&lt;br /&gt;un-accounted for time                       1363.01s  16.76%&lt;br /&gt;db file sequential read                     1122.00s  13.80%  &lt;span style="font-weight: bold;"&gt;0.032253&lt;/span&gt;&lt;br /&gt;gc buffer busy                               451.73s   5.56%  0.011746&lt;br /&gt;log buffer space                             451.64s   5.55%  0.123974&lt;br /&gt;buffer busy waits                            176.79s   2.17%  0.029579&lt;br /&gt;gc cr block 2-way                            156.49s   1.92%  0.003287&lt;br /&gt;gc cr grant 2-way                            100.20s   1.23%  0.006541&lt;br /&gt;latch: cache buffers chains                   98.92s   1.22%  0.005708&lt;br /&gt;gc current grant 2-way                        69.68s   0.86%  0.006728&lt;br /&gt;latch: library cache                          30.10s   0.37%  0.010030&lt;br /&gt;row cache lock                                28.95s   0.36%  0.018727&lt;br /&gt;gc current block 2-way                        26.72s   0.33%  0.003828&lt;br /&gt;gc cr block busy                              19.35s   0.24%  0.006802&lt;br /&gt;gc current grant busy                         15.30s   0.19%  0.004999&lt;br /&gt;latch: row cache objects                      14.28s   0.18%  0.006165&lt;br /&gt;gc cr block 3-way                             11.73s   0.14%  0.002952&lt;br /&gt;gc current block 3-way                        11.34s   0.14%  0.003440&lt;br /&gt;log file sync                                 10.71s   0.13%  0.315066&lt;br /&gt;enq: SQ - contention                           9.14s   0.11%  0.060911&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;My first thought was that there is an I/O problem as the average single block I/O took 32 milliseconds.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_SOd0WN7CXgU/SxtirXsUw0I/AAAAAAAABIo/QS7mSEhsdFk/s1600-h/Picture1.jpg"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 320px; height: 219px;" src="http://3.bp.blogspot.com/_SOd0WN7CXgU/SxtirXsUw0I/AAAAAAAABIo/QS7mSEhsdFk/s320/Picture1.jpg" alt="" id="BLOGGER_PHOTO_ID_5412027874449605442" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt; &lt;/div&gt;&lt;p style="text-align: left;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="text-align: left;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="text-align: left;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="text-align: left;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="text-align: left;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="text-align: left;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="text-align: left;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="text-align: left;"&gt;After digging for a while I have produced the following graphs which represent the I/O timing.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="text-align: left;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_SOd0WN7CXgU/SxtirhVmeaI/AAAAAAAABIw/jDMot1jLm4w/s1600-h/Picture2.jpg"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 320px; height: 219px;" src="http://2.bp.blogspot.com/_SOd0WN7CXgU/SxtirhVmeaI/AAAAAAAABIw/jDMot1jLm4w/s320/Picture2.jpg" alt="" id="BLOGGER_PHOTO_ID_5412027877038651810" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="text-align: left;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="text-align: left;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="text-align: left;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="text-align: left;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="text-align: left;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="text-align: left;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="text-align: left;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="text-align: left;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="text-align: left;"&gt;Let's first look at some facts:&lt;br /&gt;- 3 node RAC&lt;br /&gt;- Same storage&lt;br /&gt;- Single block read time for Instance 1 was substantially different from read times for other instances during off hours&lt;br /&gt;- 5 batch jobs during off hours&lt;br /&gt;- The timings for Instance 1 are obviously not correct&lt;br /&gt;&lt;br /&gt;I used the fact that I was performing the analysis on a 3 node RAC to check what are the timings on other two nodes and as you can see from the second graph, they were quite different.&lt;br /&gt;&lt;br /&gt;Here is now the explanation:&lt;br /&gt;&lt;br /&gt;The output from strace showed:&lt;br /&gt;&lt;/p&gt;&lt;div style="text-align: left;" class="codesnippet"&gt;&lt;br /&gt;gettimeofday({1159440978, 931945}, NULL) = 0&lt;br /&gt;pread(14, "\6\242\0\0\375\23\0\2+\254.\0\0\0\1\6\0054\0\0\1\0\5\0"..., 8192, 455 057408) = 8192&lt;br /&gt;gettimeofday({1159440978, 944159}, NULL) = 0&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Oracle records  time just before performing a system call (pread). When the system call completes Oracle again records the current time and the difference reports as a wait time. Unfortunately due to high CPU load the process was for quite a while waiting at the system level to get on CPU and  only then was able to read the current time and therefore the reported elapsed time was quite exaggerated.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Conclusion: Waiting in runque for CPU exaggerates all wait times of the process.&lt;br /&gt;&lt;br /&gt;It is always a good practice to confirm findings with a different method. In this case I could use also the operating system tools to measure I/O timings. The same situation one can have on any other kind of wait event but there is not always a possibility to check it independently.&lt;br /&gt;&lt;br /&gt;Finally, there was not really an I/O problem but the system was quite CPU bound. Of course the average single block I/O time over 5 - 10 ms shows that probably we are experiencing also I/O bottleneck.  The customer later on replaced disk storage with a faster one together with the HW used for RAC. &lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
&lt;/script&gt;
&lt;script type="text/javascript"&gt;
try {
var pageTracker = _gat._getTracker("UA-5265495-3");
pageTracker._trackPageview();
} catch(err) {}&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3116559472841364402-2848723603682791835?l=joze-senegacnik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://joze-senegacnik.blogspot.com/feeds/2848723603682791835/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://joze-senegacnik.blogspot.com/2009/12/measurement-error-in-trace-file.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/2848723603682791835'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/2848723603682791835'/><link rel='alternate' type='text/html' href='http://joze-senegacnik.blogspot.com/2009/12/measurement-error-in-trace-file.html' title='Measurement Error Trap In Trace File (event 10046)'/><author><name>Jože Senegačnik - Joc</name><uri>http://www.blogger.com/profile/10478214001612631485</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://4.bp.blogspot.com/_SOd0WN7CXgU/Svv9TjGM0lI/AAAAAAAAAU8/xGVOpqkTFDY/S220/joc_with_piper.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_SOd0WN7CXgU/SxtirXsUw0I/AAAAAAAABIo/QS7mSEhsdFk/s72-c/Picture1.jpg' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3116559472841364402.post-3787005554516631774</id><published>2009-12-03T10:40:00.009+01:00</published><updated>2009-12-05T07:36:18.741+01:00</updated><title type='text'>V$SQL_MONITOR and V$SQL_PLAN_MONITOR</title><content type='html'>In my recent presentation at UKOUG 2009 in Birmingham I also mentioned the new feature of Oracle11gR1 which is a neat solution for monitoring long running SQL statements. It captures statistics about SQL execution every second.&lt;br /&gt;&lt;br /&gt;For parallel execution every process involved gets separate entries in V$SQL_MONITOR and V$SQL_PLAN_MONITOR.&lt;br /&gt;&lt;br /&gt;It is enabled by default for long running statements if parameter CONTROL_MANAGEMENT_PACK_ACCESS if it is set  to “DIAGNOSTIC+TUNING” and STATISTICS_LEVEL=ALL|TYPICAL&lt;br /&gt;&lt;br /&gt;It can be enabled at statement level as well with /*+ MONITOR */ hint or disabled with /*+ NO_MONITOR */ hint.&lt;br /&gt;&lt;br /&gt;There are some defaults defined which can be altered by setting hidden parameters:&lt;br /&gt;_sqlmon_max_plan - Maximum number of plans entries that can be monitored. Defaults to 20 per CPU&lt;br /&gt;_sqlmon_max_planlines - Number of plan lines beyond which a plan cannot be monitored (default 300) &lt;br /&gt;&lt;br /&gt;Just for demonstration purposes I used a simple performance killing statement which runs quite for a while and could be used to test this new feature.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="codesnippet"&gt;&lt;br /&gt;SQL_ID  b0zm3w4h1hbff, child number 0&lt;br /&gt;-------------------------------------&lt;br /&gt;select count(*) from obj$,obj$,obj$     --performance killer&lt;br /&gt;&lt;br /&gt;Plan hash value: 3679021907&lt;br /&gt;&lt;br /&gt;----------------------------------------------------&lt;br /&gt;| Id  | Operation                | Name   | E-Rows |&lt;br /&gt;----------------------------------------------------&lt;br /&gt;|   1 |  SORT AGGREGATE          |        |      1 |&lt;br /&gt;|   2 |   MERGE JOIN CARTESIAN   |        |    341T|&lt;br /&gt;|   3 |    MERGE JOIN CARTESIAN  |        |   4886M|&lt;br /&gt;|   4 |     INDEX FAST FULL SCAN | I_OBJ1 |  69901 |&lt;br /&gt;|   5 |     BUFFER SORT          |        |  69901 |&lt;br /&gt;|   6 |      INDEX FAST FULL SCAN| I_OBJ1 |  69901 |&lt;br /&gt;|   7 |    BUFFER SORT           |        |  69901 |&lt;br /&gt;|   8 |     INDEX FAST FULL SCAN | I_OBJ1 |  69901 |&lt;br /&gt;----------------------------------------------------&lt;br /&gt;&lt;br /&gt;SQL&gt; SELECT status, KEY, SID, sql_id, elapsed_time, cpu_time, fetches, buffer_gets,&lt;br /&gt; 2         disk_reads&lt;br /&gt; 3    FROM v$sql_monitor where sql_id='b0zm3w4h1hbff';&lt;br /&gt;&lt;br /&gt;STATUS            KEY SID SQL_ID        ELAPSED_TIME   CPU_TIME FETCHES BUFFER_GETS DISK_READS&lt;br /&gt;--------- ----------- --- ------------- ------------ ---------- ------- ----------- ----------&lt;br /&gt;EXECUTING 21474836481 170 b0zm3w4h1hbff    674281628  624578125       0           0          0&lt;br /&gt;&lt;br /&gt;SQL&gt; SELECT   plan_line_id, plan_operation || ' ' || plan_options operation,&lt;br /&gt; 2           starts, output_rows&lt;br /&gt; 3      FROM v$sql_plan_monitor where key=21474836481&lt;br /&gt; 4  ORDER BY plan_line_id;&lt;br /&gt;&lt;br /&gt;PLAN_LINE_ID OPERATION                 STARTS OUTPUT_ROWS&lt;br /&gt;------------ --------------------- ---------- -----------&lt;br /&gt;          0 SELECT STATEMENT               1           0&lt;br /&gt;          1 SORT AGGREGATE                 1           0&lt;br /&gt;          2 MERGE JOIN CARTESIAN           1  4283731363&lt;br /&gt;          3 MERGE JOIN CARTESIAN           1      156731&lt;br /&gt;          4 INDEX FAST FULL SCAN           1           3&lt;br /&gt;          5 BUFFER SORT                    3      156731&lt;br /&gt;          6 INDEX FAST FULL SCAN           1       70088&lt;br /&gt;          7 BUFFER SORT               156731  4283731363&lt;br /&gt;          8 INDEX FAST FULL SCAN           1       70088&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The above result I got after running this statement for about 10 minutes. There are of course more statistics available which I have omitted here as they were useless for my demo case which had all data already in buffer cache.&lt;br /&gt;&lt;br /&gt;One can use DBMS_SQLTUNE.REPORT_SQL_MONITOR() function to produce a formatted report of monitoring results. Unfortunately the below report is too wide to be cleary seen. I got it for a statement run by DBMS_STATS package&lt;br /&gt;&lt;br /&gt;&lt;div class="codesnippet"&gt;&lt;br /&gt;SQL&gt; set long 10000000&lt;br /&gt;SQL&gt; set longchunksize 10000000&lt;br /&gt;SQL&gt; set linesize 200&lt;br /&gt;SQL&gt; select dbms_sqltune.report_sql_monitor from dual;&lt;br /&gt;&lt;br /&gt;SQL Monitoring Report&lt;br /&gt;&lt;br /&gt;SQL Text&lt;br /&gt;-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------&lt;br /&gt;select /*+ no_parallel_index(t, "I_WRI$_OPTSTAT_H_OBJ#_ICOL#_ST") dbms_stats cursor_sharing_exact use_weak_name_resl dynamic_sampling(0) no_monitoring no_expand&lt;br /&gt;index(t,"I_WRI$_OPTSTAT_H_OBJ#_ICOL#_ST") */ count(*) as nrw,count(distinct sys_op_lbid(461,'L',t.rowid)) as nlb,count(distinct&lt;br /&gt;hextoraw(sys_op_descend("OBJ#")||sys_op_descend("INTCOL#")||sys_op_descend(SYS_EXTRACT_UTC("SAVTIME"))||sys_op_descend("COLNAME"))) as ndk,sys_op_countchg(substrb(t.rowid,1,15),1)&lt;br /&gt;as clf from "SYS"."WRI$_OPTSTAT_HISTGRM_HISTORY" t where "OBJ#" is not null or "INTCOL#" is not null or SYS_EXTRACT_UTC("SAVTIME") is not null or "COLNAME" is not null&lt;br /&gt;-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Global Information&lt;br /&gt;&lt;br /&gt;Status              :  DONE (ALL ROWS)&lt;br /&gt;Instance ID         :  1&lt;br /&gt;Session ID          :  127&lt;br /&gt;SQL ID              :  1d7qn8b9wam8h&lt;br /&gt;SQL Execution ID    :  16777216&lt;br /&gt;Plan Hash Value     :  3428983716&lt;br /&gt;Execution Started   :  12/04/2009 01:09:20&lt;br /&gt;First Refresh Time  :  12/04/2009 01:09:28&lt;br /&gt;Last Refresh Time   :  12/04/2009 01:09:30&lt;br /&gt;&lt;br /&gt;--------------------------------------------------------------------&lt;br /&gt;| Elapsed |   Cpu   |    IO    |  Other   | Fetch | Buffer | Reads |&lt;br /&gt;| Time(s) | Time(s) | Waits(s) | Waits(s) | Calls |  Gets  |       |&lt;br /&gt;--------------------------------------------------------------------&lt;br /&gt;|    8.65 |    1.94 |     6.58 |     0.13 |     1 |   1327 |   694 |&lt;br /&gt;--------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL Plan Monitoring Details&lt;br /&gt;=========================================================================================================================================================================&lt;br /&gt;| Id |     Operation      |              Name              |  Rows   | Cost |   Time    | Start  | Starts |   Rows   | Memory | Activity  |       Activity Detail       |&lt;br /&gt;|    |                    |                                | (Estim) |      | Active(s) | Active |        | (Actual) | (Max)  | (percent) |         (sample #)          |&lt;br /&gt;=========================================================================================================================================================================&lt;br /&gt;|  0 | SELECT STATEMENT   |                                |         | 1026 |         1 |    +10 |      1 |        1 |   274K |           |                             |&lt;br /&gt;|  1 |   SORT GROUP BY    |                                |       1 |      |         6 |     +5 |      1 |        1 |   274K |     37.50 | Cpu (3)                     |&lt;br /&gt;|  2 |    INDEX FULL SCAN | I_WRI$_OPTSTAT_H_OBJ#_ICOL#_ST |    179K | 1026 |         8 |     +3 |      1 |     179K |        |     62.50 | db file sequential read (5) |&lt;br /&gt;=========================================================================================================================================================================&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
&lt;/script&gt;
&lt;script type="text/javascript"&gt;
try {
var pageTracker = _gat._getTracker("UA-5265495-3");
pageTracker._trackPageview();
} catch(err) {}&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3116559472841364402-3787005554516631774?l=joze-senegacnik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://joze-senegacnik.blogspot.com/feeds/3787005554516631774/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://joze-senegacnik.blogspot.com/2009/12/vsqlmonitor-and-vsqlplanmonitor.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/3787005554516631774'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/3787005554516631774'/><link rel='alternate' type='text/html' href='http://joze-senegacnik.blogspot.com/2009/12/vsqlmonitor-and-vsqlplanmonitor.html' title='V$SQL_MONITOR and V$SQL_PLAN_MONITOR'/><author><name>Jože Senegačnik - Joc</name><uri>http://www.blogger.com/profile/10478214001612631485</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://4.bp.blogspot.com/_SOd0WN7CXgU/Svv9TjGM0lI/AAAAAAAAAU8/xGVOpqkTFDY/S220/joc_with_piper.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3116559472841364402.post-388933295616319802</id><published>2009-11-28T03:12:00.007+01:00</published><updated>2009-12-02T05:52:05.763+01:00</updated><title type='text'>My interview at Miracle Open World 2008 in Lalandia, Denmark</title><content type='html'>Just for fun I post here two videos related to my presentation at Miracle Open World 2008 in Lalandia, Denmark. I had a presentation titled "Cost Based Optimizer Falacies Caused By The Application Design".&lt;br /&gt;This is a short video where I announce my presentation at Miracle Open World 2008. I took this video while I was baking pizzas for my grandchildren. The oven is homemade and if you are interested you can see &lt;a href="http://senegacnik.blogspot.com/2009/11/my-pizza-oven-at-home.html"&gt;more details&lt;/a&gt; how I have built it.&lt;br /&gt;&lt;br /&gt;&lt;object width="425" height="344"&gt;&lt;param name="movie" value="http://www.youtube.com/v/fKdXHBRLJz4&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;"&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;embed src="http://www.youtube.com/v/fKdXHBRLJz4&amp;hl=en_US&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;After the presentation I was interviewed by Mogens Norgard and if you know him then you can expect that he was trying to make this short interview very amusing.&lt;br /&gt;&lt;br /&gt;&lt;object width="425" height="344"&gt;&lt;param name="movie" value="http://www.youtube.com/v/JKHvWnr1rqw&amp;amp;hl=en_US&amp;amp;fs=1&amp;amp;"&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;embed src="http://www.youtube.com/v/JKHvWnr1rqw&amp;hl=en_US&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
&lt;/script&gt;
&lt;script type="text/javascript"&gt;
try {
var pageTracker = _gat._getTracker("UA-5265495-3");
pageTracker._trackPageview();
} catch(err) {}&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3116559472841364402-388933295616319802?l=joze-senegacnik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://joze-senegacnik.blogspot.com/feeds/388933295616319802/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://joze-senegacnik.blogspot.com/2009/11/my-interview-at-miracle-open-world-2008.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/388933295616319802'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/388933295616319802'/><link rel='alternate' type='text/html' href='http://joze-senegacnik.blogspot.com/2009/11/my-interview-at-miracle-open-world-2008.html' title='My interview at Miracle Open World 2008 in Lalandia, Denmark'/><author><name>Jože Senegačnik - Joc</name><uri>http://www.blogger.com/profile/10478214001612631485</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://4.bp.blogspot.com/_SOd0WN7CXgU/Svv9TjGM0lI/AAAAAAAAAU8/xGVOpqkTFDY/S220/joc_with_piper.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3116559472841364402.post-2276831533863854776</id><published>2009-11-24T19:41:00.000+01:00</published><updated>2009-11-24T19:48:46.301+01:00</updated><title type='text'>RMOUG Training days 2010</title><content type='html'>I'm very proud to participate again in one of the greates conferences on the world - RMOUG Training Days 2010, February 16-18, 2010 at Denver, Colorado, USA.&lt;br /&gt;&lt;br /&gt;You can find the conference agenda &lt;a href="http://www.technicalconferencesolutions.com/pls/caat/caat_abstract_reports.schedule?conference_id=62"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;I will have two presentations:&lt;br /&gt;&lt;br /&gt;1.) &lt;a href="http://www.technicalconferencesolutions.com/pls/caat/caat_abstract_reports.display_presenter_abstract?conference_id=62&amp;amp;presenter_id=68&amp;amp;abstract_id=195"&gt;Rman Tips&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;2.) &lt;a href="http://www.technicalconferencesolutions.com/pls/caat/caat_abstract_reports.display_presenter_abstract?conference_id=62&amp;amp;presenter_id=68&amp;amp;abstract_id=199"&gt;Services - Why Should One Use Them?&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
&lt;/script&gt;
&lt;script type="text/javascript"&gt;
try {
var pageTracker = _gat._getTracker("UA-5265495-3");
pageTracker._trackPageview();
} catch(err) {}&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3116559472841364402-2276831533863854776?l=joze-senegacnik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://joze-senegacnik.blogspot.com/feeds/2276831533863854776/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://joze-senegacnik.blogspot.com/2009/11/rmoug-training-days-2010.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/2276831533863854776'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/2276831533863854776'/><link rel='alternate' type='text/html' href='http://joze-senegacnik.blogspot.com/2009/11/rmoug-training-days-2010.html' title='RMOUG Training days 2010'/><author><name>Jože Senegačnik - Joc</name><uri>http://www.blogger.com/profile/10478214001612631485</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://4.bp.blogspot.com/_SOd0WN7CXgU/Svv9TjGM0lI/AAAAAAAAAU8/xGVOpqkTFDY/S220/joc_with_piper.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3116559472841364402.post-7222312827308158221</id><published>2009-11-24T18:46:00.001+01:00</published><updated>2009-12-05T07:34:59.431+01:00</updated><title type='text'>UKOUG 2009</title><content type='html'>&lt;div style="text-align: left;"&gt;&lt;a href="http://techandebs.ukoug.org/uploadedimages/UKOUG_Horizontal_Tech_EBS_resized+date+loc.JPG"&gt;&lt;img style="margin: 0px auto 10px; text-align: center; width: 391px; display: block; height: 66px;" alt="" src="http://techandebs.ukoug.org/uploadedimages/UKOUG_Horizontal_Tech_EBS_resized+date+loc.JPG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;UKOUG 2009 conference will take place next week in Birmingham. I will speak on Wednesday, December 2nd about "&lt;a href="http://techandebs.ukoug.org/default.asp?p=3227&amp;amp;dlgact=shwprs&amp;amp;prs_prsid=3651&amp;amp;day_dayid=34"&gt;Execution Plan Stability in Oracle11g&lt;/a&gt;". As the audience at UKOUG conference is very technical I will add more technical stuff to my presentation this week.&lt;br /&gt;&lt;br /&gt;Here is the link for for the &lt;a href="http://techandebs.ukoug.org/personalisedagenda"&gt;conference agenda&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;On Sunday evening I will attend Oracle ACE dinner for the first time. I'm looking forward to meet some new people there although most of them I know already from OakTable or from other conference events.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
&lt;/script&gt;
&lt;script type="text/javascript"&gt;
try {
var pageTracker = _gat._getTracker("UA-5265495-3");
pageTracker._trackPageview();
} catch(err) {}&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3116559472841364402-7222312827308158221?l=joze-senegacnik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://joze-senegacnik.blogspot.com/feeds/7222312827308158221/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://joze-senegacnik.blogspot.com/2009/11/ukoug-2009.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/7222312827308158221'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/7222312827308158221'/><link rel='alternate' type='text/html' href='http://joze-senegacnik.blogspot.com/2009/11/ukoug-2009.html' title='UKOUG 2009'/><author><name>Jože Senegačnik - Joc</name><uri>http://www.blogger.com/profile/10478214001612631485</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://4.bp.blogspot.com/_SOd0WN7CXgU/Svv9TjGM0lI/AAAAAAAAAU8/xGVOpqkTFDY/S220/joc_with_piper.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3116559472841364402.post-4757682446052911997</id><published>2009-11-24T12:23:00.008+01:00</published><updated>2009-12-02T06:01:14.118+01:00</updated><title type='text'>Table Expressions, Cardinality, SYS_OP_ATG and KOKBF$</title><content type='html'>Recently I was involved in discussion on OTN form (see http://forums.oracle.com/forums/thread.jspa?threadID=986657) &lt;br /&gt;and I found an interesting information inside the posted execution plan which was in "Predicate information" section and was &lt;br /&gt;&lt;br /&gt;&lt;div class="codesnippet"&gt;filter(SYS_OP_ATG(VALUE(KOKBF$),2,3,2)='HQPRM003')&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Googling showed some interesting information in Vlad Sadilovski's blog that KOKBF$ is a generic alias given the table expressions. What was more interesting was undocumented SYS_OP_ATG function which attracted my interest. So I decided to create a simple case to observe what is going on.&lt;br /&gt;&lt;br /&gt;&lt;div class="codesnippet"&gt;&lt;br /&gt;SQL&gt; CREATE TYPE demo_object AS OBJECT&lt;br /&gt;   2 ( ID NUMBER(6)&lt;br /&gt;   3 , first_name VARCHAR2(30)&lt;br /&gt;   4 , last_name VARCHAR2(20));&lt;br /&gt;   5 /&lt;br /&gt;&lt;br /&gt;Type created.&lt;br /&gt;&lt;br /&gt;SQL&gt; create type demo_object_t as AS TABLE OF demo_object;&lt;br /&gt;   2 /&lt;br /&gt;&lt;br /&gt;Type created.&lt;br /&gt;&lt;br /&gt;SQL&gt; CREATE or replace FUNCTION demo_func( p_num_rows number )&lt;br /&gt;   2 RETURN demo_object_t&lt;br /&gt;   3 as&lt;br /&gt;   4 r_demo_object_t demo_object_t;&lt;br /&gt;   5 BEGIN&lt;br /&gt;   6 SELECT demo_object(rownum,dbms_random.string('k',30),     dbms_random.string('k',20))&lt;br /&gt;   7 BULK COLLECT INTO r_demo_object_t&lt;br /&gt;   8 FROM dual connect by level &amp;lt;= p_num_rows; &lt;br /&gt;   9 RETURN r_demo_object_t;&lt;br /&gt;  10 END; &lt;br /&gt;  11 /&lt;br /&gt;&lt;br /&gt;Function created. &lt;br /&gt;&lt;br /&gt;SQL&gt; select * from table(demo_func(10));&lt;br /&gt;&lt;br /&gt;ID FIRST_NAME LAST_NAME&lt;br /&gt;---------- ------------------------------ --------------------&lt;br /&gt;         1 POXXOPVQXYPXUIGCQLVBWLNXXLUEQC JAIAUCWHIMCRRJQXWUJY&lt;br /&gt;         2 SVYYKMZRBERFQFZKAQQOOSDNKMIJSG JMAOAUMHSWGNMYRCBSAG&lt;br /&gt;         3 LKNMLDIGIDTJECSRZDNSGHECNGVEFL TUUFTVPIVIXGRWYZFMCF&lt;br /&gt;         4 UIAEJZRIRROBBCINFTKNAXJEPFGKPP LPNGQCTLNLMEJWLGTWQJ&lt;br /&gt;         5 MGKMJJOHOZPCYEXEDVOWYSYUJMDDBF PTQACVZBNFCJOMQKJNRA&lt;br /&gt;         6 DSOODWTOPLPDAFZRXXGKKGECIPCHHB MHWPUTQJOSGOFOKCALJW&lt;br /&gt;         7 VTTVCLHRWLXGVMAKWQPOJDMLYUIEOS MXABXPTDHQENPKEHYCFZ&lt;br /&gt;         8 QJPWITNBARETOWMUVOQHABEEYNKLOD UYOEOUROCXHXXVNQILYU&lt;br /&gt;         9 PZDJEPXAHXXIAOVTOGKPSCMNDORNQX IZLRNYOLEWSPWDMCQMCY&lt;br /&gt;        10 FBOKISOVXUNFASOLGOZZPGVHSEFDAG MXOEIQSZMLTBREPGBDSM&lt;br /&gt;&lt;br /&gt;10 rows selected.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;So now we are ready to see what is going on.&lt;br /&gt;&lt;br /&gt;&lt;div class="codesnippet"&gt;&lt;br /&gt;SQL&gt; select * from table(dbms_xplan.display);&lt;br /&gt;&lt;br /&gt;Plan hash value: 2056388305&lt;br /&gt;&lt;br /&gt;-----------------------------------------------------------------------------------------------&lt;br /&gt;| Id  | Operation                         | Name      | Rows  | Bytes | Cost (%CPU)| Time     |&lt;br /&gt;-----------------------------------------------------------------------------------------------&lt;br /&gt;|   0 | SELECT STATEMENT                  |           |  8168 | 16336 |    29   (0)| 00:00:01 |&lt;br /&gt;|   1 |  COLLECTION ITERATOR PICKLER FETCH| DEMO_FUNC |       |       |            |          |&lt;br /&gt;-----------------------------------------------------------------------------------------------&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;The estimated cardinality is 8168 rows what is a default value used for 8k block size. &lt;br /&gt;The actual cardinality was 10 rows. With additional condition id=8 the estimate changes to 82 rows.&lt;br /&gt;&lt;br /&gt;&lt;div class="codesnippet"&gt;&lt;br /&gt;SQL&gt; explain plan for&lt;br /&gt;  2  select a.id, a.first_name,a.last_name&lt;br /&gt;  3  from table(demo_func(10)) a&lt;br /&gt;  4  where a.id = 8;&lt;br /&gt;&lt;br /&gt;Explained.&lt;br /&gt;&lt;br /&gt;SQL&gt; select * from table(dbms_xplan.display);&lt;br /&gt;&lt;br /&gt;Plan hash value: 2056388305&lt;br /&gt;&lt;br /&gt;-----------------------------------------------------------------------------------------------&lt;br /&gt;| Id  | Operation                         | Name      | Rows  | Bytes | Cost (%CPU)| Time     |&lt;br /&gt;-----------------------------------------------------------------------------------------------&lt;br /&gt;|   0 | SELECT STATEMENT                  |           |    82 |   164 |    29   (0)| 00:00:01 |&lt;br /&gt;|*  1 |  COLLECTION ITERATOR PICKLER FETCH| DEMO_FUNC |       |       |            |          |&lt;br /&gt;-----------------------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Predicate Information (identified by operation id):&lt;br /&gt;---------------------------------------------------&lt;br /&gt;&lt;br /&gt;   1 - filter(SYS_OP_ATG(VALUE(KOKBF$),1,2,2)=8)&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;I wanted to correct the cardinality estimate and I used undocumented hint CARDINALITY which is available since Oracle9i.&lt;br /&gt;&lt;br /&gt;&lt;div class="codesnippet"&gt;&lt;br /&gt;SQL&gt; explain plan for&lt;br /&gt;  2  select /*+ cardinality( a 1 ) */ a.id, a.first_name,a.last_name&lt;br /&gt;  3  from table(demo_func(10)) a&lt;br /&gt;  4  where a.id = 8;&lt;br /&gt;&lt;br /&gt;Explained.&lt;br /&gt;&lt;br /&gt;SQL&gt; select * from table(dbms_xplan.display);&lt;br /&gt;&lt;br /&gt;Plan hash value: 2056388305&lt;br /&gt;&lt;br /&gt;-----------------------------------------------------------------------------------------------&lt;br /&gt;| Id  | Operation                         | Name      | Rows  | Bytes | Cost (%CPU)| Time     |&lt;br /&gt;-----------------------------------------------------------------------------------------------&lt;br /&gt;|   0 | SELECT STATEMENT                  |           |     1 |     2 |    29   (0)| 00:00:01 |&lt;br /&gt;|*  1 |  COLLECTION ITERATOR PICKLER FETCH| DEMO_FUNC |       |       |            |          |&lt;br /&gt;-----------------------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Predicate Information (identified by operation id):&lt;br /&gt;---------------------------------------------------&lt;br /&gt;&lt;br /&gt;   1 - filter(SYS_OP_ATG(VALUE(KOKBF$),1,2,2)=8)&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;I also used event 10053 to get CBO trace and there I found the following information:&lt;br /&gt;&lt;br /&gt;&lt;div class="codesnippet"&gt;&lt;br /&gt;SQL&gt; alter session set events '10053 trace name context forever';&lt;br /&gt;&lt;br /&gt;Session altered.&lt;br /&gt;&lt;br /&gt;SQL&gt; explain plan for&lt;br /&gt;  2  select /*+ cardinality( a 1 ) */ a.id, a.first_name,a.last_name&lt;br /&gt;  3  from table(demo_func(10)) a&lt;br /&gt;  4  where a.id = 8;&lt;br /&gt;&lt;br /&gt;Explained.&lt;br /&gt;&lt;br /&gt;SQL&gt; alter session set events '10053 trace name context off';&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="codesnippet"&gt;&lt;br /&gt;***************************************&lt;br /&gt;BASE STATISTICAL INFORMATION&lt;br /&gt;***********************&lt;br /&gt;Table Stats::&lt;br /&gt;  Table: KOKBF$  Alias: KOKBF$  (NOT ANALYZED)&lt;br /&gt;    #Rows: 8168  #Blks:  100  AvgRowLen:  100.00&lt;br /&gt;Access path analysis for KOKBF$&lt;br /&gt;***************************************&lt;br /&gt;SINGLE TABLE ACCESS PATH &lt;br /&gt;  Single Table Cardinality Estimation for KOKBF$[KOKBF$] &lt;br /&gt;  Table: KOKBF$  Alias: KOKBF$&lt;br /&gt;    Card: Original: 8168.000000    &gt;&gt; Single Tab Card adjusted from:81.680000 to:1.000000&lt;br /&gt;  Rounded: 1  Computed: 1.00  Non Adjusted: 81.68&lt;br /&gt;  Access Path: TableScan&lt;br /&gt;    Cost:  29.29  Resp: 29.29  Degree: 0&lt;br /&gt;      Cost_io: 29.00  Cost_cpu: 6429744&lt;br /&gt;      Resp_io: 29.00  Resp_cpu: 6429744&lt;br /&gt;  Best:: AccessPath: TableScan&lt;br /&gt;         Cost: 29.29  Degree: 1  Resp: 29.29  Card: 1.00  Bytes: 0&lt;br /&gt;&lt;br /&gt;***************************************&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;My next experiment was creating a join between two row sets returned by the function and I have used the cardinality hint again.&lt;br /&gt;&lt;br /&gt;&lt;div class="codesnippet"&gt;&lt;br /&gt;SQL&gt; explain plan for&lt;br /&gt;  2  select /*+ cardinality(a 1) cardinality (b 1 ) */ a.id, a.first_name,a.last_name&lt;br /&gt;  3  from table(demo_func(10)) a, table(demo_func(10)) b&lt;br /&gt;  4  where a.id = 8&lt;br /&gt;  5  and a.id = b.id;&lt;br /&gt;&lt;br /&gt;Explained.&lt;br /&gt;&lt;br /&gt;SQL&gt; select * from table(dbms_xplan.display);&lt;br /&gt;&lt;br /&gt;Plan hash value: 2170227849&lt;br /&gt;&lt;br /&gt;------------------------------------------------------------------------------------------------&lt;br /&gt;| Id  | Operation                          | Name      | Rows  | Bytes | Cost (%CPU)| Time     |&lt;br /&gt;------------------------------------------------------------------------------------------------&lt;br /&gt;|   0 | SELECT STATEMENT                   |           |     1 |     4 |    59   (2)| 00:00:01 |&lt;br /&gt;|*  1 |  HASH JOIN                         |           |     1 |     4 |    59   (2)| 00:00:01 |&lt;br /&gt;|*  2 |   COLLECTION ITERATOR PICKLER FETCH| DEMO_FUNC |       |       |            |          |&lt;br /&gt;|*  3 |   COLLECTION ITERATOR PICKLER FETCH| DEMO_FUNC |       |       |            |          |&lt;br /&gt;------------------------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Predicate Information (identified by operation id):&lt;br /&gt;---------------------------------------------------&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   1 - access(SYS_OP_ATG(VALUE(KOKBF$),1,2,2)=SYS_OP_ATG(VALUE(KOKBF$),1,2,2))&lt;br /&gt;   2 - filter(SYS_OP_ATG(VALUE(KOKBF$),1,2,2)=8)&lt;br /&gt;   3 - filter(SYS_OP_ATG(VALUE(KOKBF$),1,2,2)=8)&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;In the CBO trace file I found this interesting piece of information where the SQL was &lt;br /&gt;transformed in the following way:&lt;br /&gt;&lt;br /&gt;&lt;div class="codesnippet"&gt;&lt;br /&gt;SELECT /*+ OPT_ESTIMATE (TABLE "B" ROWS=1.000000 ) OPT_ESTIMATE (TABLE "A" ROWS=1.000000 ) */&lt;br /&gt;       "A"."SYS_NC_ROWINFO$"."ID" "ID",&lt;br /&gt;       "A"."SYS_NC_ROWINFO$"."FIRST_NAME" "FIRST_NAME",&lt;br /&gt;       "A"."SYS_NC_ROWINFO$"."LAST_NAME" "LAST_NAME"&lt;br /&gt;  FROM (SELECT VALUE (kokbf$) "SYS_NC_ROWINFO$"&lt;br /&gt;          FROM TABLE ("JOC"."DEMO_FUNC" (10)) "KOKBF$") "A",&lt;br /&gt;       (SELECT VALUE (kokbf$) "SYS_NC_ROWINFO$"&lt;br /&gt;          FROM TABLE ("JOC"."DEMO_FUNC" (10)) "KOKBF$") "B"&lt;br /&gt; WHERE "A"."SYS_NC_ROWINFO$"."ID" = 8&lt;br /&gt;   AND "A"."SYS_NC_ROWINFO$"."ID" = "B"."SYS_NC_ROWINFO$"."ID"&lt;br /&gt;&lt;br /&gt;Query block SEL$1 (#0) unchanged&lt;br /&gt;PL/SQL function (DEMO_FUNC) is not secure.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Here CBO transformed CARDINALITY hint to a new undocumented hint used in SQL Profiles &lt;br /&gt;OPT_ESTIMATE (TABLE "B" ROWS=1.000000 ) which does exactly the same - &lt;br /&gt;scales down the number of rows to 1 in this case.&lt;br /&gt;&lt;br /&gt;Another very interesting piece of information here is how the statement is internally transformed to use SYS_NC_ROWINFO$ which is a virtual column that references the row XMLType instance and is there since Oracle9i. In later releases this was replaced with a new OBJECT_VALUE pseudo column but obviousl CBO still uses that internally (for more details see "Oracle Database SQL Language Reference")&lt;br /&gt;&lt;br /&gt;There was also other interesting transformation present which was:&lt;br /&gt;&lt;br /&gt;&lt;div class="codesnippet"&gt;&lt;br /&gt;SELECT /*+ OPT_ESTIMATE (TABLE "KOKBF$" ROWS=1.000000 ) OPT_ESTIMATE (TABLE "KOKBF$" ROWS=1.000000 ) */&lt;br /&gt;       sys_op_atg (VALUE (kokbf$), 1, 2, 0) "ID",&lt;br /&gt;       sys_op_atg (VALUE (kokbf$), 2, 3, 0) "FIRST_NAME",&lt;br /&gt;       sys_op_atg (VALUE (kokbf$), 3, 4, 0) "LAST_NAME"&lt;br /&gt;  FROM TABLE ("JOC"."DEMO_FUNC" (10)) "KOKBF$",&lt;br /&gt;       TABLE ("JOC"."DEMO_FUNC" (10)) "KOKBF$"&lt;br /&gt; WHERE sys_op_atg (VALUE (kokbf$), 1, 2, 0) = 8&lt;br /&gt;   AND sys_op_atg (VALUE (kokbf$), 1, 2, 0) = sys_op_atg (VALUE (kokbf$), 1, 2, 0)&lt;br /&gt;&lt;br /&gt;Query block SEL$2B5797BE (#0) unchanged&lt;br /&gt;query block SEL$1 transformed to SEL$2B5797BE (#0)&lt;br /&gt;Considering Query Transformations on query block SEL$2B5797BE (#0)&lt;br /&gt;**************************&lt;br /&gt;Query transformations (QT)&lt;br /&gt;**************************&lt;br /&gt;CBQT: copy not possible on query block SEL$2B5797BE (#0) because nested table&lt;br /&gt;CBQT bypassed for query block SEL$2B5797BE (#0): Cannot copy query block.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Here Oracle uses undocumented function sys_op_atg which returns a column from object type. &lt;br /&gt;The first parameter specifies the starting column, the second one specifies the ending column and for the third parameter I was not able to figure out what does it mean. In all cases which I have found on Interenet or in Oracle manuals this parameter had always value of 2.&lt;br /&gt;&lt;br /&gt;Then CBO was trying to push the filter condition inside function execution what was of course not possible.&lt;br /&gt;&lt;br /&gt;&lt;div class="codesnippet"&gt;FPD: Considering simple filter push in query block SEL$2B5797BE (#0)&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;In next step CBO generated transitive predicate which could be observed under the "Predicate Information" section of execution plan.&lt;br /&gt;&lt;br /&gt;&lt;div class="codesnippet"&gt;&lt;br /&gt;SYS_OP_ATG(VALUE(KOKBF$),1,2,2)=8 AND SYS_OP_ATG(VALUE(KOKBF$),1,2,2)=SYS_OP_ATG(VALUE(KOKBF$),1,2,2)&lt;br /&gt;try to generate transitive predicate from check constraints for query block SEL$2B5797BE (#0)&lt;br /&gt;finally: SYS_OP_ATG(VALUE(KOKBF$),1,2,2)=8 AND SYS_OP_ATG(VALUE(KOKBF$),1,2,2)=SYS_OP_ATG(VALUE(KOKBF$),1,2,2) AND SYS_OP_ATG(VALUE(KOKBF$),1,2,2)=8&lt;br /&gt;&lt;br /&gt;FPD:   transitive predicates are generated in query block SEL$2B5797BE (#0)&lt;br /&gt;SYS_OP_ATG(VALUE(KOKBF$),1,2,2)=8&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;From my presentation at IUOG back in 2005 about the Extensible optimizer I used the trick to associate the function with statistics type. Of course I could use also DYNAMIC_SAMPLING but this is more elegant way. Here is what I have done:&lt;br /&gt;&lt;br /&gt;&lt;div class="codesnippet"&gt;&lt;br /&gt;SQL&gt; CREATE OR REPLACE TYPE demo_func_stats_type AS OBJECT (&lt;br /&gt;  2     dummy_attribute   NUMBER,&lt;br /&gt;  3     STATIC FUNCTION odcigetinterfaces (p_interfaces OUT SYS.odciobjectlist)&lt;br /&gt;  4        RETURN NUMBER,&lt;br /&gt;  5     STATIC FUNCTION odcistatstablefunction (&lt;br /&gt;  6        p_function   IN       SYS.odcifuncinfo,&lt;br /&gt;  7        p_stats      OUT      SYS.odcitabfuncstats,&lt;br /&gt;  8        p_args       IN       SYS.odciargdesclist,&lt;br /&gt;  9        p_num_rows   IN       NUMBER&lt;br /&gt; 10     )&lt;br /&gt; 11        RETURN NUMBER&lt;br /&gt; 12  );&lt;br /&gt; 13  /&lt;br /&gt;&lt;br /&gt;Type created.&lt;br /&gt;&lt;br /&gt;SQL&gt; CREATE OR REPLACE TYPE BODY demo_func_stats_type AS&lt;br /&gt;  2     STATIC FUNCTION odcigetinterfaces (p_interfaces OUT SYS.odciobjectlist)&lt;br /&gt;  3        RETURN NUMBER IS&lt;br /&gt;  4     BEGIN&lt;br /&gt;  5        p_interfaces :=&lt;br /&gt;  6                      SYS.odciobjectlist (SYS.odciobject ('SYS', 'ODCISTATS2'));&lt;br /&gt;  7        RETURN odciconst.success;&lt;br /&gt;  8     END odcigetinterfaces;&lt;br /&gt;  9     STATIC FUNCTION odcistatstablefunction (&lt;br /&gt; 10        p_function   IN       SYS.odcifuncinfo,&lt;br /&gt; 11        p_stats      OUT      SYS.odcitabfuncstats,&lt;br /&gt; 12        p_args       IN       SYS.odciargdesclist,&lt;br /&gt; 13        p_num_rows   IN       NUMBER&lt;br /&gt; 14     )&lt;br /&gt; 15        RETURN NUMBER IS&lt;br /&gt; 16     BEGIN&lt;br /&gt; 17        p_stats := SYS.odcitabfuncstats (p_num_rows);&lt;br /&gt; 18        RETURN odciconst.success;&lt;br /&gt; 19     END odcistatstablefunction;&lt;br /&gt; 20  END;&lt;br /&gt; 21  /&lt;br /&gt;&lt;br /&gt;Type body created.&lt;br /&gt;&lt;br /&gt;SQL&gt; explain plan for&lt;br /&gt;  2  select a.id, a.first_name,a.last_name&lt;br /&gt;  3  from table(demo_func(10)) a, table(demo_func(1000)) b&lt;br /&gt;  4  where a.id = 8&lt;br /&gt;  5  and a.id = b.id;&lt;br /&gt;&lt;br /&gt;Explained.&lt;br /&gt;&lt;br /&gt;SQL&gt; select * from table(dbms_xplan.display);&lt;br /&gt;&lt;br /&gt;Plan hash value: 2170227849&lt;br /&gt;&lt;br /&gt;------------------------------------------------------------------------------------------------&lt;br /&gt;| Id  | Operation                          | Name      | Rows  | Bytes | Cost (%CPU)| Time     |&lt;br /&gt;------------------------------------------------------------------------------------------------&lt;br /&gt;|   0 | SELECT STATEMENT                   |           |    67 |   268 |    59   (2)| 00:00:01 |&lt;br /&gt;|*  1 |  HASH JOIN                         |           |    67 |   268 |    59   (2)| 00:00:01 |&lt;br /&gt;|*  2 |   COLLECTION ITERATOR PICKLER FETCH| DEMO_FUNC |       |       |            |          |&lt;br /&gt;|*  3 |   COLLECTION ITERATOR PICKLER FETCH| DEMO_FUNC |       |       |            |          |&lt;br /&gt;------------------------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Predicate Information (identified by operation id):&lt;br /&gt;---------------------------------------------------&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   1 - access(SYS_OP_ATG(VALUE(KOKBF$),1,2,2)=SYS_OP_ATG(VALUE(KOKBF$),1,2,2))&lt;br /&gt;   2 - filter(SYS_OP_ATG(VALUE(KOKBF$),1,2,2)=8)&lt;br /&gt;   3 - filter(SYS_OP_ATG(VALUE(KOKBF$),1,2,2)=8)&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Here we can see that the cardinality estimate is quite off - it should be 1. Therefore I now use my statistics type and associate it with demo_func.&lt;br /&gt;&lt;br /&gt;&lt;div class="codesnippet"&gt;&lt;br /&gt;SQL&gt; associate statistics with functions demo_func using demo_func_stats_type;&lt;br /&gt;&lt;br /&gt;Statistics associated.&lt;br /&gt;&lt;br /&gt;SQL&gt; explain plan for&lt;br /&gt;  2  select a.id, a.first_name,a.last_name&lt;br /&gt;  3  from table(demo_func(10)) a, table(demo_func(1000)) b&lt;br /&gt;  4  where a.id = 8&lt;br /&gt;  5  and a.id = b.id;&lt;br /&gt;&lt;br /&gt;Explained.&lt;br /&gt;&lt;br /&gt;SQL&gt; select * from table(dbms_xplan.display);&lt;br /&gt;&lt;br /&gt;Plan hash value: 2170227849&lt;br /&gt;&lt;br /&gt;------------------------------------------------------------------------------------------------&lt;br /&gt;| Id  | Operation                          | Name      | Rows  | Bytes | Cost (%CPU)| Time     |&lt;br /&gt;------------------------------------------------------------------------------------------------&lt;br /&gt;|   0 | SELECT STATEMENT                   |           |     1 |     4 |    59   (2)| 00:00:01 |&lt;br /&gt;|*  1 |  HASH JOIN                         |           |     1 |     4 |    59   (2)| 00:00:01 |&lt;br /&gt;|*  2 |   COLLECTION ITERATOR PICKLER FETCH| DEMO_FUNC |       |       |            |          |&lt;br /&gt;|*  3 |   COLLECTION ITERATOR PICKLER FETCH| DEMO_FUNC |       |       |            |          |&lt;br /&gt;------------------------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Predicate Information (identified by operation id):&lt;br /&gt;---------------------------------------------------&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   1 - access(SYS_OP_ATG(VALUE(KOKBF$),1,2,2)=SYS_OP_ATG(VALUE(KOKBF$),1,2,2))&lt;br /&gt;   2 - filter(SYS_OP_ATG(VALUE(KOKBF$),1,2,2)=8)&lt;br /&gt;   3 - filter(SYS_OP_ATG(VALUE(KOKBF$),1,2,2)=8)&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;As we can see the CBO now correctly estimates the number of rows.&lt;br /&gt;In the CBO trace file we can find the following information:&lt;br /&gt;&lt;br /&gt;&lt;div class="codesnippet"&gt;&lt;br /&gt;***************************************&lt;br /&gt;BASE STATISTICAL INFORMATION&lt;br /&gt;***********************&lt;br /&gt;Table Stats::&lt;br /&gt;  Table: KOKBF$  Alias: KOKBF$  (NOT ANALYZED)&lt;br /&gt;    #Rows: 8168  #Blks:  100  AvgRowLen:  100.00&lt;br /&gt;***********************&lt;br /&gt;Table Stats::&lt;br /&gt;  Table: KOKBF$  Alias: KOKBF$  (NOT ANALYZED)&lt;br /&gt;    #Rows: 8168  #Blks:  100  AvgRowLen:  100.00&lt;br /&gt;Access path analysis for KOKBF$&lt;br /&gt;***************************************&lt;br /&gt;SINGLE TABLE ACCESS PATH &lt;br /&gt;  Single Table Cardinality Estimation for KOKBF$[KOKBF$] &lt;br /&gt;  Calling user-defined function card function...&lt;br /&gt;Bind :3 Value 10&lt;br /&gt;  JOC.DEMO_FUNC_STATS_TYPE.ODCIStatsTableFunction returned:&lt;br /&gt;    num_rows      : 10&lt;br /&gt;  Table: KOKBF$  Alias: KOKBF$&lt;br /&gt;    Card: Original: 10.000000  Rounded: 1  Computed: 0.10  Non Adjusted: 0.10&lt;br /&gt;  Access Path: TableScan&lt;br /&gt;    Cost:  29.29  Resp: 29.29  Degree: 0&lt;br /&gt;      Cost_io: 29.00  Cost_cpu: 6429744&lt;br /&gt;      Resp_io: 29.00  Resp_cpu: 6429744&lt;br /&gt;  Best:: AccessPath: TableScan&lt;br /&gt;         Cost: 29.29  Degree: 1  Resp: 29.29  Card: 0.10  Bytes: 0&lt;br /&gt;&lt;br /&gt;Access path analysis for KOKBF$&lt;br /&gt;***************************************&lt;br /&gt;SINGLE TABLE ACCESS PATH &lt;br /&gt;  Single Table Cardinality Estimation for KOKBF$[KOKBF$] &lt;br /&gt;  Calling user-defined function card function...&lt;br /&gt;Bind :3 Value 1000&lt;br /&gt;  JOC.DEMO_FUNC_STATS_TYPE.ODCIStatsTableFunction returned:&lt;br /&gt;    num_rows      : 1000&lt;br /&gt;  Table: KOKBF$  Alias: KOKBF$&lt;br /&gt;    Card: Original: 1000.000000  Rounded: 10  Computed: 10.00  Non Adjusted: 10.00&lt;br /&gt;  Access Path: TableScan&lt;br /&gt;    Cost:  29.29  Resp: 29.29  Degree: 0&lt;br /&gt;      Cost_io: 29.00  Cost_cpu: 6429744&lt;br /&gt;      Resp_io: 29.00  Resp_cpu: 6429744&lt;br /&gt;  Best:: AccessPath: TableScan&lt;br /&gt;         Cost: 29.29  Degree: 1  Resp: 29.29  Card: 10.00  Bytes: 0&lt;br /&gt;&lt;br /&gt;***************************************&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;As we can see the user-defined statistics function which CBO calls during the optimization phase resolves the problem of erroneously determined cardinality.&lt;br /&gt;&lt;br /&gt;One can disassociate statistics with the following command:&lt;br /&gt;&lt;br /&gt;&lt;div class="codesnippet"&gt;SQL&gt; disassociate statistics from functions demo_func;&lt;br /&gt;&lt;br /&gt;Statistics disassociated.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Now we can check what is going on in run time. We use gather_plan_statistics hint on statement level to gather all execution statistics.&lt;br /&gt;&lt;br /&gt;&lt;div class="codesnippet"&gt;&lt;br /&gt;SQL&gt; select /*+ gather_plan_statistics */ a.id, a.first_name,a.last_name&lt;br /&gt;  2  from table(demo_func(10)) a,&lt;br /&gt;  3  table(demo_func(1000)) b&lt;br /&gt;  4  where a.id = 8&lt;br /&gt;  5  and a.id = b.id;&lt;br /&gt;&lt;br /&gt;        ID FIRST_NAME                     LAST_NAME&lt;br /&gt;---------- ------------------------------ --------------------&lt;br /&gt;         8 EMRFXDHQISONDDVTYLMPQDRDIWAHMG BMUUKQWCUCKBYGGKMBEM&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&gt; select * from table(dbms_xplan.display_cursor(NULL,NULL, 'allstats last'));&lt;br /&gt;&lt;br /&gt;SQL_ID  4kyvk4q692gqu, child number 0&lt;br /&gt;-------------------------------------&lt;br /&gt;select /*+ gather_plan_statistics */ a.id, a.first_name,a.last_name&lt;br /&gt;from table(demo_func(10)) a, table(demo_func(1000)) b where a.id = 8&lt;br /&gt;and a.id = b.id&lt;br /&gt;&lt;br /&gt;Plan hash value: 2170227849&lt;br /&gt;&lt;br /&gt;----------------------------------------------------------------------------------------------------------&lt;br /&gt;| Id  | Operation                          | Name      | Starts | E-Rows | A-Rows |   A-Time   | Buffers |&lt;br /&gt;----------------------------------------------------------------------------------------------------------&lt;br /&gt;|*  1 |  HASH JOIN                         |           |      1 |      1 |      1 |00:00:00.14 |       3 |&lt;br /&gt;|*  2 |   COLLECTION ITERATOR PICKLER FETCH| DEMO_FUNC |      1 |        |      1 |00:00:00.01 |       3 |&lt;br /&gt;|*  3 |   COLLECTION ITERATOR PICKLER FETCH| DEMO_FUNC |      1 |        |      1 |00:00:00.14 |       0 |&lt;br /&gt;----------------------------------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Predicate Information (identified by operation id):&lt;br /&gt;---------------------------------------------------&lt;br /&gt;&lt;br /&gt;   1 - access(SYS_OP_ATG(VALUE(KOKBF$),1,2,2)=SYS_OP_ATG(VALUE(KOKBF$),1,2,2))&lt;br /&gt;   2 - filter(SYS_OP_ATG(VALUE(KOKBF$),1,2,2)=8)&lt;br /&gt;   3 - filter(SYS_OP_ATG(VALUE(KOKBF$),1,2,2)=8)&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;From this plan we can see that each row source is returned by "COLLECTION ITERATOR PICKLER FETCH" and that function DEMO_FUNC is executed only once (Starts = 1).&lt;br /&gt;&lt;br /&gt;Of course there is no chance to push predicate as a.id=b.id and a.id=8 inside the function execution. Therefore Oracle has to use SYS_OP_ATG function to decompose returned object and perform the join operation only after function calls complete there execution.&lt;br /&gt;&lt;br /&gt;We can see that this could be very inefficient. To resolve the possible performance issues one should not use functions (this is true also for pipelined functions) if the function result is used in later join operations or the majority of returned rows is filtered out later on. One possible solution would be to pass some conditions as function parameters, but the best solution is to replace a function call with inline view which contains the query used inside function. Then the CBO has more possibility and place for optimization and can optimize the whole statement.&lt;br /&gt;&lt;br /&gt;If I return back to the origin for this post - we got the best result when we had replaced function call with inline view containing the query from the function. The CBO can't really push any kind of predicates inside the function call and the only possibility is to use function parameter for passing them. &lt;br /&gt;&lt;br /&gt;This was also a good example to point out the problems of cardinality estimates for table functions and how one can use extensible optimizer to resolve it.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
&lt;/script&gt;
&lt;script type="text/javascript"&gt;
try {
var pageTracker = _gat._getTracker("UA-5265495-3");
pageTracker._trackPageview();
} catch(err) {}&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3116559472841364402-4757682446052911997?l=joze-senegacnik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://joze-senegacnik.blogspot.com/feeds/4757682446052911997/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://joze-senegacnik.blogspot.com/2009/11/recently-i-was-involved-in-discussion.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/4757682446052911997'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/4757682446052911997'/><link rel='alternate' type='text/html' href='http://joze-senegacnik.blogspot.com/2009/11/recently-i-was-involved-in-discussion.html' title='Table Expressions, Cardinality, SYS_OP_ATG and KOKBF$'/><author><name>Jože Senegačnik - Joc</name><uri>http://www.blogger.com/profile/10478214001612631485</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://4.bp.blogspot.com/_SOd0WN7CXgU/Svv9TjGM0lI/AAAAAAAAAU8/xGVOpqkTFDY/S220/joc_with_piper.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3116559472841364402.post-2540450206202150359</id><published>2009-11-06T12:03:00.001+01:00</published><updated>2009-11-25T03:49:01.244+01:00</updated><title type='text'>Scandinavian Trip</title><content type='html'>This week I was presenting at two Oracle User Group conferences - one in &lt;a href="http://www.orcan.se/"&gt;Sweden&lt;/a&gt; and the other one in &lt;a href="http://www.ougf.fi/"&gt;Finland&lt;/a&gt;.&lt;br /&gt;It was the first time for me to be in Sweden and therefore I had no experience with this country. I was planning to fly by myself but the rainy/snowy weather in Scandinavia and also across all Europe prevented me to do so.&lt;br /&gt;I was in Finland several times before and this was the first time I was presenting at their Oracle users group.&lt;br /&gt;Both events were nicely organized and especially in Finland I had met a lot of known people and I had a great time at the speakers dinner the evening before conference and through the whole conference as well.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
&lt;/script&gt;
&lt;script type="text/javascript"&gt;
try {
var pageTracker = _gat._getTracker("UA-5265495-3");
pageTracker._trackPageview();
} catch(err) {}&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3116559472841364402-2540450206202150359?l=joze-senegacnik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://joze-senegacnik.blogspot.com/feeds/2540450206202150359/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://joze-senegacnik.blogspot.com/2009/11/scandinavian-trip.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/2540450206202150359'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/2540450206202150359'/><link rel='alternate' type='text/html' href='http://joze-senegacnik.blogspot.com/2009/11/scandinavian-trip.html' title='Scandinavian Trip'/><author><name>Jože Senegačnik - Joc</name><uri>http://www.blogger.com/profile/10478214001612631485</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://4.bp.blogspot.com/_SOd0WN7CXgU/Svv9TjGM0lI/AAAAAAAAAU8/xGVOpqkTFDY/S220/joc_with_piper.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3116559472841364402.post-2656984776529649622</id><published>2009-11-06T10:36:00.000+01:00</published><updated>2009-11-06T11:50:27.116+01:00</updated><title type='text'>Starting Oracle Blog</title><content type='html'>Quite a long time ago I was tempted to start blogging about Oracle and then I decided just not to do that but rather I started to blog about my flying around Europe to present at Oracle conferences. However, I created the blog but never activated. The nomination for Oracle ACE changed this decision and I'll try to write about technical stuff from time to time, but don't expect that I will be so active as some of Oracle bloggers.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
&lt;/script&gt;
&lt;script type="text/javascript"&gt;
try {
var pageTracker = _gat._getTracker("UA-5265495-3");
pageTracker._trackPageview();
} catch(err) {}&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3116559472841364402-2656984776529649622?l=joze-senegacnik.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://joze-senegacnik.blogspot.com/feeds/2656984776529649622/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://joze-senegacnik.blogspot.com/2009/11/starting-oracle-blog.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/2656984776529649622'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3116559472841364402/posts/default/2656984776529649622'/><link rel='alternate' type='text/html' href='http://joze-senegacnik.blogspot.com/2009/11/starting-oracle-blog.html' title='Starting Oracle Blog'/><author><name>Jože Senegačnik - Joc</name><uri>http://www.blogger.com/profile/10478214001612631485</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://4.bp.blogspot.com/_SOd0WN7CXgU/Svv9TjGM0lI/AAAAAAAAAU8/xGVOpqkTFDY/S220/joc_with_piper.jpg'/></author><thr:total>3</thr:total></entry></feed>
