Shared Pool Series three: library cache structure/library Cache object structure

Source: Internet
Author: User
Tags hash

Library cache structure/library The structure of cache object-dump Libraryhandle

Library Cache Structure

The main function of Library cache is to store user-submitted SQL statements, SQL statement-related parse tree (parse tree is the representation of all objects involved in SQL statements)---> Shared SQL area (shared SQL areas), private SQL area ( Private Sqlareas, if a shared server is configured, execution plans, user-submitted Pl/sql blocks (including anonymous chunks, stored procedures, packages, functions, etc.) and code that they can execute after conversion to Oracle, to manage these memory structures, Library cache also contains a lot of control structure, including Lock,pin,dependency table,11g in the mutex and so on.

The Library cache needs to solve three problems:

(1). Quick-Positioning problem: There are many objects in the Library cache, how Oracle manages these objects so that service processes can quickly find the information they need. For example, a service process needs to quickly locate whether a SQL exists in Librarycache. ---Oracle uses hash table structure to solve the problem of fast location in library cache

(2). The problem of dependency: the objects in the Library cache have complex dependencies, and when a objec is invalidated, the objects that depend on it can be quickly set to a failure state. For example, a table has undergone a structural change, and the SQL statements that depend on it need to be resolved again. ---dependency table in Lco

(3). Concurrency control problem: The Library cache must have a concurrent control mechanism, such as a lock, to manage the problem of concurrent access and modification of a large number of shared objects, such as when a SQL is recompiled and the objects it relies on cannot be modified. ----LATCH LOCK PIN

The Library cache consists of a hash table, which consists of a hash buckets array.

Each hash bucket is a two-way list containing the library cache handle.

The library cache handle points to the library cache object and a list of references.

Library Cache object is further divided into: dependent table, child table, authorization table, etc.

The same SQL statement, the same hash value, placed in the same library cache handle--, such as binding variables, is a different child cursor with the same library cache handle. Different SQL statements, the same hash value placed in the same hash bucket different library cache handle.

Hash algorithm

Oracle is heavily used in internal management to hash, the purpose of using hash is to quickly find and locate.

Hash the value, produce an index number, and then place the value in the corresponding hash bucket according to the index number.

Depending on the law of the hash operation, multiple index numbers will be generated, with each index number corresponding to a hash bucket (a numeric column).

In the search for values, the search for the value of the hash, produce an index number, then this number must be in the corresponding hash bucket index number, and then jump directly to the hash bucket to traverse. In this way, when the data is positioned, it can greatly reduce the number of traversal.

Hash bucket: A hash bucket is used to manage the library cache

1, first according to the shared_pool_size specified size to automatically calculate the number of hash bucket

2, each hash bucket after a series of multiple handles

The handle describes some of the attributes of the object in the library cache, including the name, tag, and pointer to the memory address where the object is.

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.