search
HomeDatabaseMysql Tutorialsharedpool之一:heap/extent/chunk

介绍shared pool物理结构的heap 堆,extent 区,chunk 内存中:共享池、大池、PGA是heap管理 chunk shared pool物理层面上由许多内存块组成,这些内在块称为chunk,chunk是shared pool中内存分配最小单位-类似extent,但是chunk是大小不一的,在内存中一个chunk

介绍shared pool物理结构的heap 堆,extent 区,chunk
\
内存中:共享池、大池、PGA是heap管理

chunk

shared pool物理层面上由许多内存块组成,这些内在块称为chunk,chunk是shared pool中内存分配最小单位-类似extent,但是chunk是大小不一的,在内存中一个chunk是连续的。
chunk属于可用类型的时候,既不属于library cache,也不属于dictionary cache,
如果chunk被用于存放SQL相关的数据时,则该chunk就属于library cache;
如果该chunk被用于存放数据字典的信息时,则该chunk就是属于dictionary
Chunk可以分为4类-或者叫4种状态:
1.free:chunk中没有有效的对象,可以不受限制的分配
2.recr:recreatable,--可重用的,chunk里面包含的对象可以被临时性的移 走,如果需要,可以重建,例如共享SQL语句
3.freeabl:--可释放的,session用过这个chunk,里面存放的对象数据是session 在处理过程中产生的,没有办法重建,这点不同于recr。因此这个chunk不能被临时性的移走。但是在合适的时间段可以被释放。
4.perm:permanent,--永久的SGA的固定对象等,chunk中包含永久性的对象,但是大型的permanent类型的chunk中可能包含可用空间,需要的时候,这些空间可以被释放。
查看Chunk的4种状态:--R-freea这种R开头的是在Reserved Area(保留区)中的chunk
SYS@ bys3>select distinct(ksmchcls) from x$ksmsp;
KSMCHCLS
--------
freeabl
recr
perm
R-freea
R-free
R-perm
free
R-recr
查询各种状态chunk的大小,chunk的平均大小
SYS@ bys3>select KSMCHCLS,count(*) ,round(sum( KSMCHSIZ/1024/1024),0) MB,round(avg(KSMCHSIZ),0) from x$ksmsp group by KSMCHCLS order by 1;
KSMCHCLS COUNT(*) MB ROUND(AVG(KSMCHSIZ),0)
-------- ---------- ---------- ----------------------
R-free 43 6 152374
R-freea 98 0 3915
R-perm 4 16 4111578
R-recr 1 4 3977200
free 1937 0 226
freeabl 5815 11 2057
perm 271 89 343653
recr 11127 13 1250
SYS@ bys3>desc x$ksmsp
Name
------------
ADDR --在内存中地址
INDX --
INST_ID --
KSMCHIDX --
KSMCHDUR --
KSMCHCOM --chunk描述
KSMCHPTR --
KSMCHSIZ --chunk大小
KSMCHCLS --
KSMCHTYP --
KSMCHPAR --
SYS@ bys3>select count(*) from x$ksmsp; --每个chunk在x$ksmsp中都有记录,可以统计出chunk数量
COUNT(*)
----------
18704
###################

共享池中的 heap 堆和extent 区

