Return-Path: <oracle-l-bounce@freelists.org>
X-Original-To: oracle-l@orafaq.com
Delivered-To: oracle-l@orafaq.com
Received: from puck1183.startdedicated.com (localhost [127.0.0.1])
 by puck1183.startdedicated.com (Postfix) with ESMTP id 859A61961097
 for <oracle-l@orafaq.com>; Fri, 11 Nov 2016 11:54:38 +0100 (CET)
Received: from turing.freelists.org (turing.freelists.org [206.53.239.180])
 by puck1183.startdedicated.com (Postfix) with ESMTPS
 for <oracle-l@orafaq.com>; Fri, 11 Nov 2016 11:54:38 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
 by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 3FC1161DFB;
 Fri, 11 Nov 2016 05:54:37 -0500 (EST)
X-Virus-Scanned: Debian amavisd-new at turing.freelists.org
Received: from turing.freelists.org ([127.0.0.1])
 by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id JbuSnoqaTLVy; Fri, 11 Nov 2016 05:54:37 -0500 (EST)
Received: from turing.freelists.org (localhost [127.0.0.1])
 by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 4FFC661E24;
 Fri, 11 Nov 2016 05:54:24 -0500 (EST)
Received: with ECARTIS (v1.0.0; list oracle-l); Fri, 11 Nov 2016 05:53:02 -0500 (EST)
Received: from localhost (localhost [127.0.0.1])
 by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 79D1661C37
 for <oracle-l@freelists.org>; Fri, 11 Nov 2016 05:53:02 -0500 (EST)
Received: from turing.freelists.org ([127.0.0.1])
 by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id Uol9kC2FMWHr for <oracle-l@freelists.org>;
 Fri, 11 Nov 2016 05:53:02 -0500 (EST)
Received: from mail-ua0-f180.google.com (mail-ua0-f180.google.com [209.85.217.180])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 35A8A61C34
 for <oracle-l@freelists.org>; Fri, 11 Nov 2016 05:53:01 -0500 (EST)
Received: by mail-ua0-f180.google.com with SMTP id 51so10292384uai.1
        for <oracle-l@freelists.org>; Fri, 11 Nov 2016 02:53:01 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:mime-version:in-reply-to:references:from:date
         :message-id:subject:to:cc;
        bh=gc4cbqJQWQuKVyl4SmtRQxua7arlaKWhQDJOCNpcA4g=;
        b=c6cOL9HNaiQHNVQ4uRXiYTEjRyKM7Da7CtzbGp4UZBJzVFSO5kT527+vs+1fNXcNl0
         wIGhGLQZPAqVoXW65w8i2tO6zMQj0nJ/bvR707ieycm6SNlIJDxXXv+vZ4jmORIJizN1
         cDzOO7PVlzRCFUGWLetS3IIAetTlFMDWa9rSLCJ9cWOqTYwGP6GDjlkcBAFOVLsC06W4
         Ak+20ikZVQe0PsHCiOccNpwKz4c8wVjuX9G0bVRPnGH+thPfJA9nZQW+7f8V0vQfyHjE
         a/2JMt4CJ+/ins39iLb2/gmpAIQVVc8kfxuaGBivChvphs6zo6vvkqS4t4+s8JzyKcv1
         FXHQ==
X-Gm-Message-State: ABUngvfyXBJsWMvkciybeu8mBksax9S1OHRk57cCn9nrh2WhzJjK3s7mHkfQog84IkoyQE/C6oSEZAGY7WKNxw==
X-Received: by 10.159.38.133 with SMTP id 5mr1427719uay.102.1478861581211;
 Fri, 11 Nov 2016 02:53:01 -0800 (PST)
MIME-Version: 1.0
Received: by 10.159.38.129 with HTTP; Fri, 11 Nov 2016 02:52:40 -0800 (PST)
In-Reply-To: <CAJu8R6gHFL8MmiuW3uf4boH1WyvKSe_+m5hvmc1C-22m5s7Dkg@mail.gmail.com>
References: <d4117b66-06ea-7e30-23e3-a2222bbedf46@www.sqltools-plusplus.org>
 <LOXP123MB1255942508CF0E1EA01DC918A5BB0@LOXP123MB1255.GBRP123.PROD.OUTLOOK.COM>
 <CAJu8R6gHFL8MmiuW3uf4boH1WyvKSe_+m5hvmc1C-22m5s7Dkg@mail.gmail.com>
