Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 45417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T15:48:22+00:00 2026-05-10T15:48:22+00:00

Before, I have found the Cost in the execution plan to be a good

  • 0

Before, I have found the ‘Cost’ in the execution plan to be a good indicator of relative execution time. Why is this case different? Am I a fool for thinking the execution plan has relevance? What specifically can I try to improve v_test performance?

Thank you.

Using Oracle 10g I have a simple query view defined below

  create or replace view v_test as   select distinct u.bo_id as bo_id, upper(trim(d.dept_id)) as dept_id   from       cust_bo_users u   join cust_bo_roles r on u.role_name=r.role_name   join cust_dept_roll_up_tbl d on                              (r.region is null or trim(r.region)=trim(d.chrgback_reg)) and                              (r.prod_id is null or trim(r.prod_id)=trim(d.prod_id)) and                             (r.div_id is null or trim(r.div_id)=trim(d.div_id )) and                             (r.clus_id is null or trim(r.clus_id )=trim( d.clus_id)) and                             (r.prod_ln_id is null or trim(r.prod_ln_id)=trim(d.prod_ln_id)) and                             (r.dept_id is null or trim(r.dept_id)=trim(d.dept_id)) 

defined to replace the following view

        create or replace view v_bo_secured_detail   select distinct Q.BO_ID, Q.DEPT_ID   from (select U.BO_ID BO_ID, UPPER(trim(D.DEPT_ID)) DEPT_ID         from CUST_BO_USERS U, CUST_BO_ROLES R, CUST_DEPT_ROLL_UP_TBL D         where U.ROLE_NAME = R.ROLE_NAME and                 R.ROLE_LEVEL = 'REGION' and                 trim(R.REGION) = UPPER(trim(D.CHRGBACK_REG))         union all         select U.BO_ID BO_ID, UPPER(trim(D.DEPT_ID)) DEPT_ID         from CUST_BO_USERS U, CUST_BO_ROLES R, CUST_DEPT_ROLL_UP_TBL D         where U.ROLE_NAME = R.ROLE_NAME and                 R.ROLE_LEVEL = 'RG_PROD' and                 trim(R.REGION) = UPPER(trim(D.CHRGBACK_REG)) and                 trim(R.PROD_ID) = UPPER(trim(D.PROD_ID))         union all         select U.BO_ID BO_ID, UPPER(trim(D.DEPT_ID)) DEPT_ID         from CUST_BO_USERS U, CUST_BO_ROLES R, CUST_DEPT_ROLL_UP_TBL D         where U.ROLE_NAME = R.ROLE_NAME and                 R.ROLE_LEVEL = 'PROD' and                 trim(R.PROD_ID) = UPPER(trim(D.PROD_ID))         union all         select U.BO_ID BO_ID, UPPER(trim(D.DEPT_ID)) DEPT_ID         from CUST_BO_USERS U, CUST_BO_ROLES R, CUST_DEPT_ROLL_UP_TBL D         where U.ROLE_NAME = R.ROLE_NAME and                 R.ROLE_LEVEL = 'DIV' and                 trim(R.DIV_ID) = UPPER(trim(D.DIV_ID))         union all         select U.BO_ID BO_ID, UPPER(trim(D.DEPT_ID)) DEPT_ID         from CUST_BO_USERS U, CUST_BO_ROLES R, CUST_DEPT_ROLL_UP_TBL D         where U.ROLE_NAME = R.ROLE_NAME and                 R.ROLE_LEVEL = 'RG_DIV' and                 trim(R.REGION) = UPPER(trim(D.CHRGBACK_REG)) and                 trim(R.DIV_ID) = UPPER(trim(D.DIV_ID))         union all         select U.BO_ID BO_ID, UPPER(trim(D.DEPT_ID)) DEPT_ID         from CUST_BO_USERS U, CUST_BO_ROLES R, CUST_DEPT_ROLL_UP_TBL D         where U.ROLE_NAME = R.ROLE_NAME and                 R.ROLE_LEVEL = 'CLUS' and                 trim(R.CLUS_ID) = UPPER(trim(D.CLUS_ID))         union all         select U.BO_ID BO_ID, UPPER(trim(D.DEPT_ID)) DEPT_ID         from CUST_BO_USERS U, CUST_BO_ROLES R, CUST_DEPT_ROLL_UP_TBL D         where U.ROLE_NAME = R.ROLE_NAME and                 R.ROLE_LEVEL = 'RG_CLUS' and                 trim(R.REGION) = UPPER(trim(D.CHRGBACK_REG)) and                 trim(R.CLUS_ID) = UPPER(trim(D.CLUS_ID))         union all         select U.BO_ID BO_ID, UPPER(trim(D.DEPT_ID)) DEPT_ID         from CUST_BO_USERS U, CUST_BO_ROLES R, CUST_DEPT_ROLL_UP_TBL D         where U.ROLE_NAME = R.ROLE_NAME and                 R.ROLE_LEVEL = 'PROD_LN' and                 trim(R.PROD_LN_ID) = UPPER(trim(D.PROD_LN_ID))         union all         select U.BO_ID BO_ID, UPPER(trim(R.DEPT_ID)) DEPT_ID         from CUST_BO_USERS U, CUST_BO_ROLES R         where U.ROLE_NAME = R.ROLE_NAME and                 R.ROLE_LEVEL = 'DEPT') Q 

