Hjem

Dealing with hints in 3rd party apps Oracle 10g

Magnus Fagertun

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 |
-------------------------------------------------------------------------------------------------------------
Query with first_rows hint, uses the incorrect index I_062SALESIDDATEIDX
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

Cars and houses are expensive and not everybody can buy it. However, home loans are created to help people in such kind of situations.

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:

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:

Amazing Webpage, Thx! Keep up the good work. cialis professional buy viagra soft order brand cialis brand viagra

Re:

answer

People deserve good life and business loans or financial loan would make it much better. Because freedom is based on money state.

Payday Loan

lppkhvw Payday Loan 6222 payday loans 4612 payday loans 3686 Payday Loans UK ROuoJ

cialis

ewvohz cialis >:-[ viagra :-O viagra prices 9267 cheap generic cialis %-[[[

Payday loans

gtynem Payday loans >:-OOO payday loans 2074 Payday loan UK 8886

cialis tadalafil

hvtlngtg cialis tadalafil =-] viagra gUGZQ generic cialis :-O cialis >:-[

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

ejxwdem viagra 8]]] viagra 7813 cialis fMnblI viagra %-[[[ viagra uk 6264 levitra ivtaZr

cash advance

rpccxkcx cash advance lTupd payday loans 8193 payday loans 9519 payday loans kVOAd

propecia on line

hrpvrzwu propecia on line 6792 xenical bestellen 2307 amoxil iSMFja viagra toDsDO viagra mLcrVv Levitra 6099

cialis en ligne

uxzxqmk cialis en ligne >:]] cialis 2915 cialis online EzMjZ viagra 5669 viagra 2024 viagra UpxqX

YATFsCsSoSCXx

Hey all of you Hey all of you Michael Jackson fans, I know for a fact that Michael Jackson ayawls slept with little boys every chance he got. Which made him a PEDOPHILE. The little boys he had slept with never told anyone about their abuse cuz they were either 2 ashamed or Michael paid them not to tell anyone. After all Michael Jackson was very rich. But on 06-25-09 Michael Jackson died at age 50, and I'm glad he finally gone where he won't be able to hurt anymore children. Michael Jackson may you Rot In

EfHFubnUXOeVAQ

I have to fisnih labwork and write my thesis. Slow going since I've only been in the lab for like an hour and a half all semester. Am I going to get this done by December?

accutane

gydqhtn accutane 8]]] viagra kcjuGP propecia :-O cialis =-]

payday loans

jlxtbzhm payday loans BwtBY cash advance 4523 payday loans yQQTiK

cialis

jciqkn cialis 5623 buy tadalafil cheap 1270 viagra :-O buy generic viagra >:-OOO

payday loans UK

sagpkp payday loans UK 4756 Payday loans 4618 payday loan jlJku

NuuVtbNYmUkVYZ

There are many pdyaay loan places like Check into Cash, etc. you just have to mapquest it or yahoo it. However please be responsible with pdyaay loans you can even get the online (but you will pay a bigger interest rate). What pdyaay loans do is help you when you are in a crunch (like after the holidays). Usually you get them for two weeks and up to $550. However it depends on how much you make. You have to bring in a valid and current paycheck stub, references, ID, and even sometimes a ultility bill (to prove residency). When you do get one out you write a check for an advance and then get your money. When it is time to pay it they get a fee based on interest for example if you take out $50 you may have to pay back $65, etc.

viagra

vgpnzlox viagra Mcpij cialis online 1105 ordering tadalafil 5753 viagra ZznWr viagra %-[[[ cialis >:-OOO

buy sildenafil cheap

eqlyyrnk http://scheapviagra.com/ viagra EoUnAW cialis %-[[[ [url=http://scheapcialis.com/]cialis[/url] >:]]

cash advance

bwbdbane http://paydayloansinn.co.uk/ Payday Loan XSLLxI car loan >:-[ [url=http://paydayloans24x7.net/]cash advance[/url] 6217

xpdgeb

rtwwut

answer this post

People all over the world get the personal loans in different creditors, because this is fast and easy.

cialis

igmtdk cialis :-O viagra online 5315

lwvfcuvHOJoocKllT

Bravo les filles pour cette energie Corentin est un copain de mon fils Thomas, ce garcon a une peche d'enfer Je vous dis felicitations A bientotBisous discount auto insurance car insurance

KZpJHctKqxnPs

Thanks Heather! I'm obsessed with big, chunky knits. Hopefully one of these days my knitting skills will improve so I can make one myself, but until then I have an incredibly talented grandma to thank. xo cheapest auto insurance florida auto insurance

uZKMtBhTwDavp

I wouldn't be able to get rid of it either! I'm not much of a collector, but when it comes to sentimental items, it's impossible for me to part with them. xo buy ms site tramadol free car insurance quotes

yjEUrYoimsq

Hazel thanks for your note. (LOVE The Sartorialist!!). All black is often the default colour because it's the easier to unify (imagine an ensemble full of slightly different shades of red), it's easy on the eyes, and the audience tends to focus more on the music than if the ensemble were wearing different colours. The problem with saying go for it, wear any colour is what one person considers stylish another will consider completely inappropriate. There there's the issue of colour clashing. And in classical music, there are known stereotypes about what kind of dress is associated with certain types of music. Opera performers (and audiences) tend to go all out with style and flamboyance; Baroque performers (and audiences) tend not to consider fashion a big deal and are very low-key with their apparel. Ultimately, no, I don't think ensembles should be able to wear any colour; then it looks like a rehearsal. tramadol free car insurance quotes

XByEdKaLNvTC

Hi Rosemary,Thank you for updating me on missing classmate Richard Wells. You were right that he was not inthe class of 1962. I had recently emailed his brother Dan, and he informed me that Richard hasbeen teaching and living in China the last six years.Regard, Charlene (Demonet) Fisher florida auto insurance online cialis

qzbUNnLVrQnFUvQ

1.What types of things did the first website ask you to do?The website tells us to read a reversed paragraph in 60 seconds.2.On a scale of 1- 10 how successful were you in completing the tasks? 73.What made completing the task difficult?The letters were reversed, but I made out the words little by little.4.What could the web designer have done to make the site more accessible to you?They made it helpful by informing me of the reversed speech.1.What types of things did the first website ask you to do?It asked me to multi-task.2.On a scale of 1- 10 how successful were you in completing the tasks? 73.What made completing the task difficult?Doing two things at the same time.4.What could the web designer have done to make the site more accessible to you?They could have made it less difficult. affordable auto insurance discount auto insurance

TbKmgtoHzRKBktCbdZ

Amazing blog and very interesting stuff you got here! I definitely learned a lot from reading through some of your earlier posts as well and decided to drop a comment on this one!Anyways, I just signed up for your newsletter and will definitely come back for more. Feel free to do the same for my blog when you get a chance! Also, if your looking to do some guest posting or promoting some of my products definitely check out my site: with Dino Vedo.All the best,Dino Vedo PS: Like my Facebook fan page and follow me on Twitter and I'll do the same for you! tramadol viagra

GzoeFADhdOWzHlkecUX

PwrwoE jovdgclylddn

CZauqbzjfxpar

You are right this kind of eticypnron provides no security a simple regular expression is enough to decrypt it. I even created a sample application to