From: Eriovaldo Andrietta <ecandrietta@gmail.com>
Date: Fri, 11 Nov 2016 08:52:40 -0200
Message-ID: <CAJdDhaN7vRXsYi3AA-qoGNUeCzq8FFz=OEeJaBZn47set5ruqw@mail.gmail.com>
Subject: Re: How to force Oracle generate a new execution plan
To: Mohamed Houri <mohamed.houri@gmail.com>
Cc: Jonathan Lewis <jonathan@jlcomp.demon.co.uk>, 
 "info@www.sqltools-plusplus.org" <info@www.sqltools-plusplus.org>, 
 "oracle-l@freelists.org" <oracle-l@freelists.org>
Content-Type: multipart/alternative; boundary=94eb2c04791c38652f0541044bd6
X-archive-position: 66810
X-ecartis-version: Ecartis v1.0.0
Sender: oracle-l-bounce@freelists.org
Errors-to: oracle-l-bounce@freelists.org
X-original-sender: ecandrietta@gmail.com
Precedence: normal
Reply-To: ecandrietta@gmail.com
List-help: <mailto:ecartis@freelists.org?Subject=help>
List-unsubscribe: <oracle-l-request@freelists.org?Subject=unsubscribe>
List-software: Ecartis version 1.0.0
List-Id: oracle-l <oracle-l.freelists.org>
X-List-ID: oracle-l <oracle-l.freelists.org>
List-subscribe: <oracle-l-request@freelists.org?Subject=subscribe>
List-owner: <mailto:mark.bobak@proquest.com>
List-post: <mailto:oracle-l@freelists.org>
List-archive: <http://www.freelists.org/archives/oracle-l>
X-list: oracle-l
--94eb2c04791c38652f0541044bd6
Content-Type: text/plain; charset=UTF-8

Hello,

I will suggest to development the use of a temporary table  in order to get
the same plan for all executions.
For my scenary it seems to be the best way.

Thanks for answers.

Regards
Eriovaldo

2016-11-11 6:44 GMT-02:00 Mohamed Houri <mohamed.houri@gmail.com>:

