Struggle to understand the CBO's cost estimates

Hello all
I have a pretty complex query where I struggle to understand the CBO's choices
The middle part which I think should be run first, is a query on a date column, which is indexed by a non-unique normal btree index. But this is only getting chosen is some cases based on the date interval (which in these cases makes the query runs fast), in other cases it's not used, a totallly different plan is then the outcome, and the result is a query which is around 100 times slower
If I take out this middel bit and show a plan for it, its' obvious why.
On some date intervals (which is whole months) the cost is estimated to 4, and on others between 5.000 and 15.000.
Since the number of rows is about the same for each month, and I've just rebuild the index to make sure it's ok, I don't really get why.
This is my simple example
High estimated cost example (count on march):
SELECT COUNT (*) cnt
FROM fmc_pos p
WHERE local_date > TO_DATE ('2010030100', 'yyyymmddhh24')
and local_date < TO_DATE ('2010040100', 'yyyymmddhh24')
Chosen index: IDX_POS_LOCAL_DATE
Estimated cost from plan: 6.394
Estimated index cost from plan: 6.394
Result: 2.718.563
Elapsed time: About 3 sek
Low estimated cost example (count on june):
SELECT COUNT (*) cnt
FROM fmc_pos p
WHERE local_date > TO_DATE ('2010060100', 'yyyymmddhh24')
and local_date < TO_DATE ('2010070100', 'yyyymmddhh24')
Chosen index: IDX_POS_LOCAL_DATE
Estimated cost from plan: 4
Estimated index cost from plan: 4
Result: 2.642.124
Elapsed time: About 3 sek
In both these simple examples the index gets used by the plan, but as you can see the estimated cost is very different, eventhough the number of rows queried is less than 10% different. The execution time is also about the samme
As I mentioned I've just rebuild the index using compute statistics, but that doesn't change anything
Can anybody tell me why the optimizer comes up with costs that are so different on this simple well-balanced index, which then in the full qury makes it choose a very bad plan?
Best Regards
Klaus Mogensen

