The Library Cache.ppt
《The Library Cache.ppt》由会员分享,可在线阅读,更多相关《The Library Cache.ppt(50页珍藏版)》请在麦多课文档分享上搜索。
1、The Library Cache,Objectives,At the end of this section, you should be able to: Explain the library cache architecture List locks, pins, and latches in the library cache Identify when library cache contention occurs Describe how to reduce library cache contention Detail how to diagnose library cache
2、 problems,The Library Cache,An area in the shared pool that manages information about: Shared cursors (SQL and PL/SQL objects) Database objects (tables, indexes, and so on) Initially created to manage PL/SQL programs and library units, therefore called library cache Scope was extended to include sha
3、red cursors and information about other RDBMS objects.,Library Cache Objects,The units of information that are stored in the library cache are called objects. There are two classes of objects: Stored objectsCreated and dropped with explicit SQL or PL/SQL commandsExamples: Tables, views, packages, fu
4、nctions Transient objectsCreated at execution time and live only for the duration of the instance (or aged out) Example: Shared and nonshared cursors,Shared Cursors,In-memory representation of an executable object: SQL statements Anonymous PL/SQL block PL/SQL stored procedures or functions Java stor
5、ed procedures Object Methods Represented by two or more objects: A parent cursor that has a name One or more child cursors containing the execution plan,Shared Cursors,select * from EMPLOYEES,Base Obj: MARK.EMPLOYEES,Base Obj: HQ.EMPLOYEES,Scott, Ted and Mark issue select * from EMPLOYEES; (EMPLOYEE
6、S is a synonym for HQ.EMPLOYEES Mark has own copy of EMPLOYEES),Shared by Scott and Ted,Used by Mark,John issues select * from employees; (John has his own copy of EMPLOYEES),select * from employees,Used by John,Parent Cursors,Child Cursors,Base Obj: JOHN.EMPLOYEES,Library Cache Architecture,The lib
7、rary cache is a hash table that is accessible through an array of hash buckets. The library cache manager (KGL) controls the access and usage of library cache objects. Memory for the library cache is allocated from the shared pool.,Hash Buckets,0,2,3,1,4,6,7,5,select * from employees,Hash Buckets,Ob
8、ject Handles,Object Handles,Name Namespace Lock owners Lock waiters Pin owners Pin waiters Flags Heap 0 (Object),Hash Bucket,Object Handles,Heap 0 (Object),Heap 0 (Object),Internally, most of the object identity is represented by structures of type kglob. These are the structures stored in heap 0. O
9、bject structures have the following components: Type Name Flags Tables Data blocks,Object Types,Objects are grouped in namespaces according to their type. Each object can only be of one type. All the objects of the same type are in the same namespace. A namespace may be used by more than one type. T
10、he most important namespace is called cursor (CRSR) and houses the shared SQL cursors.,Object Names,Library cache object names have three parts: Name of schema Name of object Name of database link (remote objects only) The format used is SCHEMA.NAMEDBLINK. For example, HR.EMPLOYEESACME.COM,Object Fl
11、ags,Public flags: Are not protected by pins or latches Indicate in detail the type of the object Status flags: Are protected by pins Indicate whether the object is being created/dropped/altered/updated Special status flags: Are protected by the library cache latch Are related to object validity and
12、authorization,Object Tables,The following tables are maintained for each object: Dependency table Child table Translation table Authorization table Access table Read-only dependency table Schema name table,Object Data Blocks,The remainder of an objects data is stored in other independent data heaps.
13、 The object structure contains an array of data block structures. The data block structures have a pointer to a different data heap. An object structure has room for 16 data block structures but not all of them are in use.,Library Cache Object,Source,Diana,Pcode,Mcode,Errors,SQL Context,0,Hash Bucke
14、ts,Object Handles,Heap 0 (Object),Object Type Object Name FlagsTablesData Blocks,Dependency table,Child table,Translation table,Authorization table,Access table,R-O dependency table,Object,. . .,Heap 1,Heap 6,Schema name table,Object Heaps,Heap 0 1 2 3 4 5 6 7 8-11,Usage Object Source Diana Pcode Mc
15、ode Errors SQL Context Free Subordinate Heaps,Locks and Pins,Locks and pins are used to control access to the library cache objects. Locks manage concurrency. Pins ensure cache coherence. When an object is accessed: First the lock is acquired on the handle Then the necessary object heaps are pinned
16、Pinning an object will load object information into memory if it is not there.,Lock and Pin Persistence,Every lock and pin is associated with a state object: Session Transaction Call If associated with a session, then the lock, or pin, persists until the session ends. If associated with a transactio
17、n, then it is released when a commit or rollback occurs. If associated with a call, then it is released when the call returns.,Lock Modes,There are three lock modes: Share (S): to read an object Exclusive (X): to modify/create objects Null (N): special for session persistency Stored objects can be l
18、ocked in any of the three modes. Transient objects (cursors) can only be held in Null (N) mode.,Lock Compatibility,Process A is holding a lock on an object of mode:,Process A tries to get another lock of mode:,Process B tries to get a lock of mode:,Pin Modes,There are two pin modes: Share (S): to re
19、ad an object heap Exclusive (X): to modify an object heap Both stored and transient object heaps can be pinned either in Share or Exclusive mode. When an object heap is pinned, it is also loaded into memory at the same time if it is not already there.,Library Cache Latches,A library cache load lock
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
2000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- THELIBRARYCACHEPPT
