Re: Plan changed After creating profile
Date: Sat, 2 Oct 2021 09:17:18 +0100
Message-ID: <CAGtsp8kOuWaMcUPC7CTvnFuHv-4sxBCf9XAo6i8O=y22N=_xkA_at_mail.gmail.com>
Thanks for posting the profile content.
That's a "proper" SQL Profile produced by the dbms_sqltune so all it's
doing is adjusting the optimizer's arithmetic and letting the optimizer
pick the best plan based on the estimates it produced.
If I understand correctly, this profile was created while the database was
running 11.2.0.4, and since then you've upgraded to 19.9 and more recently
to 19.11. After the upgrade the query was performing adequately for a few
months but has suddenly started to perform badly.
The most common problem with the optimizer is that a small change in the
data and/or the stats about the data can result in a huge change in
performance. This can happen at any time on any version of Oracle. Trivial
example:
if the optimizer thinks table X will return 99 rows it will use a nested
loop and indexed access into table Y; if it thinks that table X will return
100 rows then it will use a hash join with a tablescan of table Y. The
change in plan is a good idea in principle - but shouldn't actually happen
until table X returns more than 1,000 rows and the optimizer has decided to
do the switch too soon because the arithmetic about table Y says the
indexed access will fetch too many rows, or visit too many table blocks.
This type of arithmetic error can still happen after you've created the
profile - it's just that it probably won't happen because the profile has
been carefully constructed to make the final arithmetic as realistic as
possible. HOWEVER - when you upgrade, you will find that the optimizer (a)
may have gathered stats differently and (b) may have some corrections
applied to the way it does the arithmetic and (c) may have some new options
for transformations. This gives you three different ways in which the
"corrections" supplied by the profile may no longer be good enough to allow
the optimizer to produce a sensible plan all the time.
Examples of change on the upgrade
Suggestions
Regards
On Fri, 1 Oct 2021 at 18:47, Krishnaprasad Yadav <chrishna0007_at_gmail.com>
wrote:
> Hi All,
a) If your stats gather is using default methods you may now have
top-frequency or hybrid histograms where you used to have height-balanced
histograms; this can make a huge difference to cardinality estimates.
b) An automatic job may have created some column group stats - which can
make a huge difference
c) various subqueries can unnest in 19c that could not unnest in 11g, and
the aritmetic of calculating costs of executing filter subqueries has
changed so the profile could have a dramatically different effect on the
plan than it used to.
Jonathan Lewis
>
> Below is extract from Hint :
>
> PLAN_NAME SIGNATURE OPT_TYPE CATEGORY
> PLAN_ID HINT
> ---------- ---------- --------------------------------
> -------------------- ----------
> --------------------------------------------------
> SYS_SQLPRO 1.3066E+19 Profile DEFAULT
> 0 OPT_ESTIMATE(_at_"SEL$2", INDEX_SCAN, "AUDITTRA
> F_014d7f18
> IL"_at_"SEL$2", "IX_AUDITNAME", SCALE_ROWS=127210
> a95d0000
> .5501)
>
> ...
-- http://www.freelists.org/webpage/oracle-lReceived on Sat Oct 02 2021 - 10:17:18 CEST