Cost is high still gets executed fast !!!
I am working on a query to tune: existing query in the production with correlated subquery is taking 32 seconds to execute, I changed the query by using inline view without changing any conditions and functionality. Then it took 18 seconds. Involved tables are very huge and has millions of records. Want to know the following.
1. Even though the second query comes out in 18 seconds, but physical i/o and logical i/o (consistent gets) are very high compared to first query which is taking more time (32 seconds). Why is this happening. Can you please explain.
2. I can see the benifit only in terms of memory sorts: in the second query it got reduced drastically.
Expecting soon reply on this, and thanks in advance.
no examples, no proof, no traces - no help
Support Davey; anyone with the ability of guessing the right answer to your question with such lack of supporting documentation would rather be in Vegas making millions.
Pablo (Paul) Berzukov
Author of Understanding Database Administration
available at amazon and other bookstores.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
A knowing vintage evolves optimizer. Query shifts! Optimizer twists with query. Query rests across optimizer. A signed sheep fleshes the trolley next to the justified yawn. Optimizer farms query in a dubious documentary.
Courtesy of: Creativity Tools
"The person who says it cannot be done should not interrupt the person doing it." --Chinese Proverb
Trace file attached
Please find attached trace file for your perusal.
Originally Posted by davey23uk
In the first execution plan, the sub query was executed for each row in the NL. The number of in-memory sort was very high.
The UNION is not needed in the sub query:
SQL> SELECT /*+ ordered */ DISTINCT
8 FROM TRAG_NODE_HIE_MKT mnu,
9 TTAG_DS_MKT_CHARACTERISTIC dmc,
10 TMAG_ASS_SHOP_MAPPED_CHAR asmc
11 WHERE mnu.mnu_level_node_type = 'SHOP'
12 AND -mnu.mnu_mah_id = asmc.asm_sho_id
13 AND dmc.dmc_fds_id = 1017672 -- pFactory_datascope_id
14 AND dmc.dmc_type = 'M'
15 AND dmc.dmc_chr_id = asmc.asm_smv_smc_id
16 AND dmc.dmc_chr_id IN
17 (SELECT mhl_smc_id
18 FROM TTAG_MS_HIERARCHY_LEVEL
19 WHERE mhl_fds_id=1017672 -- pFactory_datascope_id
20 AND mhl_level_type='M'
21 AND mhl_mhi_id=mnu_hii_id
22 UNION ALL
23 SELECT fsh_smc_id
24 FROM TRDS_FDS_SOFT_SHOP_CHAR
25 WHERE fsh_fds_id=1017672 -- pFactory_datascope_id
26* AND fsh_type='M')
Click Here to Expand Forum to Full Width