成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

怎么解析Cursor和綁定變量

這篇文章將為大家詳細講解有關怎么解析Cursor和綁定變量,文章內(nèi)容質(zhì)量較高,因此小編分享給大家做個參考,希望大家閱讀完這篇文章后對相關知識有一定的了解。

網(wǎng)站建設哪家好,找成都創(chuàng)新互聯(lián)公司!專注于網(wǎng)頁設計、網(wǎng)站建設、微信開發(fā)、小程序制作、集團企業(yè)網(wǎng)站建設等服務項目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了城廂免費建站歡迎大家使用!

如下是我就這次演講的內(nèi)容做的一點概括,里面也包含了我回答一些朋友的問題的郵件內(nèi)容:

Oracle里的cursor分為兩種:一種是shared cursor,一種是session cursor。

所謂的shared cursor就是指緩存在library cache里的一種library cache object,說白了就是指緩存在library cache里的sql和匿名pl/sql。它們是oracle緩存在library cache中的幾十種library cache object之一,它所屬于的namespace是CRSR(也就是cursor的縮寫)。你信里提到的parent cursor和child cursor都是shared cursor,它們都是以library cache object handle的方式存在library cache里,當一條sql第一次被執(zhí)行的時候,會同時產(chǎn)生parent cursor和child cursor,parent cursor的library cache object handle的heap 0里會存儲其child cursor的地址,這個sql的執(zhí)行計劃會存儲在上述child cursor的library cache object handle的heap 6中,第一次執(zhí)行上述sql所產(chǎn)生的parent cursor和child cursor的過程也就是所謂的"硬解析"主要做的事情。如果上述sql再次執(zhí)行,Oracle只需要去掃描相應的library cache object handle,找到上次硬解析后產(chǎn)生的child cursor,把里面的parse tree和執(zhí)行計劃直接拿過用就可以了,這就是所謂的"軟解析"。

Oracle里的第二種cursor就是session cursor,session cursor又分為三種:分別是implicit cursor,explicit cursor和ref cursor。所謂的session cursor其實就是指的跟這個session相對應的server process的PGA里(準確的說是UGA)的一塊內(nèi)存區(qū)域(或者說內(nèi)存結構),它的目的是為了處理且一次只處理一條sql語句(這里是指一個implicit cursor一次只處理一條sql,explicit cursor和ref cursor處理sql的數(shù)量是由你自己所控制)。

一個session cursor只能對應一個shared cursor,而一個shared cursor卻可能同時對應多個session cursor。

當某個session cursor和其對應的shared cursor建立關聯(lián)后,如果你把cursor_space_for_time調(diào)成true,當一個session cursor處理完一條sql后,它就不會被destroy,Oracle會把其cache起來(我們稱之為soft closed session cursor),這么做的目的是很明顯的,因為這個soft closed掉的session cursor已經(jīng)和包含其執(zhí)行計劃和parse tree的shared cursor建立了聯(lián)系,那么當在這個session中再次執(zhí)行同樣的sql的時候,Oracle就不再需要去掃描library cache了,直接把剛才已經(jīng)soft closed掉的session cursor拿過來用就好了,這就是所謂的"軟軟解析"。

最后我說一下特別容易混淆的Oracle里幾個關于cursor的參數(shù)的含義:

1、open_cursors

open_cursors指的是在單個session中同時能以open狀態(tài)存在的session cursor的最大數(shù)量 

2、session_cached_cursors

session_cached_cursors指的是單個session中同時能cache住的soft closed session cursor的最大數(shù)量

3、cursor_space_for_time

關于cursor_space_for_time有三點需要注意:1) 10.2.0.5和11.1.0.7里它已經(jīng)作廢了;2) 把它的值調(diào)成true后如果還同時用到了綁定變量,則由于Bug 6696453的關系,可能會導致logical data corruption;3) 把它的值調(diào)成true后,所有的child cursor在執(zhí)行完后依然會持有l(wèi)ibrary cache pin,直到其parent cursor關閉

首先我們來看一下library cache object所屬于的namespace的定義:

1. Library cache objects are grouped in namespaces according to their type.

2. Each object can only be of one type.

3. All the objects of the same type are in the same namespace.

4. A namespace may be used by more than one type.

5. The most important namespace is called cursor (CRSR) and houses the shared SQL cursors.

你在obj$看到的關于namespace的解釋當然是不全的,因為像shared cursor這樣的library cache object根本就不在obj$里。

所以實際上你可以這樣理解:namespace是針對緩存在library cache里的library cache object來說的,那為什么obj$里會有namespace的定義呢?----因為library cache object有一部分的來源就是來自于數(shù)據(jù)庫里已經(jīng)存在的、固化的object的metadata。

我們再來看一下library cache object所屬于的namespace的詳細說明:

Currently there are 64 different object types but this number may grow at any time with the introduction of new features. Examples of types are: cursor, table, synonym, sequence, index, LOB, Java source, outline, dimension, and so on. Not every type corresponds to a namespace. Actually, there are only 32 namespaces which, of course, are also subject to increase at any time.