> Randolf,
>
> Yes you're right. And  I have been very often confronted to such a
> situation in the last couple of years.
>
> I have optimized an overnight query with a varying IN-LIST and fixed a SQL
> Profile over it.  A couple of weeks later
> there was a performance issue within the same job but using a different
> sql_id. I have recognized that big query and asked
> the end user whether it is the same query as the one I have SQL Profiled
> the last couple of weeks; and the answer was yes with an addition of a
> couple of few new clients in the varying IN-LIST.
>
> I have then transferred the plan of the SQL Profiled query to the new
> sql_id and the performance was good again.
>
> I have asked, at the same time, the development team to replace the
> IN-LIST with a select from a dedicated table so that the sql_id will not
> change and the SQL Profile will be used.
>
> Best regards
> Mohamed Houri
>
> 2016-11-11 9:28 GMT+01:00 Jonathan Lewis <jonathan@jlcomp.demon.co.uk>:
>
>>
>> Randolf,
>>
>> I had read the question differently, viz: there are always 1000 bind
>> variables of which a limited number are set.
>> Re-reading the original posting, though, I see that your interpretation
>> looks like a better match for the description.
>>
>> Under my interpretation, the abrupt (and dramatic) switch from fast to
>> slow on the 20/21 value break point would simply be due to the optimizer
>> producing a different plan (the typical indexed access/NLJ vs. full
>> tablescan/HJ type of thing) if if had to optimize for a slightly larger
>> predicted data set - making the day's workload dependent on the size of the
>> first set of values used.
>>
>>
>> Regards
>> Jonathan Lewis
>>
>> ________________________________________
>> From: oracle-l-bounce@freelists.org <oracle-l-bounce@freelists.org> on
>> behalf of Randolf Geist <info@www.sqltools-plusplus.org>
>> Sent: 11 November 2016 08:13:13
>> To: ecandrietta@gmail.com
>> Cc: oracle-l@freelists.org
>> Subject: Re: How to force Oracle generate a new execution plan
>>
>> Hi Eriovaldo,
>>
>> you've got already answers to your specific questions, however the way I
>> you understand your description these answers won't necessarily help you
>> with your problem.
>>
>> If your application issues the dynamic query using a variable length IN
>> list of bind variables (so e.g. uses IN (:b1, :b2, :b3) in case of three
>> members, IN (:b1, :b2, :b3, :b4) in case of four members etc.) then you
>> effectively end up with different SQL texts / SQL_IDs for each of these
>> variations - so you actually don't re-use any of the plans potentially
>> already available in the Shared Pool, except for those cases where you
>> issue the statement with the same number of bind variables but
>> different/same bind values.
>>
>> Hence your problem is very likely related to different execution plans
>> being generated for the different variations / SQL_IDs, but it could
>> also be a optimization / hard parse issue - sometimes with a higher
>> number of bind variables the optimizer might take very long to come up
>> with an execution plan.
>>
>> So as a first step you need to identify what the problem actually is
>> (bad execution plan, hard parse, something else) by measuring where the
>> time goes e.g. via SQL trace, or maybe via Active Session History if you
>> have an Enterprise Edition plus Diagnostic Pack license, then you can
>> decide what measures you have at your disposal.
>>
>> Randolf
>>
>> > 1.) How can I do to force Oracle always generate a new execution plan
>> and
>> > not reuse the plan that is in cache ?
>> > 2.) Is there a way to clear a execution plan for a specific sql_id ? (I
>> > have the sql_id that supose is with the bad execution plan).
>> --
>> http://www.freelists.org/webpage/oracle-l
>>
>>
>> --
>> http://www.freelists.org/webpage/oracle-l
>>
>>
>>
>
>
> --
>
> Houri Mohamed
>
> Oracle DBA-Developer-Performance & Tuning
>
> Member of Oraworld-team <http://www.oraworld-team.com/>
>
> Visit My         - Blog <http://www.hourim.wordpress.com/>
>
> Let's Connect -  <http://fr.linkedin.com/pub/mohamed-houri/11/329/857/>*Linkedin
> Profile <http://fr.linkedin.com/pub/mohamed-houri/11/329/857/>*
>
> My Twitter <https://twitter.com/MohamedHouri>      - MohamedHouri
> <https://twitter.com/MohamedHouri>
>
>
>

--94eb2c04791c38652f0541044bd6
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_default" style=3D"font-family:&quot;tr=
ebuchet ms&quot;,sans-serif">Hello,=C2=A0</div><div class=3D"gmail_default"=
 style=3D"font-family:&quot;trebuchet ms&quot;,sans-serif"><br></div><div c=
lass=3D"gmail_default" style=3D"font-family:&quot;trebuchet ms&quot;,sans-s=
erif">I will suggest to development the use of a temporary table =C2=A0in o=
rder to get the same plan for all executions.<br></div><div class=3D"gmail_=
default" style=3D"font-family:&quot;trebuchet ms&quot;,sans-serif">For my s=
cenary it seems to be the best way.</div><div class=3D"gmail_default" style=
=3D"font-family:&quot;trebuchet ms&quot;,sans-serif"><br></div><div class=
=3D"gmail_default" style=3D"font-family:&quot;trebuchet ms&quot;,sans-serif=
">Thanks for answers.<br></div><div class=3D"gmail_default" style=3D"font-f=
amily:&quot;trebuchet ms&quot;,sans-serif"><br></div><div class=3D"gmail_de=
fault" style=3D"font-family:&quot;trebuchet ms&quot;,sans-serif">Regards</d=
iv><div class=3D"gmail_default" style=3D"font-family:&quot;trebuchet ms&quo=
t;,sans-serif">Eriovaldo</div></div><div class=3D"gmail_extra"><br><div cla=
ss=3D"gmail_quote">2016-11-11 6:44 GMT-02:00 Mohamed Houri <span dir=3D"ltr=
">&lt;<a href=3D"mailto:mohamed.houri@gmail.com" target=3D"_blank">mohamed.=
houri@gmail.com</a>&gt;</span>:<br><blockquote class=3D"gmail_quote" style=
=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=
=3D"ltr"><div>Randolf,</div><div><br></div><div>Yes you&#39;re right. And =
=C2=A0I have been very often confronted to such a situation in the last cou=
ple of years.</div><div><br></div><div>I have optimized an overnight query =
with a varying IN-LIST and fixed a SQL Profile over it.=C2=A0 A couple of w=
eeks later</div><div>there was a performance issue within the same job but =
using a different sql_id. I have recognized that big query and asked</div><=
div>the end user whether it is the same query as the one I have SQL Profile=
d the last couple of weeks; and the answer was yes with an addition of a co=
uple of few new clients in the varying IN-LIST.</div><div><br></div><div>I =
have then transferred the plan of the SQL Profiled query to the new sql_id =
and the performance was good again.</div><div><br></div><div>I have asked, =
at the same time, the development team to replace the IN-LIST with a select=
 from a dedicated table so that the sql_id will not change and the SQL Prof=
