210 likes | 517 Views
SQL Tuning. Optimizer Tasks. Oracle optimizer performs the following functions when evaluating a SQL statement: Evaluates the expressions and conditions contained in the SQL statement Transforms complex queries into an equivalent join query
E N D
Optimizer Tasks • Oracle optimizer performs the following functions when evaluating a SQL statement: • Evaluates the expressions and conditions contained in the SQL statement • Transforms complex queries into an equivalent join query • Chooses an optimization goal, either the Cost-based Optimizer (CBO) or the Rule-based Optimizer (RBO) • Determines how to access each table to retrieve data • Determines the order of table joins for statements involving more than two tables • Chooses the type of join to be performed for each pair
Cost-based Optimizer Process • CHOOSE: Oracle chooses the best and most efficient path to execute and retrieve data. Optimizer can select a cost-access method when statistics are available or a rule-based access method if it is faster. This setting is the most common mode used. • ALL_ROWS: Oracle uses cost based access methods regardless of statistics availability. This optimizer priority is to retrieve all rows with the minimum amount of resource consumption. This option often used in Web applications. • FIRST_ROWS: Oracle uses a mix of cost-based access methods and heuristics to retrieve the first few rows fast. This option is often used in FORMS client/server applications. • FIRST_ROWS_N: Where N is 1, 10, 100, or 1000. Uses the cost-based access method to retrieve rows the most efficient way.
Optimizer Parameters • Optimizer Performance: • OPTIMIZER_DYNAMIC_SAMPLING • OPTIMIZER_FEATURES_ENABLE • OPTIMIZER_INDEX_CACHING • OPTIMIZER_INDEX_COST_ADJ • OPTIMIZER_MAX_PERMUTATIONS • Optimizer Behavior: • CURSOR_SHARING • DB_FILE_MULTIBLOCK_READ_COUNT • HASH_AREA_SIZE • HASH_JOIN_ENABLED • PARTITION_VIEW_ENABLED • QUERY_REWRITE_ENABLED • SORT_AREA_SIZE • STAR_TRANSFORMATION_ENABLED