What is a certainty is that all the objects of the same type will always be stored in the same namespace. An object can only be of one type, hence the search for an object in the library cache is reduced to a search for this object in the corresponding namespace.

Some namespaces contain objects of two or three different types. These are some of the most commonly used namespaces:

CRSR: Stores library objects of type cursor (shared SQL statements)

TABL/PRCD/TYPE: Stores tables, views, sequences, synonyms, procedure specifications, function specifications, package specifications, libraries, and type specifications

BODY/TYBD: Stores procedure, function, package, and type bodies

TRGR: Stores library objects of type trigger

INDX: Stores library objects of type index

CLST: Stores library objects of type cluster

The exact number and name of namespaces in use depends on the server features that are used by the application. For example, if the application uses Java, namespaces like JVSC (java source) and JVRE (Java resource) may be used, otherwise they will not be used.

Note: These namespaces do not store tables, clusters, or indexes as such, only the metadata is stored.

最后的結論是:我也看不到KQD.H的內(nèi)容,所以我也無法知道Oracle里所有的namespace的準確namespace id,但是其實你是可以通過library cache dump里的所有namespace的列表來猜出來的,因為這顯示是按namespace id來排序的。

可以通過library cache dump知道某個Oracle的版本下所有的namespace,如下所示的是9.2.0.6的:

LIBRARY CACHE STATISTICS:
namespace           gets hit ratio      pins hit ratio    reloads   invalids
-------------- --------- --------- --------- --------- ---------- ----------
CRSR                1078     0.860      4989     0.935         17          0
TABL/PRCD/TYPE       596     0.636       780     0.624          0          0
BODY/TYBD              1     0.000         0     0.000          0          0
TRGR                   1     0.000         1     0.000          0          0
INDX                  76     0.474        45     0.111          0          0
CLST                 148     0.953       203     0.961          0          0
OBJE                   0     0.000         0     0.000          0          0
PIPE                   0     0.000         0     0.000          0          0
LOB                    0     0.000         0     0.000          0          0
DIR                    0     0.000         0     0.000          0          0
QUEU                  30     0.700        30     0.700          0          0
OBJG                   0     0.000         0     0.000          0          0
PROP                   0     0.000         0     0.000          0          0
JVSC                   0     0.000         0     0.000          0          0
JVRE                   0     0.000         0     0.000          0          0
ROBJ                   0     0.000         0     0.000          0          0
REIP                   0     0.000         0     0.000          0          0
CPOB                   0     0.000         0     0.000          0          0
EVNT                   1     0.000         1     0.000          0          0
SUMM                   0     0.000         0     0.000          0          0
DIMN                   0     0.000         0     0.000          0          0
CTX                    0     0.000         0     0.000          0          0
OUTL                   0     0.000         0     0.000          0          0
RULS                   0     0.000         0     0.000          0          0
RMGR                   0     0.000         0     0.000          0          0
IFSD                   1     0.000         0     0.000          0          0
PPLN                   0     0.000         0     0.000          0          0
PCLS                   0     0.000         0     0.000          0          0
SUBS                   0     0.000         0     0.000          0          0
LOCS                   0     0.000         0     0.000          0          0
RMOB                   0     0.000         0     0.000          0          0
RSMD                   0     0.000         0     0.000          0          0
JVSD                   0     0.000         0     0.000          0          0
ENPR                   0     0.000         0     0.000          0          0
RELC                   0     0.000         0     0.000          0          0
STREAM                 0     0.000         0     0.000          0          0
APPLY                  0     0.000         0     0.000          0          0
APPLY SOURCE           0     0.000         0     0.000          0          0
APPLY DESTN            0     0.000         0     0.000          0          0
TEST                   0     0.000         0     0.000          0          0
CUMULATIVE          1932     0.778      6049     0.888         17          0

從結果里看9.2.0.6是一共有40個namespace。

關于怎么解析Cursor和綁定變量就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。

網(wǎng)站標題:怎么解析Cursor和綁定變量
鏈接URL:http://jinyejixie.com/article48/ijdohp.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供動態(tài)網(wǎng)站、電子商務、移動網(wǎng)站建設手機網(wǎng)站建設、網(wǎng)站維護、網(wǎng)站設計

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

手機網(wǎng)站建設
班玛县| 漳平市| 枞阳县| 施甸县| 阜康市| 台南县| 晴隆县| 华容县| 永春县| 车致| 东方市| 郴州市| 锦州市| 巴马| 顺昌县| 两当县| 金溪县| 呼图壁县| 同仁县| 晋江市| 海南省| 绥德县| 东宁县| 奉化市| 郑州市| 临澧县| 旺苍县| 贵定县| 洛浦县| 墨竹工卡县| 大英县| 淮阳县| 宣汉县| 德江县| 云浮市| 孝感市| 永定县| 兴安盟| 石屏县| 云梦县| 宁安市|