Oracle Optimization Technology

Source: Internet
Author: User

1. Basic Principles

Oracle logs: To improve hard disk write efficiency, Oracle uses a data buffer in the memory to store data and writes it to the disk (DBWR) after a certain amount or a certain amount of time ).

In this case, if a fault such as power failure occurs, data in the data buffer zone will be lost.

Therefore, logs are required to store records. It also has a buffer, which triggers the LGWR process to be written to the REDO file (Log File) every 3 seconds or a Commit or 1 out of 3 ).

Rollback: Multi-version control is used in Oracle for concurrency. When writing data, first write the original data into the UNDO (roll back the tablespace ). Then, change the location of the original data to the new data. (When other processes read the data in the rollback table, this prevents dirty reading ). If Commit is used, the tablespace is recycled. If rollback is performed, read the original image to overwrite the original location.

All operations on rolled back data involve logs, so there will be a lot of REDO with UNDO!

Dml redo: assume that the inserted log is 6 (Omitted Unit) (The rowid of the inserted record of the undo record ). The updated log is 7 (the old field in the column where the UNDO record is updated ). The deleted log is 32 (UNDO records the original whole row of data ).

2. Batch insert

Bind Variable: reduce SQL parsing.

Batch submission: reduces interaction with Oracle. Reduce IO.

3. Storage Mechanism SEGMENT-> indicates a table. Contains multiple Extent instances. EXTENT-> indicates the smallest unit of expansion. When data increases, it is extended according to an EXTENT. Contains 8 blocks. Block-> indicates the minimum storage unit of a Block (8 KB ). Header, table directory, row directory, available space (free space), and data zone. 4. Advantages of temporary tables and partition and cluster temporary tables: 1. efficient deletion of records. After the transaction-based global temporary table COMMIT or SESSION connection exits, the temporary table records are automatically deleted (more records are generated ). 2. Data is independent for different sessions. Different sessions have different access results. Partition: The data is completely isolated (different from the index generation address ). Therefore, it generates multiple segments (multiple tables ). 1. When querying by partition field, partitions can be efficiently eliminated. Only access part of the resource. 2. Powerful partition operations, truncate deletion, data transfer, partition cutting, and partition merging. 3. Global index: Only partition columns can create a global index (or prefix ). Many partition operations will invalidate the global index and must be rebuilt. 4. For local indexes, only local indexes can be built for other fields. When performing a query, you need to access the local indexes of all partitions. Sometimes, the efficiency is lower (each index usually requires 4 IO times ). Clustering table: only primary key indexes can be used to constrain the data storage location (via organization index ). (The default primary key is non-clustering ). The advantage is that the query does not need to perform the Back-to-table operation. The disadvantage is that the update overhead is higher. 5. Storage of index B + tree. The height of 50 W entries is 3. In this case, I/O is required four times (including back-to-table operations ). Index advantages: 1. COUNT, SUM, and AVG. However, when there is a null value (the B-tree does not store the null value), the overhead may be higher. 2. MAX and MIN. Note that MAX + MIN cannot be used at the same time. This is because Oracle is atomic. Scans the entire table. 3. order by, DISTINCT, and UNION ). 4. combined index: avoid returning to the table. However, note that the query range must be queried according to the prefix order of the combination (the equivalence does not matter ). When there is an equivalence value with a range, the equivalence value goes first and the range is later. 5. Bitmap index: a large number of duplicates are created in rare updates. 6. Table join 1. nested join: read all the rows suitable for the driver table at most, and obtain the rows in the driver table one by one based on the join conditions (so to reduce IO, the driver table should be smaller ). Therefore, an index is required for the restrictions on the driver table, and an index is required for the connection conditions of the driver table. 2. hash connection: Read the driver table to create a hash (the driver table is small), read the drive table to find the hash. Comparison of values greater than or less is not supported. 3. sort and merge: Read the elements of the two tables, sort them separately, and then merge them. The join conditions of both tables must be indexed. Not equal.

Reference: More than Oracle.

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.