Yes, this is the version info:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
TNS for Linux: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
If I then run the two queries with the hint, and query the plan results I get this information:
The high estimated cost query:
SQL_ID  0kqjnn0mk2cms, child number 0
SELECT /*+ gather_plan_statistics */ COUNT (*) cnt FROM fmc_pos p WHERE local_date > TO_DATE
('2010030100', 'yyyymmddhh24') and local_date < TO_DATE ('2010040100', 'yyyymmddhh24')
Plan hash value: 3346164428
| Id  | Operation         | Name               | Starts | E-Rows | A-Rows |   A-Time   | Buffers | Reads  |
|   1 |  SORT AGGREGATE   |                    |      1 |      1 |      1 |00:00:05.06 |    7206 |   7204 |
|*  2 |   INDEX RANGE SCAN| IDX_POS_LOCAL_DATE |      1 |   2213K|   2715K|00:00:05.65 |    7206 |   7204 |
Predicate Information (identified by operation id):
   2 - access("LOCAL_DATE">TO_DATE(' 2010-03-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND
              "LOCAL_DATE"<TO_DATE(' 2010-04-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))
The low estimated cost query:
SQL_ID  1w4hx6xsrsr5s, child number 0
SELECT /*+ gather_plan_statistics */ COUNT (*) cnt FROM fmc_pos p WHERE local_date > TO_DATE
('2010060100', 'yyyymmddhh24') and local_date < TO_DATE ('2010070100', 'yyyymmddhh24')
Plan hash value: 3346164428
| Id  | Operation         | Name               | Starts | E-Rows | A-Rows |   A-Time   | Buffers | Reads  |
|   1 |  SORT AGGREGATE   |                    |      1 |      1 |      1 |00:00:02.89 |    7014 |   7012 |
|*  2 |   INDEX RANGE SCAN| IDX_POS_LOCAL_DATE |      1 |     45 |   2642K|00:00:05.32 |    7014 |   7012 |
Predicate Information (identified by operation id):
   2 - access("LOCAL_DATE">TO_DATE(' 2010-06-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND
              "LOCAL_DATE"<TO_DATE(' 2010-07-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))
I'm not sure whcih info this gives me?
Best regards
Klaus Mogensen
Edited by: user12241627 on 16-Jul-2010 04:44                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • Cost component not splitting at the time of Rune the tine of Cost Estimate

    http//
    Hi,
    We are in developing phase for Product costing for coal mine project ,
    we have raise coal material with Non component BOM , and Routing is only one activity with 400- Raised Coal Qty-MT ,
    We upload the plan with Production cost center -activity type and cost element ( as per cost component -we have 10 cost component  as per below )
    RM - Blasting
    Production Overhead
    Power - Main
    Stores,Spare,Consum
    Repairs & Maint
    Lease & Hire Char-PM
    Power - Auxiliary
    Depreciation
    Over Burden
    Development
    we done the plan for Amount and Qty by KP06,KP26  and update plan price but system not calculate the cost component splitting in cost estimate as per planning while only one item showing for all cost to Production Overhead cost component
    Production Overhead cost component which assign the secondary cost element which is assign to activity type 400
    can any one help me to how we can resolve this issue
    Please find attached document

    Hi,
    Here I am providing the necessity and importance of splitting structure, will share the configuration steps once you go through the following and get the comfort level.
                        Expense Analysis and Splitting in Manufacturing Cost Centers
    Introduction In SAP Cost center work as a cost responsibility center, where all the expenses and cost are stored and analyzed for the purpose of management decision making.
    The cost could be fixed or variable in nature. The difference between variable and fixed costs can be made in various ways in product costing in CO module.
    Fixed costs represent the static costs incurred by the organization, which doesn’t change on the basis on manufacturing activities, which remain constant irrespective of production activities like rent for the premises, salaries of office staff etc.
    On the other hand, variable cost varies based on the level of production activities; if production activities increase then variable cost also increased like electricity consumes raw material charges etc.
    However all the variable cost doesn’t vary in direct proportion by quantity of goods produced.
    In this document will try to define; how the Expenses analysis and splitting of cost done in manufacturing cost centers.
    From controlling prospective, fixed cost remain constant regardless of operating activities, but if these factor changes, variable cost will fluctuate.
    Basically raw material costs represent variable cost, but in this document main focused will be given to distinguish fixed and variable activity cost.
    The segregation between fixed and variable cost is optional and is derived from the configuration and master data configured in cost center accounting and overhead accounting.
    Activity Price:
    There are different methods that could be used in cost center accounting to determine the activity price. The simple way is the manually enter “Fixed” and “Variable” Activity cost (KP26).
    However there are other methods used in Cost center Planning and Budgeting that automatically calculate the fixed and variable activity price.
    Here the focused will be given on Planning and Budgeting activity and automatic calculation of plan activity rate in cost center.
    This method aggregate planned costs by cost element and capacity by plan unit to calculate the activity price.
    Activity independent costs are segregated among different activities based on Splitting Structure, while activity dependent cost directly used for the purpose of variable activity rate calculation.   
    Fixed Activity Cost:
    In product costing all those cost, which doesn’t vary based on the activities in manufacturing cost will represent fixed cost.
    In a manufacturing cost centers there may be two or more activities performed.
    To calculate the activities rate, the fixed costs are distributed to various activities on the basis of Splitting Structure defined for cost center.  
    Variable Activity Cost:
    Variable activity cost, which directly depend upon the activity type and fluctuate based on increase or decrease in manufacturing activities. In SAP variable activity cost are directly linked to the respective activity.
    Activity Prices: Fixed and Variable Split
    In Cost Center Accounting dividing the cost between Fixed and Variable requires appropriate split to be made in the cost entered for the activity. The process is described below:
    i.  Variable cost would be planned at activity level and expenses should be maintained at cost element in the manufacturing cost center by assigning activity and cost element combination.
    In other word, the expenses should be planned on Activity type at the time of primary cost planning (KP06).
    Then the variable activity rates are calculated on Total cost planned at Activity divided by Total number of activity planned at that cost center (i.e. capacity in KP26)
    ii. Fixed cost would be planned at independent of activity type. These costs are maintained in KP06 at cost element level on manufacturing cost center.
    Then the fixed costs are distributed on various activity types on the basis of Splitting structure defined at OKEW.
    In Splitting Structure we define the rules, how the fixed cost will be distributed to Activities. For the purpose of this document, considering split of fixed cost on the basis of Capacity maintained in KP26.
    Regards,
    Pavan kumar Arvapally

  • Can't delete the cost estimate via CKR1

    Hi,
    We have one material. We can't delete the cost estimate via CKR1. It is only warning. It is no error log. The other material cost estimate can delete normally. I check the material master I can't find the issue. The following is the warning message. Could you pls help check it? Whate factor will effect the cost estimate deletion? Thanks.
    ==========================
    Deleting current standard cost estimates can cause inconsistencies
    Message no. CK 669
    Diagnosis
    u2022 If you delete a current standard cost estimate, the fields for
    the cost estimate are set to zero in the material master record. If you
    use the material ledger, the standard prices in the material ledger
    master data are also deleted when you delete the current standard cost
    estimate. The material master record for the material thus does no
    longer contains a current standard price from a standard cost estimate.
    u2022 If you delete an active standard cost estimate, you can no
    longer determine scrap, work in process and variations for previous
    periods.
    u2022 In certain countires, it is a legal requirement to maintain
    records of standard pricing. Therefore, you should check whether you
    are obliged by law to keep records of your standard cost estimates.
    Please also contact the relevant accounting and inventory management
    departments.
    ==========================
    Best Regards
    Park Han

    Hi,
    The deletion of Current standard cost estimate should be followed with some rules of the IFRS.
    If you want to change the standard cost you can do the change,If you want to delete the standard cost of material then it will set the price of material to zero.If the material ledger also activate then it will make the Moving average price & standard cost of the material to zero.
    So follow the Law of the country & Discus with Audit team &then delete the curent standard cost estimate of the material.
    Regards,
    Raj

  • CK51N updates SO cost estimate but not the status of SO line item

    Hi All,
    Ours is a MTO scenario with Sales Order costing. When we execute the Order BOM cost estimate in CK51N the cost estmate is updated in tne sales order line item but the status of the Sales Order line item remains "to be costed". Please advise is there any config setting for the status update of Sales Order line item when the ck51N is executed.
    When i do the Sales Order costing in VA02 --> Extras --> Costing.  The staus of the Sales Order Line item gets updated automatically.
    Regards,
    Rajeswari shankar.

    Hi,
    In general for MTO Scenarios, you would do the sales order costing from VA02 only.Once you get the cost,then in the left corner,there is a symbol for markup the price,by clicking on which you would mark and release the price.

  • Deleting the released cost estimate -reg

    Hi,
    I have created std cost estimate for one material through CK40N and released.
    After that , I tried to delete the cost estimate through CK44 , The variant (costing name) only deleted but  i could not delete the released cost estimate  for the material.
    No GR , sales invoice any posting were happened after releasing.
    Can you suggest me, what could be the reason and  how to delete the cost esimate.
    Regards
    Karthikeyan

    Dear Karthikeyan,
    If you want to delete the released cost estimate use CKR1,which is not recommanded,as it may create
    discrepancies.
    CKR1 is used to reorganize or delete the existing or the future or the previous standard cost estimates.
    CK44 is used to delete the costing run datas.
    Regards
    Mangalraj.S

  • Cost estimate display is confusing

    I have a cost estimate scenario as under:
    Finished product Y gets received at distribution plant N after external processing after leaving manufacturing plant M as a semi-finished product X.
    Finished product  (at the distribution center) costed on Day 1 = $ 90 (cost of X pulled from plant M's last cost estimate)
    Semi-finished product X gets recosted again in plant M on Day 2 and gives cost $95
    But finished product Y not recosted in plant N after that to reflect $95 instead of $90.
    But when you do a CK13N on finished product Y in plant N.
    It shows $90 in the multi-level costed BOM at the top total but underneath it, the semi-finished product displays the Day 2 cost of $95. Should it not be showing the cost of $90 as on the date of the Day 1 cost estimate which is what was used for the Day 1 cost estimate for the finished product?
    Attached document contains screenshot

    Hello Rajaram,
    The report can be a confusing report. 
    One thing to understand is that the report is reading saved data and values in tables KEKO and CKIS.   The report you see in CK13n is not doing any totaling, just displaying saved data.
    If FP in DC was saved at 90
    and SFP recosted and saved at 95
    and this new cost was not rolled into DistCenter and saved,  there is no way the report will reflect 95.
    It is not like an EXCEL sheet totaling columns of numbers, it only reports what was saved.
    hope this helps,  please ask if you have another question about it
    Althea

  • Material ledger and standard cost estimate

    Hi Gurus,
    When standard cost estimate is done in a scenario, where  material ledger is activated, does the entire stock get revaluated andl post a credit in my P/L? Is it possible  to keep my inventory(FG and SFG) at periodic unit price ie at the actual manufacturing price over a longer period say 3 years? Please fill this gap in my understanding.
    Best regards
    Vimal

    Hi Vimal,
    Material ledger uses the standard price as 'preliminary price' always during the current month, independent of the question if a new standard price was estimated and released.
    But: After period end, when the actual price is calculated the posting will adjust the inventory and P/L accounts to the actual price, with posting date in the recent period.
    That means if you have a material that was manufactured once and then consumed over a 3 year period, and during that period you calculate the same material in a standard cost estimate with changing results, that would mean: Looking back at any month during the 3 years the consumption and stock values will be valued at the actual price of manufacturing. But during the currently open period it will always be valuated at the price of the last released cost estimate.
    I hope I understood your scenario correct...
    Best regards,  Udo

  • Order BOM Cost Estimate

    I am working in an MTO environment i run order bom cost estimate immediately after creation of sales order. When I save the estimate, value against condition type EK02 gets update in sales order.
    As far I know EK02 is a statistical condition, value in the EK02  is not used in price determination however condition type EK01 is used in price determination.
    I want to understand that what happens when we save order bom cost estimate. And fields gets updated with this. And how the value in EK01 is used in price determination.

    Hi
    EK02 stores the Sales order cost estimate... The PGI and related goods movement happen at this value... This field helps you identify whether the PGI value posted in accounting docs is correct or not...
    Regards
    Ajay M

  • Sales order cost estimate with GIT account

    Hi,
    Business introduced Goods - in - Transit (Balance sheet account), so PGI will always post to GIT and Invoice it will get reversed.
    For one of the Configuratble material (MTO) scenario we need the Sales order cost estimate to get the Planned cost.
    When i try to execute the sales order cost estimate it says cost element doesnot exist for GIT GL (WHich is right).
    But with maintaining the GIT how to achieve the sales order cost estimate.
    I tried to create CE category 90 for GIT, in Cost estimate am getting error CE 90 not supported for Cost estimate.
    Kindly help this is kind of urgent req for us
    Thanks,
    Sudha

    Hello Ashley
    Yes, if you have done your settings correctly, especially Requirements class set up  (see the documentation link),  then the cost estimate will flow to a condition type in Pricing, usually EK01/EK02 conditions. These conditions are used to calculate sales prices (PR00) in cost-plus (mark-up) scenarios.
    Link: http://help.sap.com/erp2005_ehp_04/helpdata/EN/90/ba6da4446711d189420000e829fbbd/frameset.htm
    However Profit margin  as calculated in a sales order comes from VPRS condition  (which is based in Material Master) and is the difference of net value and VPRS condition value in normal circumstance.
    Hope other more knowledgeable experts will weigh in.

  • Sales order cost estimate

    hi,
    While saving the sales order cost estimate its getting the GL account from GBB-ZG0.
    as we assigned Balance sheet account its asking the cost element.
    can you please explain what is link to get the gl from GBB-ZGO, can we change this to pick from GBB-VBR.
    Thanks,
    Sudha

    Hi,
    Are you are working with unvaluated special stock ?  In this case, the system is looking for a consumption account via the account assignment category. For example if you are using requirement class ZPJ which uses account assignment category Q. In account assignment Q, you entered account modification VBR. Therefore, the system is looking for an account via the keys GBB / VBR.
    regards
    Waman

  • Error reading material cost estimate for sales order (KE292)

    Dear All,
    I have an issue with billing. we are posting july month transactions, the material cost is maintained through MR21. When releasing billing document for accounting we are getting error message like"Error reading the material cost estimate for sales order "11"
    Message no. KE292
    Diagnosis
    In Profitability Analysis (CO-PA), the system tried to valuate item 000010 of sales order 11 by reading the corresponding product cost estimate.
    However, no product cost estimate could be found for this sales order item.
    The system accessed product costing for product AMLFP011011XX00P using costing key YB3 as defined in the
    CO-PA Customizing settings.
    System Response
    The system cannot process the document any further.
    Procedure
    Check your Customizing settings."
    We cross checked with other client as a current date and we ran cost estimate through CK40N with same material. and we posted entries. Here it is working fine. but in above process it is not working. Can you pls guide me where i missed.
    Regards,
    Nagaraju,

    Hi,
    When the Costing Key is assigned to the material types in the COPA customizing, then system expects Cost estimation when billing is released to Accounts.
    If you dont run cost estimation but update the material master through MR21, system will not accept as in the Costing key configuration you must have selected the Current Standard price field for the valuation.
    Hence, try to run cost estimation and then do releasing.
    Thanks & Regards
    Ravi Kumar

  • AFS grid value/valuation type not picked in sales order cost estimate

    Hi Experts,
    We have different valuation types in the material master. This is part of the AFS, where each grid value is a valuation type. While making a sales order cost estimate and in one sales order item, we have 3 grid values (valuation types), system is costing only for one grid value and that too for the entire quantity. This way the costing is wrong as different grid values have different BOMs and routings.
    Is there any specific setting to have the grid value to be picked up in the sales order cost estimate? Or am i missing some setting? in general product costing settings or AFS product costing settings?
    Best Regards
    Vimal

    Hi,
    Do you mean "sales order costing", please  if so then please ref. the link:
    http://help.sap.com/saphelp_46c/helpdata/en/90/ba6da4446711d189420000e829fbbd/content.htm
    Regards
    DSR
    Edited by: D.Srinivasa Rao on Nov 25, 2011 8:19 AM

  • GL account in cost estimate

    Hi,
    For Standard cost estimate the GL account will be pick from Cost component strucutre OKTZ.
    We are fine here
    Can you please tell me how the sales order cost estimate will take GL and where it will store value.
    we are in MTO scenario and posting COGS to B/S while posting we are getting the error "CE doesnot exist".
    Can you pleaes help as this is very urgent.
    Thanks,
    Sudha

    hi..
    Please check if COGS is created as a cost element.
    regards,
    Ramesan

  • Sales order is blocked for Delivery-ZH Cost estimate Req

    Hi experts,
    When I am saving the sales order I am getting the informative message standard cost estimate for material xxxx is missing. when i am creating delivery with reference to sales order  it is not allowing me to do delivery it is showing that Sales order is blocked for Delivery-ZH Cost estimate Req( in  a log). Can you pls let me know what configuration I have to check.
    Regards,
    Sunina Agarwal

    hello, friend.
    it looks like product costing has been activated in your environment.  if such is the case, you would have to coordinate with your FICO consultant, and they have to make the necessary standard cost estimates.
    please also check if the cost estimates are part of the incompletion procedures.  if it is, you would not be able to bill the transaction even if this is taken out of the incompleteness procedure.
    regards.

  • Confuguarable Material Cost Estimate

    Hi All.,
    It is an urgent requirement.......
    My client having both configuarable & non configuarable materials.....
    with regarding to the configuarable material cost estimate i don't have good grip on this.
    Can anybody please share some guidlines for how to create the cost estimate.....
    Thanks one and all.,
    Raja

    Configurable materials can only have a cost estimate when there is a sales order bom to define the build.
    We use configurable material and the cost estimate is configured in the same manner as standard material (Costing variant,costing dates, transfer control, etc. but some of the details differ), but it is only Saved within a Sales order. You can use CU50 for a trial cost - the configuration will have to be created in CU50 before it will cost.
    When costing configurable materials in sales orders or for sales orders the valuation variant is different from standard cost variant in these points:
    1 - The costing type is different. 18 - Sales order costing vs. 01 - Standard cost est. (mat.)
    The Costing type for Sales order does not allow updating of the standard price in the Mat Mstr
    The Costing type for Sales order also controls the use of Labor overhead for the costing variant.
    2 - Valuation Variant can be different - Valuation for Prod Costing specifies the rules to build a cost estimate. For Sales order, you may want it to use ONLY the standard price for a material/component, and NOT build a cost estimate.
    3 - Date control - The default “from” date for the Config Mat in a Sales order is “Today” while for product costing it is “first of next month”
    Our Prod Cost Est. is valid until the end of the Fiscal year when a new cost estimate is released. Our Config Material on a Sales order is valid until the end of time.
    I cannot explain “why” we chose one over the other, most of the decisions were made before I arrived. But the Costing Type Difference is very important to us, because there is no chance that the cost estimate will interfere with setting of standards and it allows “searching” for a Sales Order Cost estimate.
    You have to analyze how each part of the costing variant could impact the business and decide how to set it. If circumstances change, you can review the settings later. (I fully intend to review some of ours directly after this conversation.)
    Sales Order Costing Variants are on OKY9 while product costing is at OKKN
    Sales Order Costing Variants are assigned under SD “Maintain Requirements Classes for Costing/Account Assignment (table T459K)
    Hope this helps.
    Althea

Maybe you are looking for