Home Database Mysql Tutorial Oracle block cleanout

Oracle block cleanout

Jun 07, 2016 pm 03:50 PM
Block oracle shark

简单点说,在oracle的block上都有活动事务的标志的,如果一个事务commit后,由于某些block在commit之前已经写回datafile,或者事务影响到的block数过多,则commit的时候只会清理undo segment header中的事务表信息,data block上的事务标志不会清除,在否则代

简单点说,在oracle的block上都有活动事务的标志的,如果一个事务commit后,由于某些block在commit之前已经写回datafile,或者事务影响到的block数过多,则commit的时候只会清理undo segment header中的事务表信息,data block上的事务标志不会清除,在否则代价过高。那么在一些读取这些block时,需要将这些事务标志进行清除,就是延迟块清除




块清除即清除数据块上与“锁定”有关的信息。Oracle的锁机制是一种轻量级的锁定机制,不是通过构建锁列表来进行数据的锁定管理,而是直接将锁作为数据的属性,存储在数据块首部。因此,每次访问数据时都要去看数据块头部的锁,如果数据已经提交,则可能需要清理这个块,换句话说,要将这些事务信息删除。因此这个动作就会生成redo。


Cleanout有2种,一种是fast commit cleanout(提交清除),另一种是delayed block cleanout(延迟清除).


提交清楚是如何工作的?Oracle会记录已修改的块列表,这些列表可以有20个块,Oracle根据需要分配多个这样的列表,但是如果这些修改的块加起来超过buffer_cache的10%,oracle就停止分配这样的列表,因此当提交时就只会清理最多10%buffer_cache的数据块,其余的部分就延迟清除,这样也是为了提高commit的效率。


还有一种情况,就是当事务还未commit时,修改的数据块已经写入硬盘,当发生commit时oracle并不会把block重新读入做cleanout,而是把cleanout留到下一次对此块的访问是完成。


Cleanout有2种,一种是fast commit cleanout,

另一种是delayed block cleanout.Oracle的每个事务(transaction)修改不超过10%buffer cache的数据块时,oracle做的是fast commit cleanout。如果一个事务(transaction)修改的块超过10% buffer cache,那么超过的块就执行delayed block cleanout,还有一种情况,就是当事务还未commit时,修改的数据块已经写入硬盘,当发生commit时oracle并不会把block重新读入做cleanout,而是把cleanout留到下一次对此块的访问是完成。

当我们update 数据之后,并且没有commit,此时我们flush buffer cache,将修改的数据块,flush 到硬盘,那么此时发生的就是delay block cleanout
正常情况下,会去修改block里的相关SCN。 但是实际上此时Oracle 并没有回去修改这些block,因为再次调用成本太大。 Oracle只更新了undo segment header slot。 当下次再次访问这个block时,在根据undo segment 来更新block scn 和 itl 上的scn。 如果此时对应的undo segment 已经不存在,就会出发ORA-01555,快照过旧的错误。
做了delayed block cleanout之后,itl 变成了SCN。 此时lck,lb标志为都被清零,scn也是从undo segment header transactiontable slot里面得到。如果undosegment header 上的slot被覆盖了,那么会把undo segment 上的control scn拿来当作upper bound scn
当delayed block cleanout 发生时,依赖与undo segment来保证,如果undo segment 被删除了,那么会Oracle 会使用system 表空间下的undo$ 基表来保证delayed block cleanout。
一般来说,select 是不会产生redo的。 但如果发生了delayed block cleanout,那么就会产生redo。 当然这只是一种情况,开启审计等,也会造成select 产生redo。
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What to do if the oracle can't be opened What to do if the oracle can't be opened Apr 11, 2025 pm 10:06 PM

Solutions to Oracle cannot be opened include: 1. Start the database service; 2. Start the listener; 3. Check port conflicts; 4. Set environment variables correctly; 5. Make sure the firewall or antivirus software does not block the connection; 6. Check whether the server is closed; 7. Use RMAN to recover corrupt files; 8. Check whether the TNS service name is correct; 9. Check network connection; 10. Reinstall Oracle software.

How to solve the problem of closing oracle cursor How to solve the problem of closing oracle cursor Apr 11, 2025 pm 10:18 PM

The method to solve the Oracle cursor closure problem includes: explicitly closing the cursor using the CLOSE statement. Declare the cursor in the FOR UPDATE clause so that it automatically closes after the scope is ended. Declare the cursor in the USING clause so that it automatically closes when the associated PL/SQL variable is closed. Use exception handling to ensure that the cursor is closed in any exception situation. Use the connection pool to automatically close the cursor. Disable automatic submission and delay cursor closing.

How to create cursors in oracle loop How to create cursors in oracle loop Apr 12, 2025 am 06:18 AM

In Oracle, the FOR LOOP loop can create cursors dynamically. The steps are: 1. Define the cursor type; 2. Create the loop; 3. Create the cursor dynamically; 4. Execute the cursor; 5. Close the cursor. Example: A cursor can be created cycle-by-circuit to display the names and salaries of the top 10 employees.

How to stop oracle database How to stop oracle database Apr 12, 2025 am 06:12 AM

To stop an Oracle database, perform the following steps: 1. Connect to the database; 2. Shutdown immediately; 3. Shutdown abort completely.

What steps are required to configure CentOS in HDFS What steps are required to configure CentOS in HDFS Apr 14, 2025 pm 06:42 PM

Building a Hadoop Distributed File System (HDFS) on a CentOS system requires multiple steps. This article provides a brief configuration guide. 1. Prepare to install JDK in the early stage: Install JavaDevelopmentKit (JDK) on all nodes, and the version must be compatible with Hadoop. The installation package can be downloaded from the Oracle official website. Environment variable configuration: Edit /etc/profile file, set Java and Hadoop environment variables, so that the system can find the installation path of JDK and Hadoop. 2. Security configuration: SSH password-free login to generate SSH key: Use the ssh-keygen command on each node

Oracle's Role in the Business World Oracle's Role in the Business World Apr 23, 2025 am 12:01 AM

Oracle is not only a database company, but also a leader in cloud computing and ERP systems. 1. Oracle provides comprehensive solutions from database to cloud services and ERP systems. 2. OracleCloud challenges AWS and Azure, providing IaaS, PaaS and SaaS services. 3. Oracle's ERP systems such as E-BusinessSuite and FusionApplications help enterprises optimize operations.

What to do if the oracle log is full What to do if the oracle log is full Apr 12, 2025 am 06:09 AM

When Oracle log files are full, the following solutions can be adopted: 1) Clean old log files; 2) Increase the log file size; 3) Increase the log file group; 4) Set up automatic log management; 5) Reinitialize the database. Before implementing any solution, it is recommended to back up the database to prevent data loss.

How to create oracle dynamic sql How to create oracle dynamic sql Apr 12, 2025 am 06:06 AM

SQL statements can be created and executed based on runtime input by using Oracle's dynamic SQL. The steps include: preparing an empty string variable to store dynamically generated SQL statements. Use the EXECUTE IMMEDIATE or PREPARE statement to compile and execute dynamic SQL statements. Use bind variable to pass user input or other dynamic values ​​to dynamic SQL. Use EXECUTE IMMEDIATE or EXECUTE to execute dynamic SQL statements.

See all articles