An in-depth discussion on shared pool (II.)

Source: Internet
Author: User

An in-depth discussion on shared pool (II.)

Sunday, 2004-08-22 21:23 eygle




Link

Http://www.eygle.com/internal/shared_pool-2.htm
Let's move on to the previous question.
In fact, we can monitor the space fragmentation of the shared pool from within the database.
This involves an internal view X$ksmsp

X$ksmsp's name means: [K]ernal [S]torage [m]emory Management [S]ga hea[p]
Each of these lines represents a chunk in the shared pool.

First, record the test environment:



Sql> select * from V$version;

BANNER
----------------------------------------------------------------
Oracle9i Enterprise Edition Release 9.2.0.3.0-production
Pl/sql Release 9.2.0.3.0-production
CORE 9.2.0.3.0 Production
TNS for Linux:version 9.2.0.3.0-production
Nlsrtl Version 9.2.0.3.0-production



Let's take a look at the structure of X$ksmsp:




sql> desc x$ksmsp Name Null? Type-----------------------------------------------------------------------------ADDR RAW (4) INDX number inst_id Number Ksmchidx number Ksmchdur number ksmchcom VARCHAR2 (a) ksmchptr RAW (4) ksmchsiz number Ksmchcls VARCHAR2 (8) Ksmchtyp Number Ksmchpar RAW (4)




We focus on the following fields:

Ksmchcom is the annotation field, and the comment is added to the field after each memory block is assigned.
X$KSMSP.KSMCHSIZ represents block Size

The X$ksmsp.ksmchcls column represents the type, which has four main categories, as described below:

Free
Free chunks--does not contain chunk of any object and can be assigned without restriction.

Recr
The Recreatable chunks--contains objects that can be temporarily moved out of memory, and when needed, this object can be
was recreated. For example, many of the memory that stores shared SQL code can be rebuilt.

Freeabl
Freeable chunks--contains the session period or the called object, which can then be freed. This part of memory sometimes
Can be released in full or in part. But note that because some objects are generated by intermediate processes, these objects cannot be
Temporarily removed from memory (because it is not rebuilt).

Perm
Permanent memory chunks--contains permanent objects. It is not usually possible to release independently.

We can examine the number of memory slices that exist in the shared pool by querying the X$ksmsp view
Note, however, that some versions of Oracle (such as: 10.1.0.2) are found on certain platforms (e.g., HP-UX Pa-risc 64-bit)
Consulting This view may cause excessive CPU consumption, which is caused by bugs.

Let's take a look at the test:




The initial startup database has 2,259 chunksql> select COUNT (*) from X$ksmsp in the X$ksmsp; COUNT (*)----------2259 executes the query:sql> select COUNT (*) from dba_objects; COUNT (*)----------10491 The number of chunk in the shared pool is increased sql> select COUNT (*) from X$ksmsp; COUNT (*)----------2358






This is because the shared pool in SQL parsing, request space, resulting in the request free space, allocation, split
resulting in more and more finely broken memory chunk

From this we can see that if there are a lot of hard parsing in the database system, the shred pool memory that allocates free is requested
In addition to the necessary competition for shared pool latch, it is inevitable that more memory fragmentation will result in the shared pool
(Of course, in memory recycling, you may see a decrease in the number of chunk)

Let's look at the following tests:


First restart the database:sql> startup Force;oracle instance started. Total System Global area 47256168 bytesfixed size 451176 bytesvariable size 29360128 bytesdatabase buffers 16777216 Edo buffers 667648 bytesdatabase mounted. Database opened. Create a temporary table to hold the previous X$KSMSP status:sql> create GLOBAL temporary TABLE E$ksmsp on COMMIT PRESERVE ROWS as 2 SELECT a.ksmchcom, 3 sum (a.chunk) CHUNK, 4 sum (A.RECR) RECR, 5 sum (A.FREEABL) freeabl, 6 sum (a.sum) sum 7 from (SELECT KSMCHC OM, COUNT (ksmchcom) CHUNK, 8 DECODE (ksmchcls, ' RECR ', sum (ksmchsiz), NULL) RECR, 9 DECODE (ksmchcls, ' freeabl ', SUM (KS Mchsiz), NULL) freeabl sum (ksmchsiz) sum from X$ksmsp Group by ksmchcom, Ksmchcls) a WHERE 1 = 0 GROUP by a. ksmchcom; Table created. Save the current shared pool state:sql> INSERT into E$ksmsp 2 SELECT a.ksmchcom, 3 sum (a.chunk) CHUNK, 4 sum (A.RECR) rec R, 5 sum (A.FREEABL) freeabl, 6 sum (a.sum) sum 7 from (SELECT ksmchcom, COUNT (ksmchcom) CHUNK, 8 DECODE (ksmchcls, ' RECR ', SUM (Ksmchsiz), NULL) RECR, 9 DECODE(Ksmchcls, ' freeabl ', sum (ksmchsiz), NULL) freeabl, sum (ksmchsiz) sum one from X$ksmsp to GROUP by ksmchcom, Ksmchcls) A GROUP by a.ksmchcom 14/41 rows created. Execute Query:sql> SELECT COUNT (*) from dba_objects; COUNT (*)----------10492 Comparison of changes in shared pool memory allocations before and after:sql> select A.ksmchcom,a.chunk,a.sum,b.chunk,b.sum, (A.chunk- B.chunk) C_diff, (A.sum-b.sum) S_diff 2 from 3 (SELECT a.ksmchcom, 4 sum (a.chunk) chunk, 5 sum (A.RECR) RECR, 6 sum (a.fr EEABL) Freeabl, 7 sum (a.sum) sum 8 from (SELECT ksmchcom, COUNT (ksmchcom) CHUNK, 9 DECODE (ksmchcls, ' RECR ', sum (ksmchs IZ), NULL) RECR, DECODE (ksmchcls, ' freeabl ', sum (ksmchsiz), null) FREEABL, sum (ksmchsiz) sum from X$ksmsp G Roup by ksmchcom, Ksmchcls) A-GROUP by a.ksmchcom) A,e$ksmsp b where a.ksmchcom = B.ksmchcom and (a.chunk-b.chunk) <>0 16/ksmchcom CHUNK sum CHUNK sum c_diff s_diff------------------------------------------------------------ ----------------KGL handles 313 102080 302 98416 3664KGLSHeap 274 365752 270 360424 4 5328KQR PO 389 198548 377 192580 5968free memory 2292076 2381304 3-89228library CAC He 1005 398284 965 381416 16868sql area 287 547452 MB 490052 rows 574006.




Let us briefly analyze the above results:
First, the free memory size is reduced by 89228 (added to another five components), which means that the SQL resolution store takes up a certain amount of memory space
The increase in chunk from 90 to 93 indicates an increase in memory fragmentation.

In the following sections, I'll take a look at KGL handles, Kgls heap the memory structures in these two very important shared pool.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.