ile will be used.</div><div><br></div><div>Best regards</div><div>Mohamed H=
ouri</div></div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote"><=
div><div class=3D"h5">2016-11-11 9:28 GMT+01:00 Jonathan Lewis <span dir=3D=
"ltr">&lt;<a href=3D"mailto:jonathan@jlcomp.demon.co.uk" target=3D"_blank">=
jonathan@jlcomp.demon.co.uk</a>&gt;</span>:<br></div></div><blockquote clas=
s=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;pad=
ding-left:1ex"><div><div class=3D"h5"><br>
Randolf,<br>
<br>
I had read the question differently, viz: there are always 1000 bind variab=
les of which a limited number are set.<br>
Re-reading the original posting, though, I see that your interpretation loo=
ks like a better match for the description.<br>
<br>
Under my interpretation, the abrupt (and dramatic) switch from fast to slow=
 on the 20/21 value break point would simply be due to the optimizer produc=
ing a different plan (the typical indexed access/NLJ vs. full tablescan/HJ =
type of thing) if if had to optimize for a slightly larger predicted data s=
et - making the day&#39;s workload dependent on the size of the first set o=
f values used.<br>
<br>
<br>
Regards<br>
Jonathan Lewis<br>
<br>
______________________________<wbr>__________<br>
From: <a href=3D"mailto:oracle-l-bounce@freelists.org" target=3D"_blank">or=
acle-l-bounce@freelists.org</a> &lt;<a href=3D"mailto:oracle-l-bounce@freel=
ists.org" target=3D"_blank">oracle-l-bounce@freelists.org</a><wbr>&gt; on b=
ehalf of Randolf Geist &lt;<a href=3D"mailto:info@www.sqltools-plusplus.org=
" target=3D"_blank">info@www.sqltools-plusplus.or<wbr>g</a>&gt;<br>
Sent: 11 November 2016 08:13:13<br>
To: <a href=3D"mailto:ecandrietta@gmail.com" target=3D"_blank">ecandrietta@=
gmail.com</a><br>
Cc: <a href=3D"mailto:oracle-l@freelists.org" target=3D"_blank">oracle-l@fr=
eelists.org</a><br>
Subject: Re: How to force Oracle generate a new execution plan<br>
<div><div class=3D"m_-8498349901004172929h5"><br>
Hi Eriovaldo,<br>
<br>
you&#39;ve got already answers to your specific questions, however the way =
I<br>
you understand your description these answers won&#39;t necessarily help yo=
u<br>
with your problem.<br>
<br>
If your application issues the dynamic query using a variable length IN<br>
list of bind variables (so e.g. uses IN (:b1, :b2, :b3) in case of three<br=
>
members, IN (:b1, :b2, :b3, :b4) in case of four members etc.) then you<br>
effectively end up with different SQL texts / SQL_IDs for each of these<br>
variations - so you actually don&#39;t re-use any of the plans potentially<=
br>
already available in the Shared Pool, except for those cases where you<br>
issue the statement with the same number of bind variables but<br>
different/same bind values.<br>
<br>
Hence your problem is very likely related to different execution plans<br>
being generated for the different variations / SQL_IDs, but it could<br>
also be a optimization / hard parse issue - sometimes with a higher<br>
number of bind variables the optimizer might take very long to come up<br>
with an execution plan.<br>
<br>
So as a first step you need to identify what the problem actually is<br>
(bad execution plan, hard parse, something else) by measuring where the<br>
time goes e.g. via SQL trace, or maybe via Active Session History if you<br=
>
have an Enterprise Edition plus Diagnostic Pack license, then you can<br>
decide what measures you have at your disposal.<br>
<br>
Randolf<br>
<br>
&gt; 1.) How can I do to force Oracle always generate a new execution plan =
and<br>
&gt; not reuse the plan that is in cache ?<br>
&gt; 2.) Is there a way to clear a execution plan for a specific sql_id ? (=
I<br>
&gt; have the sql_id that supose is with the bad execution plan).<br>
--<br>
<a href=3D"http://www.freelists.org/webpage/oracle-l" rel=3D"noreferrer" ta=
rget=3D"_blank">http://www.freelists.org/webpa<wbr>ge/oracle-l</a><br>
<br>
<br>
</div></div></div></div><span class=3D"HOEnZb"><font color=3D"#888888">--<b=
r>
<a href=3D"http://www.freelists.org/webpage/oracle-l" rel=3D"noreferrer" ta=
rget=3D"_blank">http://www.freelists.org/webpa<wbr>ge/oracle-l</a><br>
<br>
<br>
</font></span></blockquote></div><span class=3D""><br><br clear=3D"all"><di=
v><br></div>-- <br><div class=3D"m_-8498349901004172929gmail_signature" dat=
a-smartmail=3D"gmail_signature"><div dir=3D"ltr"><div><div dir=3D"ltr"><p s=
tyle=3D"margin:0cm;margin-bottom:.0001pt"><span style=3D"font-size:10pt;fon=
t-family:Arial,sans-serif">Houri Mohamed=C2=A0</span></p><p style=3D"margin=
:0cm 0cm 0.0001pt"><span style=3D"font-size:10pt;font-family:Arial,sans-ser=
if">Oracle
DBA-Developer-Performance &amp; Tuning=C2=A0</span></p><p style=3D"margin:0=
cm;margin-bottom:.0001pt">