heap 堆由一个或多个大小不一的extent组成,extent由chunk组成
DUMP 共享池查看heap/extent/chunk结构:--用新建会话来做
alter session set events 'immediate trace name heapdump level 2';
select value from v$diag_info where name like 'De%';
/u01/diag/rdbms/bys3/bys3/trace/bys3_ora_7876.trc
查看TRACE文件内容: --找这一段的方法:VI搜索HEAP DUMP
******************************************************
HEAP DUMP heap name="sga heap" desc=0x200010b4
extent sz=0x7ad4 alt=124 het=32767 rec=9 flg=-126 opc=0
parent=(nil) owner=(nil) nex=(nil) xsz=0x0 heap=(nil)
fl2=0x60, nex=(nil)
ds for latch 1: 0x20030f24
reserved granule count 0 (granule size 4194304)
******************************************************
HEAP DUMP heap name="sga heap(1,0)" desc=0x20030f24
---heap name="sga heap(1,0)" 共享池中第1个子池 --高级堆的子缓冲区
extent sz=0xfc4 alt=124 het=32767 rec=9 flg=-126 opc=0
parent=(nil) owner=(nil) nex=(nil) xsz=0x400000 heap=(nil)
fl2=0x20, nex=(nil), dsxvers=1, dsxflg=0x0
dsx first ext=0x2c400000
latch set 1 of 1
durations disabled for this heap
reserved granules for root 0 (granule size 4194304)
EXTENT 0 addr=0x23c00000 ---EXTENT 0,向下搜索还有多个EXTENT的,一个EXTENT有多个Chunk
Chunk 23c00038 sz= 24 R-stopper "reserved stoppe"
Chunk 23c00050 sz= 14300 R-free " "
Chunk 23c0382c sz= 8224 R-freeable "KKSSP^38 " ds=0x23d8f480
Chunk 23c0a8e4 sz= 169732 R-free " "
Chunk 23c33fe8 sz= 24 R-stopper "reserved stoppe"
Chunk 23c34000 sz= 15776 perm "perm " alo=15776
Chunk 23c37da0 sz= 84 free " " -- free状态的CHUNK,23c37da0 内存地址,84字节,可以看到各chunk大小不一
Chunk 23c37df4 sz= 236 recreate "KGLHD " latch=(nil) ---recreate状态的CHUNK, latch=(nil) 没有latch
#####
Statement
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
Explain the InnoDB Buffer Pool and its importance for performance.Explain the InnoDB Buffer Pool and its importance for performance.Apr 19, 2025 am 12:24 AM

InnoDBBufferPool reduces disk I/O by caching data and indexing pages, improving database performance. Its working principle includes: 1. Data reading: Read data from BufferPool; 2. Data writing: After modifying the data, write to BufferPool and refresh it to disk regularly; 3. Cache management: Use the LRU algorithm to manage cache pages; 4. Reading mechanism: Load adjacent data pages in advance. By sizing the BufferPool and using multiple instances, database performance can be optimized.

MySQL vs. Other Programming Languages: A ComparisonMySQL vs. Other Programming Languages: A ComparisonApr 19, 2025 am 12:22 AM

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages ​​such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages ​​have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

Learning MySQL: A Step-by-Step Guide for New UsersLearning MySQL: A Step-by-Step Guide for New UsersApr 19, 2025 am 12:19 AM

MySQL is worth learning because it is a powerful open source database management system suitable for data storage, management and analysis. 1) MySQL is a relational database that uses SQL to operate data and is suitable for structured data management. 2) The SQL language is the key to interacting with MySQL and supports CRUD operations. 3) The working principle of MySQL includes client/server architecture, storage engine and query optimizer. 4) Basic usage includes creating databases and tables, and advanced usage involves joining tables using JOIN. 5) Common errors include syntax errors and permission issues, and debugging skills include checking syntax and using EXPLAIN commands. 6) Performance optimization involves the use of indexes, optimization of SQL statements and regular maintenance of databases.

MySQL: Essential Skills for Beginners to MasterMySQL: Essential Skills for Beginners to MasterApr 18, 2025 am 12:24 AM

MySQL is suitable for beginners to learn database skills. 1. Install MySQL server and client tools. 2. Understand basic SQL queries, such as SELECT. 3. Master data operations: create tables, insert, update, and delete data. 4. Learn advanced skills: subquery and window functions. 5. Debugging and optimization: Check syntax, use indexes, avoid SELECT*, and use LIMIT.

MySQL: Structured Data and Relational DatabasesMySQL: Structured Data and Relational DatabasesApr 18, 2025 am 12:22 AM

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.

MySQL: Key Features and Capabilities ExplainedMySQL: Key Features and Capabilities ExplainedApr 18, 2025 am 12:17 AM

MySQL is an open source relational database management system that is widely used in Web development. Its key features include: 1. Supports multiple storage engines, such as InnoDB and MyISAM, suitable for different scenarios; 2. Provides master-slave replication functions to facilitate load balancing and data backup; 3. Improve query efficiency through query optimization and index use.

The Purpose of SQL: Interacting with MySQL DatabasesThe Purpose of SQL: Interacting with MySQL DatabasesApr 18, 2025 am 12:12 AM

SQL is used to interact with MySQL database to realize data addition, deletion, modification, inspection and database design. 1) SQL performs data operations through SELECT, INSERT, UPDATE, DELETE statements; 2) Use CREATE, ALTER, DROP statements for database design and management; 3) Complex queries and data analysis are implemented through SQL to improve business decision-making efficiency.

MySQL for Beginners: Getting Started with Database ManagementMySQL for Beginners: Getting Started with Database ManagementApr 18, 2025 am 12:10 AM

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA

See all articles

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

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.