The process of sql statement execution in oracle

Several big memory of shared memory

1) shared pool (shared pool): The
main function is to improve the execution efficiency of SQL statements and PL/SQL statements, cache executed SQL statements, execution plans; PL/SQL statement code blocks, execution codes, etc. (this part is called library cache); and when compiling SQL, PL/SQL statements are referenced by data dictionary information (this part is called dictionary cache or row cache). It is one of the most important parts of SGA.
2) database buffer cache (database buffer): The
main function is to cache the data blocks that have been read. All modifications to the data in the Oracle database are carried out in the buffer cache. Because all operations must first read the data block on the physical file into the buffer cache, and then perform various operations. The buffer cache is the largest memory area in the SGA and one of the most important parts of the SGA.
3) redo log buffer (redo log buffer):
Cache the generated redo log records, and the log writing background process will write the records in the log buffer to disk. It is also one of the most important parts of SGA.
4) Large pool (large pool):
optional memory pool, its main function is to share the pressure of the shared pool. In some cases, such as backup and recovery, if the Large pool is not allocated, memory will be allocated from the shared pool, which will increase the burden of the shared pool.
5) Java pool (Java pool):
used for Java programs.
6)stream pool:
The memory area used by the database in stream work.

sql execution process

The server process carries sql--->go to libray cache to find the previous execution plan

1. The client enters a sql statement.

2. The sql statement is transmitted to the oracle database instance via the network.

3. The server process receives sql statements.

*oracle实例将sql语句解析成sql执行计划,然后才能执行
*解析的时候会消耗I/O、CPU,查询执行的sql涉及到的视图等系列资源有没有权限,或者是否存在

 

4. Modify the data in the shared pool (cache sql statements and parse the execution plan)

The execution plan caches the data from the DBF file into the buffer Cache, and writes the DBF file into the DBF file by the DBWriter process, which has its own writing mechanism.

5. The server process modifies the table and generates a log. The log is cached in the redo buffer and written to the redo.log file by the LogWriter process. The LogWriter process has its own writing mechanism

That is, the server process is used on the user side, the background process writes data, and the user pays attention to the processing speed of the server process.

 

The role of shared pool in SQL execution:

Cache the commonly used SQL execution plan in the SP to reduce the parsing steps. If some are used directly in the SP, if not, a new parsing is newly generated. This series of actions is performed by the server process.

buffer Cache:

Reducing the usage rate of I/O involves a concept, the hit rate.

Hard analysis of sql statement

The shard pool is roughly divided into 3 parts

1. Free space.

2. Library cache space.

3. Dictionary cache (row cache), which caches oracle's own information.

--查询shard pool 主要组成的cache size

select * from v$sgastat a where a.NAME = 'library cache';
select * from v$sgastat a where a.pool = 'shared pool' and a.NAME = 'free memory';
select * from v$sgastat a where a.NAME = 'row cache';

Analysis type of sql statement

Soft analysis

Hard analysis

The execution plan cannot be found in the librarycache, and hard analysis occurs, which consumes resources.

--查询软解析和硬解析的次数,软硬解析的具体情况
--我们期望软解析多,硬解析多的时候需要引起注意
select name,value from v$sysstat where name like 'parse%'

Guess you like

Origin blog.csdn.net/weixin_41086692/article/details/103006817