</p><p style=3D"margin:0cm 0cm 0.0001pt"><span style=3D"font-size:10pt;font=
-family:Arial,sans-serif">Member
of=C2=A0<span style=3D"color:#1155cc"><a href=3D"http://www.oraworld-team.c=
om/" target=3D"_blank">Oraworld-team</a></span></span></p>

<p style=3D"margin:0cm;margin-bottom:.0001pt"><span style=3D"font-size:10pt=
;font-family:Arial,sans-serif">Visit My =C2=A0 =C2=A0 =C2=A0
=C2=A0 -=C2=A0<a href=3D"http://www.hourim.wordpress.com/" target=3D"_blank=
">Blog</a></span></p><p style=3D"margin:0cm 0cm 0.0001pt"><span style=3D"fo=
nt-size:10pt;font-family:Arial,sans-serif">Let&#39;s
Connect -<a href=3D"http://fr.linkedin.com/pub/mohamed-houri/11/329/857/" t=
arget=3D"_blank">=C2=A0</a><u><a href=3D"http://fr.linkedin.com/pub/mohamed=
-houri/11/329/857/" target=3D"_blank">Linkedin
Profile</a></u></span></p><p style=3D"margin:0cm;margin-bottom:.0001pt">



</p><p style=3D"margin:0cm 0cm 0.0001pt"><span style=3D"font-size:10pt;font=
-family:Arial,sans-serif">My=C2=A0<a href=3D"https://twitter.com/MohamedHou=
ri" target=3D"_blank"><span style=3D"color:windowtext">Twitter</span></a>=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 -<span>=C2=A0</span><a href=3D"https://twitt=
er.com/MohamedHouri" target=3D"_blank">MohamedHouri</a></span></p><p style=
=3D"margin:0cm 0cm 0.0001pt"><img src=3D"https://docs.google.com/uc?export=
=3Ddownload&amp;id=3D0B9S_l_uP8T7XVDBIVFZYNTRTZ2s&amp;revid=3D0B9S_l_uP8T7X=
dU8vTW9MMEtYa2VEdGV3aFFJdmxobm5qaThjPQ"><br></p><p style=3D"margin-bottom:0=
.0001pt;background-repeat:initial initial"><span style=3D"font-size:10.0pt;=
font-family:&quot;Arial&quot;,&quot;sans-serif&quot;"></span></p></div></di=
v></div></div>
</span></div>
</blockquote></div><br></div>

--94eb2c04791c38652f0541044bd6--
--
http://www.freelists.org/webpage/oracle-l