with the goal of removing the dependency on the ROLE_LEVEL column.

The execution plan for v_test is significantly lower than v_bo_secured_detail for simple

select * from <view> where bo_id='value' 

queries. And is significantly lower when used in a real world query

  select CT_REPORT.RPT_KEY,          CT_REPORT_ENTRY.RPE_KEY,          CT_REPORT_ENTRY.CUSTOM16,          Exp_Sub_Type.value,          min(CT_REPORT_PAYMENT_CONF.PAY_DATE),          CT_REPORT.PAID_DATE   from CT_REPORT,       <VIEW> SD,       CT_REPORT_ENTRY,       CT_LIST_ITEM_LANG Exp_Sub_Type,       CT_REPORT_PAYMENT_CONF,       CT_STATUS_LANG Payment_Status   where (CT_REPORT_ENTRY.RPT_KEY = CT_REPORT.RPT_KEY) and         (Payment_Status.STAT_KEY = CT_REPORT.PAY_KEY) and         (Exp_Sub_Type.LI_KEY = CT_REPORT_ENTRY.CUSTOM9 and Exp_Sub_Type.LANG_CODE = 'en') and         (CT_REPORT.RPT_KEY = CT_REPORT_PAYMENT_CONF.RPT_KEY) and         (SD.BO_ID = 'JZHU9') and         (SD.DEPT_ID = UPPER(CT_REPORT_ENTRY.CUSTOM5)) and         (Payment_Status.name = 'Payment Confirmed' and (Payment_Status.LANG_CODE = 'en') and         CT_REPORT.PAID_DATE > to_date('01/01/2008', 'mm/dd/yyyy') and Exp_Sub_Type.value != 'Korea')   group by CT_REPORT.RPT_KEY,             CT_REPORT_ENTRY.RPE_KEY,             CT_REPORT_ENTRY.CUSTOM16,             Exp_Sub_Type.value,             CT_REPORT.PAID_DATE 

The execution times are WILDLY different. The v_test view taking 15 hours, and the v_bo_secured_detail taking a few seconds.


Thank you all who responded

This is one to remember for me. The places where the theory and mathematics of the expressions meets the reality of hardware based execution. Ouch.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T15:48:22+00:00Added an answer on May 10, 2026 at 3:48 pm

    As the Oracle documentation says, the cost is the estimated cost relative to a particular execution plan. When you tweak the query, the particular execution plan that costs are calculated relative to can change. Sometimes dramatically.

    The problem with v_test’s performance is that Oracle can think of no way to execute it other than performing a nested loop, for each cust_bo_roles, scan all of cust_dept_roll_up_tbl to find a match. If the table are of size n and m, this takes n*m time, which is slow for large tables. By contrast v_bo_secured_detail is set up so that it is a series of queries, each of which can be done through some other mechanism. (Oracle has a number it may use, including using an index, building a hash on the fly, or sorting the datasets and merging them. These operations are all O(n*log(n)) or better.) A small series of fast queries is fast.

    As painful as it is, if you want this query to be fast then you need to break it out like the previous query did.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 69k
  • Answers 69k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer ActiveMQ has support for message groups which, quite literally, should… May 11, 2026 at 12:27 pm
  • added an answer Set a filemon (http://technet.microsoft.com/en-us/sysinternals/bb896642.aspx) to monitor 'C:\dummy.xml'. When you'll get… May 11, 2026 at 12:27 pm
  • added an answer Read the man page : -c stands for create -v… May 11, 2026 at 12:27 pm

Related Questions

I am pretty sure I have seen this before, but I haven't found out
This question has been asked before ( link ) but I have slightly different
I want to get smarter in AJAX, but not sure which way to go.
I'm beginning a project right now that will require a pretty extensive web back

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.