Oracle internal index and parameter quantity adjustment

Source: Internet
Author: User
Welcome to the Oracle community forum and interact with 2 million technical staff. This article is about Oracle10g cost-based internal optimization (CBO) and Structured Query Language (SQL) part 1 of a series of articles on performance optimization (12 in total. Each skillful article is excerpted from the Oracle structure book to be published by Rampant Technology Press.

Welcome to the Oracle community forum and interact with 2 million technical staff> This article describes Oracle 10 Gb cost-based internal optimization (CBO) and Structured Query Language (SQL) part 1 of a series of articles on performance optimization (12 in total. Each skillful article is excerpted from the Oracle structure book to be published by Rampant Technology Press.

Welcome to the Oracle community forum and interact with 2 million technical staff> enter

This article is part 1 of a series of articles (12 in total) on Oracle 10 Gb cost-based internal optimization (CBO) and Structured Query Language (SQL) performance optimization (10th in total. Each skillful Article excerpts from the Oracle Structured Query Language (SQL) and internal index, which will be published by Rampant Technology Press. The author is Kimberly Floss. From the homepage of this series, you can see other parts to be released.

If you cannot change the code...

Although system-level performance tuning is not the best solution for performance tuning of structured query languages (SQL), when you cannot change some SQL statements (for example, SQL statements in some packages provided by the provider). It is extremely helpful to adjust the system performance by using the regular mode of SQL processing. Based on daily work experience, it is very common for Oracle Database administrators to change some optimization parameters to adapt to SQL type changes in database buffers.

Some common changes:

1. Oracle parameter changes. Changes to optimizer_mode, optimizer_index_cost_adj, and optimizer_index_caching can have a huge impact on the SQL Execution Plan.

2. Change the statistical parameters. Using the dbms_stats package to import specific statistical parameters (which is adjusted for the processing mode of course) can significantly affect the SQL Execution speed.

3. Use automatic query to re-write data. The Oracle materialized view can pre-aggregate and pre-aggregate data to reduce the number of running time table connections. For databases with Fewer updates, you can also increase the processing speed by connecting tables in advance.

Some of the most important Oracle optimization parameters for performance optimization are as follows:

* Optimizer_mode-in Oracle 9i, many optimization modes are determined by the value of the optimizer_mode parameter. The value range of this parameter is rule, choose, all_rows, first_rows, first_rows_1, first_rows_10, and first_rows_100.

We start by defining the "best" execution plan. At any given time, all SQL statements in the database buffer must have the "best" Execution Plan (of course, because the processing requirements may be different at any given time, so this optimal execution plan may change frequently ). What is the "best" execution plan? Is the execution plan that returns the fastest results or that uses the least computing resources? Obviously, the answer depends on the processing process of your database. Oracle provides two optimization modes that allow you to choose the "best" execution plan you think:

1. optimizer_mode = first_rows ?? Compared with full table scan access, this optimization mode focuses more on index access. When you want a query to return results at the fastest speed, even if the total Logical Input and Output is higher than the full table scan, this mode is generally used for online access to the system, because end users want to view the first page of query results as soon as possible.

2. optimizer_mode = all_rows ?? This optimization mode focuses more on full table scanning (especially concurrent full table scanning), because in this case, the server resource overhead is minimal. This mode is generally used in batch processing processes and data warehouses. Their goal is to minimize the resources consumed by servers.

3. optimizer_mode = first_rows_n ?? From Oracle 9i, there is a new optimization mode for some queries that return small result sets. The optional values are first_rows_1, first_rows_10, and first_rows_100. These parameter values can ensure that Oracle can optimize such SQL statements.

Although the optimizer_mode parameter controls the overall behavior of "cost-based optimization", other Oracle parameters also have a considerable impact on "cost-based optimization. Oracle provides some important parameters to control the "cost-based optimization" Options:

1. optimizer_index_cost_adj ?? This parameter can be used to adjust "cost-based optimization", which is more inclined to index access than full table scan access. The smaller the value, the more likely a "cost-based optimization" will be to use an available index.

2. optimizer_index_caching ?? This parameter tells Oracle how likely your index is to be in the memory data buffer. The setting of this parameter will affect whether to use indexes for a table connection (nested loop) or full table scan for "cost-based optimization.

3. db_file_multiblock_read_count ?? When this value is set to a large value (a larger server is used), "cost-based optimization" identifies scattered (multiple blocks) read operations may cost less than sequential read operations. This makes "cost-based optimization" more inclined to full table scanning.

However, since Oracle 9.2, this is no longer the case. When calculating the system Statistical table, it contains "Multi-block read Operation Records" (MBRC), which determines the cost of full table scanning. Oracle 10 Gb goes further. Some "system default values" are added, which are very inappropriate. For Oracle 9.2, pay attention to 149560.1 on Metalink.

1. parallel_automatic_tuning ?? When this parameter is set to "enabled", full table scan is performed concurrently on Oracle servers with many CPUs. Because concurrent full-Table scanning can be very fast, "cost-based optimization" has a high index access overhead, so it is more inclined to use full-Table scanning.

2. hash_area_size (if pga_aggregate_target is not used )?? This parameter sets "cost-based optimization", which is more inclined to use Hash connections than using nested loops and sort and MERGE table connections.

3. sort_area_size (only when pga_aggregate_target is not used )?? This parameter affects whether to execute index access or decide whether to sort the result set based on "cost-based optimization. The higher the value of this parameter, the more likely it is to execute sorting in the memory (thousands of times faster than using a temporary tablespace), and the "cost-based optimization" is relative to using a pre-sorted index for retrieval, direct sorting is preferred.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.