DBAsupport.com Forums - Powered by vBulletin
Results 1 to 6 of 6

Thread: Cost is high still gets executed fast !!!

  1. #1
    Join Date
    May 2008
    Posts
    2

    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.

  2. #2
    Join Date
    Sep 2002
    Location
    England
    Posts
    7,334
    no examples, no proof, no traces - no help

  3. #3
    Join Date
    Mar 2007
    Location
    Ft. Lauderdale, FL
    Posts
    3,555
    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.

  4. #4
    Join Date
    Jul 2002
    Location
    Lake Worth, FL
    Posts
    1,492

    Talking

    It's obvious:

    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

  5. #5
    Join Date
    May 2008
    Posts
    2

    Trace file attached

    Quote Originally Posted by davey23uk
    no examples, no proof, no traces - no help
    Please find attached trace file for your perusal.
    Attached Files Attached Files

  6. #6
    Join Date
    May 2000
    Location
    ATLANTA, GA, USA
    Posts
    3,135
    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:

    Try this:

    Code:
    SQL>  SELECT  /*+ ordered */ DISTINCT
      2                  dmc.dmc_fds_id,
      3                  asmc.asm_smv_id,
      4                  asmc.asm_sho_id,
      5                  asmc.asm_smv_smc_id,
      6                asmc.asm_tpr_from,
      7                asmc.asm_tpr_to
      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')
    SQL> /

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width