From oracle-l-bounce@freelists.org Fri Oct 14 07:24:43 2005 Return-Path: Received: from air891.startdedicated.com (root@localhost) by orafaq.com (8.12.10/8.12.10) with ESMTP id j9ECOgwq030562 for ; Fri, 14 Oct 2005 07:24:42 -0500 X-ClientAddr: 206.53.239.180 Received: from turing.freelists.org (freelists-180.iquest.net [206.53.239.180]) by air891.startdedicated.com (8.12.10/8.12.10) with ESMTP id j9ECOdvX030547 for ; Fri, 14 Oct 2005 07:24:39 -0500 Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 671621FE976; Fri, 14 Oct 2005 07:24:31 -0500 (EST) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 27384-08; Fri, 14 Oct 2005 07:24:31 -0500 (EST) Received: from turing (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id D27B11FD570; Fri, 14 Oct 2005 07:24:30 -0500 (EST) X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by Ecartis Subject: RE: autotrace issue Date: Fri, 14 Oct 2005 15:23:50 +0300 Message-ID: <083667B535F3464CA0DD0D1DAFA4E3760773331C@camexc1.kfs.local> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: autotrace issue Thread-Index: AcXQt+gyJTtl4lM2R1Gduwtc2Wt/rwAAbF8Q From: "Yasin Baskan" To: "Mladen Gogala" Cc: , X-archive-position: 26981 X-ecartis-version: Ecartis v1.0.0 Sender: oracle-l-bounce@freelists.org Errors-To: oracle-l-bounce@freelists.org X-original-sender: yasbs@kocbank.com.tr Precedence: normal Reply-To: yasbs@kocbank.com.tr X-list: oracle-l X-Virus-Scanned: by amavisd-new-20030616-p9 (Debian) at avenirtech.net X-mailscan-MailScanner-Information: Please contact the ISP for more information X-mailscan-MailScanner: Found to be clean X-MailScanner-From: oracle-l-bounce@freelists.org X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on air891.startdedicated.com X-Spam-Level: X-Spam-Status: No, hits=-3.8 required=5.0 tests=AWL,BAYES_00,HTML_MESSAGE autolearn=ham version=2.63 Sure it will reuse the same plan for a sql statement with bind variables. But it does not use the same plan for sqls with literals. Select * from Where col1=1; Select * from
Where col1=2; The optimizer can give 2 different plans for these sqls (according to the statistics of course). I was talking about sqls with literals as the sqls in the question. -----Original Message----- From: Mladen Gogala [mailto:gogala@sbcglobal.net] Sent: Friday, October 14, 2005 3:06 PM To: Yasin Baskan Cc: madan.sanjay@gmail.com; oracle-l@freelists.org Subject: Re: autotrace issue Yassin, no, it isn't normal. Once you have parsed and optimized statement, Oracle will resuse the same plan with utter disregard for the actual value of the bind variables. There is, however, a thing known as "bind value peeking" or a "peeping Tom optimizer" introduced in 9i, but without the lady godiva support. Optimizer looks into the value of the bind variables and uses the values there to query the column histograms. That causes an additional problem: if the first value is not representative for the majority of cases and there is very little you can do about it, short of recalculating statistics for one of the underlying tables, which is likely to influence all queries referencing that table. BTW, what makes hard parse such an expensive beast is exactly the enormous complexity of CBO. It has to look into all those tables to gather information like num_rows, leaf_blocks, clustering factor, value distribution for all columns that are referenced in the "WHERE" clause and have histograms, to look for the functional index and perform quite a complex task. You want to use bind variables to avoid invoking the optimizer at any time but the time of the very first execution. On 10/14/2005 07:37:08 AM, Yasin Baskan wrote: > > > Isn't it normal that the plan changes with the actual value in the where > clause. That is what the optimizer does. You can use a bind variable > instead of that literal and see what the plan is. -- Mladen Gogala http://www.mgogala.com Bu mesaj ve onunla iletilen tum ekler gonderildigi kisi ya da kuruma ozel ve Bankalar Kanunu geregince, gizlilik yukumlulugu tasiyor olabilir. Bu mesaj, hicbir sekilde, herhangi bir amac icin cogaltilamaz, yayinlanamaz ve para karsiligi satilamaz; mesajin yetkili alicisi veya alicisina iletmekten sorumlu kisi degilseniz, mesaj icerigini ya da eklerini kopyalamayiniz, yayinlamayiniz, baska kisilere yonlendirmeyiniz ve mesaji gonderen kisiyi derhal uyararak bu mesaji siliniz. Bu mesajin iceriginde ya da eklerinde yer alan bilgilerin dogrulugu, butunlugu ve guncelligi Bankamiz tarafindan garanti edilmemektedir ve bilinen viruslere karsi kontrolleri yapilmis olarak yollanan mesajin sisteminizde yaratabilecegi zararlardan Bankamiz sorumlu tutulamaz. This message and the files attached to it are under the privacy liability in accordance with the Banking Law and confidential to the use of the individual or entity to whom they are addressed. This message cannot be copied, disclosed or sold monetary consideration for any purpose. If you are not the intended recipient of this message, you should not copy, distribute, disclose or forward the information that exists in the content and in the attachments of this message; please notify the sender immediately and delete all copies of this message. Our Bank does not warrant the accuracy, integrity and currency of the information transmitted with this message. This message has been detected for all known computer viruses thence our Bank is not liable for the occurrence of any system corruption caused by this message -- http://www.freelists.org/webpage/oracle-l