SQL 문장이 RULE 에서 COST-BASED로 전환되는 경우
제품 : ORACLE SERVER
작성날짜 : 2004-05-28
SQL 문장이 RULE에서 COST-BASED로 전환되는 경우
==============================================
PURPOSE
SQL statement 문장이 자동으로 cost-based mode로 전환되는 경우에 대해
알아보자.
Explanation
Rule-based mode에서 sql statement를 실행하더라도 Optimizer에 의해
cost-based mode로 전환되는 경우가 있다.
이런 경우는 해당 SQL이 아래와 같은 경우로 사용되는 경우 가능하다.
- Partitioned tables
- Index-organized tables
- Reverse key indexes
- Function-based indexes
- SAMPLE clauses in a SELECT statement
- Parallel execution and parallel DML
- Star transformations
- Star joins
- Extensible optimizer
- Query rewrite (materialized views)
- Progress meter
- Hash joins
- Bitmap indexes
- Partition views (release 7.3)
- Hint (RULE 또는 DRIVING_SITE제외한 Hint가 왔을경우)
- FIRST_ROWS,ALL_ROWS Optimizer의 경우는 통계정보가 없어도 CBO로 동작
- TABLE 또는 INDEX에 Parallel degree가 설정되어 있거나,
INSTANCE가 설정되어 있는 경우(DEFAULT도 해당)
- Table에 domain index(Text index등) 이 생성되어 있는 경우
Similar Messages
-
Rule based & Cost based optimizer
Hi,
What is the difference Rule based & Cost based optimizer ?
ThanksWithout an optimizer, all SQL statements would simply do block-by-block, row-by-row table scans and table updates.
The optimizer attempts to find a faster way of accessing rows by looking at alternatives, such as indexes.
Joins add a level of complexity - the simplest join is "take an appropriate row in the first table, scan the second table for a match". However, deciding which is the first (or driving) table is also an optimization decision.
As technology improves a lot of different techiques for accessing the rows or joining that tables have been devised, each with it's own optimium data-size:performance:cost curve.
Rule-Based Optimizer:
The optimization process follows specific defined rules, and will always follow those rules. The rules are easily documented and cover things like 'when are indexes used', 'which table is the first to be used in a join' and so on. A number of the rules are based on the form of the SQL statement, such as order of table names in the FROM clause.
In the hands of an expert Oracle SQL tuner, the RBO is a wonderful tool - except that it does not support such advanced as query rewrite and bitmap indexes. In the hands of the typical developer, the RBO is a surefire recipie for slow SQL.
Cost-Based Optimizer:
The optimization process internally sets up multiple execution proposals and extrapolates the cost of each proposal using statistics and knowledge of the disk, CPU and memory usage of each of the propsals. It is not unusual for the optimizer to analyze hundred, or even thousands, of proposals - remember, something as simple as a different order of table names is a proposal. The proposal with the least cost is generally selected to be executed.
The CBO requires accurate statistics to make reasonable decisions.
Even with good statistics, the complexity of the SQL statement may cause the CBO to make a wrong decision, or ignore a specific proposal. To compensate for this, the developer may provide 'hints' or recommendations to the optimizer. (See the 10g SQL Reference manual for a list of hints.)
The CBO has been constantly improving with every release since it's inception in Oracle 7.0.12, but early missteps have given it a bad reputation. Even in Oracle8i and 9i Release 1, there were countless 'opportunities for improvement' <tm> As of Oracle 10g, the CBO is quite decent - sufficiently so that the RBO has been officially deprecated. -
How can I know the database is using Cost Based or Rule Based?
Hi all expertise,
How can I know the database is using Cost Based or Rule Based?
If cost based it is using, what methods are need to use to minimize the cost when database is running? And which tables I can see the performance of the database?
Thanks
Amyhow to see database setting ?
use this
SQL> sho parameter optimizer
NAME TYPE VALUE
optimizer_dynamic_sampling integer 1
optimizer_features_enable string 9.2.0
optimizer_index_caching integer 0
optimizer_index_cost_adj integer 100
optimizer_max_permutations integer 2000
optimizer_mode string CHOOSE
choose means if table statistics is available then it will use cost
else
use rule based optimizer
for seeing performnace of table use
set autotrace on
and run your query
if it doen't show cost.it means it use rule based
for using cost based
u will calculate table statistics
9i
dbms_stats.gather_table_stats('owner','table');
8i
analyze table <table_name> compute statistics;
hope it will help you
kuljeet pal singh -
Re: Oracle 8i (8.1.7.4) Rule based v/s Cost based
Hi,
I would like to know the advantages/disadvantages of using RULE based optimizer v/s COST based optimizer in Oracle 8i. We have a production RULE based database and are experiencing performance issues on some queries sporadically.
TKPROF revealed:
call count cpu elapsed disk query current rows
Parse 0 0.00 0.00 0 0 0 0
Execute 3 94.67 2699.16 1020421 5692711 51404 0
Fetch 13 140.93 4204.41 688482 4073366 0 26896
total 16 235.60 6903.57 1708903 9766077 51404 26896
Please post your expert suggestions as soon as possible.
Thanks and Regards,
AI think the answer you are looking for is that Rule Based optimizer is predictive, but Cost Based optimizer results may vary depending on statistics of rows, indexes, etc. But at the same time, you can typically get better speed for OLTP relational databases with CBO, assuming you have correct statistics, and correct optimizer settings set.
-
Top Link Special Considerations in moving to Cost Based Optimizer....
Our current application architecture consists of running a Java based application with Oracle 9i as the database and toplink as the object relational mapping tool. This is a hosted application about 5 years old with stringent SLA requirements and high availability needs. We are currently using Rule Based Optimizer (RBO) mode and do not collect statistics for the schemas. We are planning a move to Cost Based Optimizer (CBO)
What are the special considerations we need to be aware of from moving RBO to CBO from top link perspective. Is top link code optimized for one mode over the other ?. What special parameter settings are needed ?. Any of your experience in moving Top Link based applications to RBO and best practices will be very much appreciated.
-Thanks
Ganesan MahaGanesan,
Over the 10 years we have been delivering TopLink I do not recall any issues with customizing TopLink for either approach. You do have the ability to customize how the SQL is generated and even replace the generated SQL with custom queries should you need to. This will not require application changes but simply modifications to the TopLink metadata.
As of 9.0.4 you can also provide hints in the TopLink query and expression framework that will be generated into the SQL to assist the optimizer.
Doug -
Adding HINTS produce a cost based plan ?
I have an SQL with Oracle Hints. If I do an explain plan report on this SQL, there is data under Rows, Bytes and Cost. If I remove the hints from the SQL, the explain plan has no data under rows, bytes, cost and a note: rule based optimization.
If I compute statistics on one of the tables used by the SQL, using ANALYSE TABLE as recommended, then I have a third explain plan, with data under rows, bytes and cost.
So how, in the absence of statistics, can Hints help produce a cost based plan ?When you provide hints in the SQL statments you typically are controlling the execution path and the nature of join that SQL statment is choosing. This can give you good results or can slow down performance of your query as the time passes and database is subjected to changes.
If on the other hand you choose COST based optimization and collect statistics as recommended by Oracle then you make optimizer think instead of your self which yealds competative performance when you let optimizer engine decide the execution plan. So If i where you would think of performing following tasks.
1)Collect the statistics for all the tables and indexes refrenced in the SQL statment.
2)Set the optimizer goal to choose.
3) Vary the optimizer sampling size while collecting the statistics using ANALYZE command. In the past I have noticed that optimizer behavior will change as per the sampling so you might have to adjest your stats while using ANALYZE command to fine tune the behavior of SQL statment.
4)This should improve performance of your query. -
Cost Based Optimizer (CBO)
not sure if this is a daft question or what. but i am trying to find out where exactly it exists.
i know, when performing ST05 and viewing the execution plan, we see what the CBO has used, but is the CBO purely performed at the database server, and not at the SAP Application.
When updating the statistics, are these passed to the database server, and once again, the CBO utilizes them for the execution plan, or do the database statistics actually reside in the database server.
finally, in viewing the execution plan, the statement "execution costs = xxx" (xxx being a numeric value). what exactly is xxx. maybe an internal index used to compare execution plans, or maybe the number of blocks required to read the "estimated #rows".
anyone ??
thanks
glenHello Glen,
So far as my knowledge is concerned, the statistics are actually located on the database server. That is what appears to be more logical too. what is the use of maintaining the access paths on tha application server ? Most of the modern database servers are equipped with the CBO functionality. And Cost-Based-Optimizing is dependent on the database.
Here's what the documentation says:
<i>You can update statistics on the Oracle database using the Computing Center Management System (CCMS). The transactions to be used are DB20 and DB21.
By running update statistics regularly, you make sure that the database statistics are up-to-date, so improving database performance. The Oracle cost-based optimizer (CBO) uses the statistics to optimize access paths when retrieving data for queries. If the statistics are out-of-date, the CBO might generate inappropriate access paths (such as using the wrong index), resulting in poor performance.
From Release 4.0, the CBO is a standard part of the SAP System. If statistics are available for a table, the database system uses the cost-based optimizer. Otherwise, it uses the rule-based optimizer.</i>
Regards,
Anand Mandalika. -
Cost Based Oracle Volume 1: Fundamentals - The most awaited topic book
List,
I was very happy to know the news from AskTom site that Mr. Jonathan Lewis has written a book on most awaited topic, i.e. Cost Based Oracle - Volumne 1. I used the terms most awaited, because, I haven't found any book on this topic, may be few technical papers, but, a complete book dedicating to this topic is new, at least in my view. What you more expect when an Oracle Expert write this books, who provides with in-detailed information and not to forget with proven tests.
The book might be available in the book stall from November month onwards. Following is the linke and book index, if someone interested, please read it.
http://www.jlcomp.demon.co.uk/cbo_book/ind_book.htmlA couple of years back I had a developer bring me a poorly running query that came from a vendor package. I looked at it, asked a bunch of dumb questions, and then rewote it to drive differently. It ran great. Then I told the developer that since it was a canned package I didn't know what good my version was going to do him.
A week later the developer came back and told me that the vendor had put my version of the query into their product. Considering that most of their installations are on SQL Server while we run on Oracle I found that amazing.
Sometimes the unexpected happens and it is not a bad thing. But I do not recommend waging money on a vendor accepting a performance improvement suggestion. Most of them act like your shop is the only one having performance issues with their product.
-- Mark D Powell -- -
Differance between the Cost based costing and Account based costing
Hi,
What is the Differance between the Cost Based Costing and Account Based Costing ?You can check sap note 69384
COSTING-BASED PROFITABILITY ACCOUNT-BASED PROFITABILITY
ANALYSIS ANALYSIS
OBJECTIVE
o profitability and sales accounting
o evaluation of market segments (for example,
customers, product groups, sales areas) and corporate
units (for example, division, sales organization) with
regard to their profit or contribution margins
o calculation of profits procedures
- cost-of-sales accounting
- interim and reconciled sales report
- periodic and transaction-based allocation
- Profitability Analysis on the basis of full and
direct costs
o posted and costing-based values o account-based values
o can be reconciled with FI for o always reconciled with
account groups (revenues, sales FI on account level
deductions, costs of goods
Note 69384 - Information: Account-based Profitability Analysis
manufactured, and so on)
DATA STRUCTURES
o definition of operating concerns o definition of operating
with fixed characteristics and concerns with fixed and useruser-
defined characteristics defined characteristics
and value fields
o cumulative storage by posting o cumulative storage by
periods and weeks posting periods
o storage in operating concern o controlling area currency,
currency (as of Release 4.0 also company code currency
optional in company code currency and transaction currency
if req.)
o user-definable summarization levels
FUNCTIONS
o transfer of profit relevant o transfer of profit-relevant
business transactions from SD, FI activities from SD, FI, CO, MM
CO, MM (revenues, sales deductions (revenues, sales deductions and
and costs organized by value fields) costs organized by accounts)
o Derivation of characteristics from master
data or using derivation rules
o Realignments also for data that is already
posted
o Valuation
(Costs of goods manufactured, imputed
costs and sales deductions)
o sales and profit planning o profit planning
- flexible layout - flexible layout
- periodic distribution - periodic distribution
- valuation, revaluation - forecast procedure
- forecast procedure - top-down distribution
- top-down distribution - simulation
- simulation
o profit analysis by means of 'interactive drill-down
reporting'
- Report Painter
- object list/ranking lists, database schema
- drill-down
- key figure systems
- flexible hierarchies
- navigation between reports
- exception reporting
- ABC analyses
- Exporting (Excel, Winword, Mail) -
Account Based Vs Cost Based COPA - Char Derivation
We're trying to implement both Cost based and Account based COPA at a client here.
I have some derivation rules maintained in KEDR.
When I'm trying to post a document in FI, the cost based COPA document is being created with the Characteristics populated correctly according to the derivation rules. However, in Account based COPA the characteristics are NOT getting derived.
Can some tell me if there could be something I've missed?
ThanksHi
Have you deactivated any of the characteristics used in Account based COPA
Check KEQ3 and you may have activated only for Costing based COPA
S Jayaram
Edited by: S Jayram on Dec 18, 2007 3:24 PM -
Costing Based And Account based COPA - Need Assistance
Hello All,
In our project, with no other option we are planning to implement both costing based and account based COPA. I have been told that it is not recommended by SAP because for every entry there will two line items, one in cost based and another in account based (Correct me if I am wrong). But I could not understand why it is creating 2 line items in COPA. - Please help to understand this concept with an Example.
Thanks
PMHi
Costing based and account based COPA serve the same purpose... analyze profitability of the product ....
Costing based COPA should always be preferred over account based COPA, as it provides greater flexibility, some extra features, some extra planning mechanism and faster reports
Following are the point of differences between Costing based vs. Account based copa (ABC)
1. Account based copa uses transaction tables (COEP, BSEG) and hence affects performance of CO transactions.CBC takes values from CE1XXXX to CE4XXXX tables. XXXX means Operating Concern name.
2. Estimated / Statistical values not possible in ABC, say, calculating frieght upon invoice on a thumb rule basis to have better view of profitability per customer.. no valuation strategy in Accounts based COPA..
3. Reports based on line items not possible in ABC.. possible in CBC.
4 Actual Top Down distribution only available in CBC not in ABC .
5. Revaluation of actual data to plan data is not available in ABC
6. No key figure schemes are available in ABC
7. In ABC, settlement cost elements are used to settle values to prof segments unlike value fields in CBC
8. Production variance / COGS accounts shud be defined as cost element in ABC.
System creates a document for each type of COPA as it stores values in different tables and what you can do with this data also differs like you can do TOP down in Costing Based Copa..
Hence, you will have two COPA documents always......................
Fot further clarifications .. please revert back..
Regards
Sarada -
Costing based CO-PA extraction to DSO
Hello Expert,
I need to load the line item data to level 1 DSO. On the source system, the system has used the combination of the following key fields not allow duplicate records.
PALEDGER
VRGAR
VERSI
PERIO
PAOBJNR
PASUBNR
BELNR
POSNR
But, the datasource only includes the following fields from the source system.
PALEDGER
VRGAR
VERSI
PERIO
BELNR
POSNR
How the system is going to handle duplicate records in absence of these two fields (PAOBJNR
PASUBNR) in the datastore object (DSO) which are part of the key fields in the source system?
Please let me know about it.
Thanks.
Bhai.Hi,
For Costing based CO-PA Extraction : Pls follow this steps.
1.Create a CO_PA Data Source in KEB0 (Costing Based) and test this extractor in RSA3.
2. On BW side , Create CO_PA cube using the info source (to which generated CO_PA data source assigned in BW) as a template,and move the chars, KF and time chars and assign the dimensions as required.
I suggest make the copy of any below existing COPA cube and then you add/ delete missing fields.
CO-PA: Published Key Figures
CO-PA: Quickstart (S_GO)
CO-PA: Route Profitability (S_AL)
Pls Check this link for Costing based CO-PA
http://help.sap.com/saphelp_nw04/helpdata/en/b0/06644ca87011d1b5750000e82de856/content.htm
Hope this helps,
Regards
CSM Reddy -
Activating Account based Copa in the existing Cost-based COPA
Hi Sap CO gurus!
Please advise me for the following issue.
Presently, My client using Cost-based COPA for segment wise reporting.( Already activated).
Now they wanted the reports in Account Based. Is it possible to activate the Account based now? Will the system allow us to activate or not?
If yes, What will be the implications? I want to know the pros and cons for that.
If not, How Can I edit the COPA settings( Operating concern)? Or shall I delete the Operating concern and create one new one?
Can you please explain the impact of each situation?
Thanks a lot in advance
RamaHi Joe
You can deactivate Account Based COPA, but you will have to do a thorough testing so that you are aware of the issues that can crop up
The IMG Menu is SPRO > Controlling > Prof Analysis
You will have to do a testing of how the open sales orders would behave... The open sales orders mean Sales Orders where PGI has been done, but billing is pending AS WELL AS Sales orders which are just created, but no Logistics movement (PGI) has taken place... You will have to do testing on both types of sales orders
- When you do PGI after deactivating the account based COPA, you may face error. Because, COGS GL account is a cost element in Account based COPA, where as in Costing based COPA, it is usually not a Cost Element
- Also do a billing from an open sales order and see if you get any error there...
Similar issue can arise during variance settlement also, because the variance account is not a cost ele in Costing Based COPA.
Test out the above scenarios and do share your experiences
Regards
Ajay M -
Allocation of Cost based on Match for 2 Dimensions
Hi Experts,
We are running an allocation where we assign an expense account balance (transportation costs) based on the combination of the dimensions entity and country. Please see the attached for a full example.
A brief example:
ORIGINAL DATA
Entity: Country AI Units (Currency)
1120 Holland AI_01 50
1120 Holland AI_03 30
1120 France AI_02 10
PRICING DATA
Entity: Country USD
1120 Holland 8
1120 France 10
DESIRED RESULT
1120 Holland AI_01 (50*8)=400
1120 Holland AI_03 (30*8)=240
1120 France AI_02 ((10*10)=100
ACTUAL RESULT
1120 Holland AI_01 (50+30) *8=640
1120 Holland AI_03 (50+ 30)*8=640
The original data is multiplied by a "pricing table" data that resides in a statistical account with similar dimensions for Entity and Country. Based on the match between Entity and Country between the data and country we assign the cost.
Issue is that other dimensions e.g. AI or other should be ignored for this calculation and the postings occur as they were originally. However the actual result based on the script below is duplicating data
Any ideas?
Thanks in advance
Eyal Feiler
SCRIPT USED
*RUNALLOCATION
*FACTOR=USING*1
*DIM CURRENCY WHAT=KL_Q ; WHERE=USD; USING=USD;
*DIM COUNTRY WHAT=[ALLOCATION]="y" ; WHERE=<<<; USING=<<<;
*DIM ACTIVE_INGREDIEN WHAT=[AI_ALLOCATION]="X"; WHERE=[AI_ALLOCATION]="X"; USING=AI_NONE;
*DIM ACCOUNT WHAT=411113; WHERE=612313; USING=411113;
*DIM AUDITID WHAT=AD3000; WHERE=AD5130; USING=AD4130;
*ENDALLOCATION
*COMMITVadim,
Again as before this helped us greatly!
Another question if I may:
2) The next step of the calculation is after we search for a price
based on the entity/country match, if one is not found we go to a second
pricing table and select based entity and property of the country (e.g. a
region) that has a new price.
This means that we could have a conflict between the 2 tables. e.g.
in the first table we find a match between Entity and country = France or
country = Holland.
Now when there's an entry = Greece there's no match in table 1 and
we go to table 2 to select the Europe price.
Europe price will now override the first 2 rows from table 1. How can we build this?
One thought is to first perform the select on table 2 (region) and
then override with (table 1) only where it's found?
Thoughts?
Thanks
Eyal -
Reconciliation of costing based COPA and account based COPA
hi experts,
I want reconciliation statement of A/c based copa and costing based copa through SAP. we have not configured any account based copa reports. now we are manually doing the reconciliation. Please tell me the configuration.
Thanks & regards
jayHI
Costing-based Profitability Analysis is the form of profitability analysis that groups costs and revenues according to value fields and costing-based valuation approaches, both of which you can define yourself. It guarantees you access at all times to a complete, short-term profitability report.
Account-based Profitability Analysis is a form of profitability analysis organized in accounts and using an account-based valuation approach. The distinguishing characteristic of this form is its use of cost and revenue elements. It provides you with a profitability report that is permanently reconciled with financial accounting
Regards,
Vijayanand Sankaran
Maybe you are looking for
-
A PAL CTOAEME OVER SIGNED INTO MY COMCAST NETWORK RUN THROUGH ROUTER NOW NETWORK KEEPS TELLING ME CONNECTION TIMEOUT CANT SIGN BACK INTO BACK INTO THE NETWORK
-
If my 2 year contract is up, how much will it cost to shut it off?
my 2 years is up I no longer need this phone.
-
Creative Cloud Desktop Client OSX 10.9.4 Problems !!!
Hi Community Some days ago the Creative Cloud Client on OSX stopped running. The Problem: Creative Cloud Client starts but doesnt show content under apps etc.. only an running progress bar, or the Client starts but there is nothing at least as an bla
-
Oracle's Java tools strategy - interview
I've posted my interview with Ted Farrell, I've posted an interview with Ted Farrell, who is Architect and Director, Application Development Tools Division at Oracle Corporation. He talks about JDeveloper, both the current 10g and future versions. To
-
How to call a function from a different script object?
Hi All, Here is the scenario, I have 2 script objects A and B . In script object A i have a function called "funcA" and in script object B i have a function called "funcB" Now I want to call funcA from funcB which is not happening. I tried doing A.fu