fre, 18/02/2011 - 11:51
Maria Colgan from the Oracle Optimizer Group wrote an excellent blog post explaining how to deal with applications that have embedded hints leading to poor execution plans. The very same day, coincidentally, one of my customers was having a problem with a SQL that started to perform badly after a new index was added. The problem was caused by the first_rows hint that made the optimizer choose the wrong index.
Query without hint, uses the correct index I_062INVOICEACCOUNTREFNUMIDX
SQL> select * from table(Dbms_Xplan.display); PLAN_TABLE_OUTPUT-------------------------------- Plan hash value: 3005292771 ------------------------------------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ------------------------------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 712 | 6 (17)| 00:00:01 | | 1 | SORT ORDER BY | | 1 | 712 | 6 (17)| 00:00:01 | | 2 | TABLE ACCESS BY INDEX ROWID| CUSTINVOICEJOUR | 1 | 712 | 5 (0)| 00:00:01 | |* 3 | INDEX RANGE SCAN | I_062INVOICEACCOUNTREFNUMIDX | 1 | | 4 (0)| 00:00:01 | -------------------------------------------------------------------------------------------------------------
PLAN_TABLE_OUTPUT----------------------------------Plan hash value: 2733576580----------------------------------------------------------------------------------------------------| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |----------------------------------------------------------------------------------------------------| 0 | SELECT STATEMENT | | 1 | 712 | 51096 (1)| 00:10:14 ||* 1 | TABLE ACCESS BY INDEX ROWID | CUSTINVOICEJOUR | 1 | 712 | 51096 (1)| 00:10:14 ||* 2 | INDEX RANGE SCAN DESCENDING| I_062SALESIDDATEIDX | 338K| | 1819 (1)| 00:00:22 |----------------------------------------------------------------------------------------------------
In 11g we can use SQL Plan Management (SPM) to make Oracle choose the correct execution plan, as Maria Colgan described in her blog post. In 10g and 9i we must use stored outlines. With the help of stored outlines the database can lock one execution plan for a SQL.
In order to generate an outline we must be able to run the query with the correct plan and the correct hash value. This means we must run the SQL as it is run from the application with the hint, and get the execution plan without the hint.
The "magic" here is the hidden parameter _optimizer_ignore_hints. This way we can execute the SQL with the hint, generate the same plan as we do without the hint, and lock this with an outline.
I'm running this on an account with system privileges:
SQL> alter session set current_schema=username;
Session altered.
SQL> alter session set "_optimizer_ignore_hints" = true; Session altered. SQL> create outline custinvoicejour_firstrow on SELECT /*+ FIRST_ROWS */ a.custgroup, ...snip... Outline created. SQL> SELECT name, category, sql_text FROM dba_outlines; NAME CATEGORY SQL_TEXT ------------------------------ ------------------------------ --------------------------------------- CUSTINVOICEJOUR_FIRSTROW DEFAULT SELECT /*+ first_rows */a .custgroup,... SQL> SELECT name, category, used FROM dba_outlines; NAME CATEGORY USED ------------------------------ ------------------------------ ------ CUSTINVOICEJOUR_FIRSTROW DEFAULT UNUSED
To make the database follow the outline, the parameter use_stored_outlines must be set. When the outline is put in use, the status in dba_outlines will change. It might be a good idea to recreate the outline after it has been tested, so that we know the users are taking advantage of the plan in the outline.
SQL> alter system set use_stored_outlines=DEFAULT ; System altered. SQL> SELECT name, category, used FROM dba_outlines NAME CATEGORY USED ------------------------------ ------------------------------ ------ CUSTINVOICEJOUR_FIRSTROW DEFAULT USED
Kommentarer
Re:
I agree, respect! Thanks. cigarettes online free shipping / viagra / buy cigarettes
Red Bottom shoes
Help and motivate a competent and high performance Red Bottom shoes combination. Two types want to leave a good impression, both task (the task of the second type is often around people round and round), and organized for the purpose, so they both work efficiency, like the job done, and attract interesting, high-level person to join the camp, they continue to prove capable, but they may also be in pursuit of their desires which mercilessly run over other people to Red Bottoms achieve the target is not important.
christian louboutin sale
If you are a second type of employees you Red Bottom shoes have to inform you the second type of boss you network, bit by bit, in particular, you have to pay for his efforts. The trouble is that this relationship often happens that the second type of staff to the name of the boss's signature, or ratification of, but forgot to tell the boss, the boss caught off guard, which is comprehensive, focusing on relationships and the image of the second type of boss, it is embarrassing scene. christian louboutin sale All types of employees can do not hesitate to apologize, and learn its lesson.
Re:
Great site, respect! cheap drugs order viagra soft fast delivery buy cialis professional discount prices viagra pfizer online pharmacy.
respond this post
Your entire spectacle is
Your entire spectacle is normally remarkable and additionally code-cracking renegade, cheap ray ban sunglasses ever since open industry dash through equal law regulations like almost every: cultivate or possibly die-off. This challenge to be beautiful for reputation comes with commanded nearly every one of Minaj’s flummoxed emcee predecessors one another solution, right into smaller whirlpools about self-caricature. (See, using Kim and additionally Elliott, MC Lyte, Da Brat, and additionally Foxy Grey. )With Nicki, all the slideshow range about caricatures is indeed , blinding you will get rid of excess sight for the people going through all the puppet-mastering. ray ban cheap And thoughtful: Within the movies civilization put together because of a decades-long authenticity abs run, this girl makes you fail, in conclusion, all the essentialist topic. So, who Nicki is normally is far a lot less valuable when compared to the things the lady with, which is certainly really recognized. http://www.rayban-sunglassescheap.com/
Re:
Thanks for sharing. professional cialis
Re:
Nice post, respect, thanks! levitra price
sample
pea phenylethylamine methylhexamine erowid
buy clarinet repair kit
milligram yohimbine hcl dosage
schisandra chinensis
the outline, the parameter use_stored_outlines must be set. When the outline is put in use, the status in dba_outlines will change
Re:
Of course I like this web-site. professional speed dating london / serious relationship dating sites / free black herpes dating sites / relationship dating forums / dating definition relationships / speed dating nyc new york city / internet dating rules
Re:
I often read your blog and always find it very interesting. Keep up the great work internet dating sites reviews / dating questions to ask a girl / free online dating services / free dating site fish sea / friends reunited dating site
Re:
I have truely enjoyed getting to know you and I pray for you! chat dating room live dating chat top 10 free chat dating sites dating chat lines black uk dating online
Re:
Nice stuff you got, very interesting to read. viagra super active / order viagra professional / order cialis soft / levitra online / order viagra online / generic viagra / viagra online / buy cialis brand
Re:
Amazing Webpage, Thx! Keep up the good work. cialis professional buy viagra soft order brand cialis brand viagra
Re:
Usefull post. I bookmark this page. buy generic viagra generic cialis buy levitra online order viagra professional propecia online
answer
Cheap Supra Shoes
Cheap Supra Shoes Men's Supra Shoes Supra Cuttler Supra Pilot Supra Society Supra Society Mid Supra TK Society Supra Vaider Women' Supra Shoes Super Skytop Justin Bieber Supra Shoes
Payday Loan
cialis
Payday loans
cialis tadalafil
Lacoste Polo Shirts uk
Look sporty and elegant with cheap Lacoste sale from us, fgjhntd <a href="http://www.lacostepoloshirts.co.uk/">cheap Lacoste Polo Shirts</a>
Giants Super Bowl Jersey
Giants Super Bowl Jersey With over 80 years of team history Eli Manning Jersey, the Giants are currently members of the Eastern Division of the National Football Conference in the NFL Tom Brady Jersey. The Gaints was one Jason Pierre-Paul Jersey of the greatest team in NFL history With Victor Cruz Jersey over 80 years of team history Hakeem Nicks Jersey, the Giants are currently members of the Eastern Division of the National Football Conference in the NFL Lawrence Taylor Jersey The Gaints was one of the greatest team in NFL history, it ranks third among all NFL franchises BenJarvus Green-Ellis Jersey, their championship only is surpassed by the Green Bay Packers and Chicago Bears. The Giants had 15 Hall of Fame players , including NFL MVP award winners Justin Tuck Jersey Mel Hein, Frank Gifford, Kevin Boss Jersey Charlie Conerly, Y. A. Tittle, and Lawrence Taylor. During their history, the New York Giants have used numerous uniforms and logos. Ahmad Bradshaw Jersey Antrel Rolle Jersey Brandon Jacobs Jersey Carl Banks Jersey Danny Clark Jersey Harry Carson Jersey Kenny Phillips Jersey Mario Manningham Jersey Mark Bavaro Jersey Michael Strahan Jersey Osi Umenyiora Jersey Phil Simms Jersey Plaxico Burress Jersey Prince Amukamara Jersey Steve Smith Jersey Tiki Barber Jersey You will find a great selection of NFL apparel including NFL throwback jerseys and more of your favorite NFL gear here.
payday loans online
viagra
cash advance
propecia on line
cialis en ligne
YATFsCsSoSCXx
EfHFubnUXOeVAQ
accutane
payday loans
cialis
payday loans UK
NuuVtbNYmUkVYZ
viagra
buy sildenafil cheap
cash advance
xpdgeb
answer this post
cialis
lwvfcuvHOJoocKllT
KZpJHctKqxnPs
uZKMtBhTwDavp
yjEUrYoimsq
XByEdKaLNvTC
qzbUNnLVrQnFUvQ
TbKmgtoHzRKBktCbdZ
GzoeFADhdOWzHlkecUX
CZauqbzjfxpar