X$表

本文深入探讨了Oracle数据库的内存管理机制,详细解释了多个关键内存结构,包括shared pool、large pool等,以及如何通过查询特定视图如x$ksmsp、x$ksmlru来监控和诊断内存分配情况。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

X$

blog.itpub.net

 

Table NameAcronym ExplainedComments
x$bhbuffer headerJames Morle says it's buffer hash
x$kcbwaitkernel cache, block wait
x$kcbfwaitkernel cache, block file waitA commonly used query tells you more than v$waitstat does
x$kcccpkernel cache, controlfile checkpoint progress
x$kcclekernel cache, controlfile logfile entrylebsz usually used to show log block size
x$kcfiokernel cache, file I/O
x$kclfhkernel cache, lock file header
x$kclfikernel cache, lock file index
x$kcluhkernel cache, lock undo header
x$kcluikernel cache, lock undo index
x$kdxstkernel data, index statusused in catalog.sql to create index_stats
x$kdxhskernel data, index histogramused in catalog.sql to create index_histogram
x$kghlukernel generic, heap LRUs
x$kgllkkernel generic, librarycache lockused in catblock.sql to build dba_kgllock
x$kglobkernel generic, librarycache object
x$kglpnkernel generic, librarycache pinused in catblock.sql to build dba_kgllock
x$kglstkernel generic, librarycache status
x$kqfcokernel query, fixed table columns
x$kqftakernel query, fixed table
x$kqfdtkernel query, fixed table
x$kqfpkernel query, fixed procedureused in catprc.sql to build disk_and_fixed_objects view
x$kqfszkernel query, fixed size (size of fixed objects in current version of Oracle)
x$kqfvikernel query, fixed view
x$kqfvtkernel query, fixed view table (how fixed view is built on fixed tables)
x$ksled, x$kslei, x$ksleskernel service, event definition, events for instance, events for session, respectively (not sure about "l")
x$ksmfskernel service, memory fixed SGAalso contains db_block_buffers and log_buffer sizes for some reason
x$ksmfsvkernel service, memory fixed SGA vectorsdetailing fixed SGA
x$ksmjskernel service, memory java_pool summary
x$ksmlrukernel service, memory LRU
x$ksmlskernel service, memory large_pool summary
x$ksmmemkernel service, memoryentire memory map
x$ksmppkernel service, memory process poolPGA
x$ksmsdkernel service, memory SGA definition
x$ksmspkernel service, memory shared pool
x$ksmsprkernel service, memory shared pool reserved
x$ksmsskernel service, memory shared_pool summary
x$ksmupkernel service, memory user poolUGA
x$ksqstkernel service, enqueue status
x$ksulvkernel service, user locale value
x$ksulopkernel service, user long operation
x$ksuprkernel service, user process
x$kzsrokernel security, system roleused in many SQL scripts in ?/rdbms/admin
x$lelock element
x$le_statlock element status

关于x$table的研究,可以看以下几个视图:

v$fixed_table ( where name like 'x$%')

v$fixed_view_definition (view_definition可以看到v$视图所用的x$table)

 

1.x$ksmsp (shared_pool的映象)

X$KSMSP的名称含义为:
[K]ernel [S]torage [M]emory Management [S]GA Hea[P]

addrchunk的地址
indxchunk的序号
inst_id实例号
ksmchcomchunk的简要说明
ksmchsizchunk的大小(byte)
ksmchptrchunk在内存的物理地址(16进制)
ksmchcls

chunk的类型:

perm : permanent分配,不能被free

free : free内存

recr : recreatable(可以被free/flush)

freeable: 可以被free的,但当前在使用,不准备用来被flush

 

我们关注以下几个字段:

KSMCHCOM是注释字段,每个内存块被分配以后,注释会添加在该字段中.
x$ksmsp.ksmchsiz代表块大小

x$ksmsp.ksmchcls列代表类型,主要有四类,说明如下:

free
Free chunks--不包含任何对象的chunk,可以不受限制的被分配.

recr
Recreatable chunks--包含可以被临时移出内存的对象,在需要的时候,这个对象可以
被重新创建.例如,许多存储共享sql代码的内存都是可以重建的.

freeabl
Freeable chunks--包含session周期或调用的对象,随后可以被释放.这部分内存有时候
可以全部或部分提前释放.但是注意,由于某些对象是中间过程产生的,这些对象不能
临时被移出内存(因为不可重建).

perm
Permanent memory chunks--包含永久对象.通常不能独立释放.

我们可以通过查询x$ksmsp视图来考察shared pool中存在的内存片的数量
不过注意:Oracle的某些版本(如:10.1.0.2)在某些平台上(如:HP-UX PA-RISC 64-bit)查
询该视图可能导致过度的CPU耗用,这是由于bug引起的.

 

2.x$ksmlru


[K]ernel Layer
[S]ervice Layer
[M]emory Management
[LRU]east recently used shared pool chunks flushes
from the shared pool

addrchunk的地址
indxchunk的序号
inst_id实例号
ksmchcomchunk的简要说明
ksmchsizchunk的大小(byte)
ksmlrnumshared_poolflush出去的数目
ksmlrhon

load的对象的名字

ksmlrohvload的对象的hash
ksmlrses执行这个分配的session(v$sessionsaddr连接)

说明:

The contents of this view are ZEROED when it is queried and so it shows the largest allocations since the view was last queried.

The view can be useful when looking for the cause of memory
allocations in the shared pool. It is quite normal for Oracle to flush chunks of memory from the shared pool to make space for new allocations. However, on heavily concurrent systems the shared pool can become a point of contention if SQL is not well shared. This view can help show sessions and statements requesting the largest memory allocations. The important thing to watch for is entries which are showing large values in KSMLRNUM as this indicates the number of items flushed to find a chunk of memory of size KSMLRSIZ. Under normal operation where SQL it not fully shared this table will show entries with KSMLRNUM set to 7 or 8 (as we flush in batches). If the figure is much higher than this then normal flushing is not finding space and is having to loop through the 'flush' code to find more space.

If the entries are always from the same session then it may be useful to see what the offending session is doing (eg: running a literal SQL script)

3.x$ksqst

数据库中各种lock的统计,下面的sql可以得出每种锁waitget的次数:

 

4.x$kvis

数据库的块大小及最大可用大小


         

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/756652/viewspace-242135/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/756652/viewspace-242135/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值