SQL的reload以及Invalidations
關於SQL 的 遊標版本不高,但 reload 以及 Invalidations 次數相對比較多。基本上是每一次 Invalidations 便伴隨著一次 reload. 關於 load 以及 Invalidations 的說明如下,
Invalidations - An invalidation is a measure of the number of times a cached cursor is deleted from the cache because it is no longer valid. A cursor is invalidated because something has changed such that the copy of the cursor in memory is not valid any more. For example, regathering the statistics on an object or modifying a table definition is enough to invalidate a cursor for a query that is based on that object. When a cursor is invalidated, any sessions wanting to use the cursor need to wait for a valid version to be loaded.
Reloads - Reload is a count of the number of times a cursor that previously existed in the cache, was searched for, found to not be there (because it had aged out etc) and then had to be re-compiled and re-loaded in to the library cache. High reloads are a bad thing because they indicate that you are doing work that you would not have had to do if your cache was setup appropriately so as not to remove the cursor in the first place.
目前看起來是統計資訊收集引起,導致當每次統計收集後便發生一次 load 。
以下,關於keep cursor 實驗,看起來 keep 後還是會發生 reload 情況。
LOADS 1次, INVALIDATIONS 0次
select sql_id, LOADS,INVALIDATIONS,FIRST_LOAD_TIME,LAST_LOAD_TIME,address,hash_value
from v$sql where sql_id='adh4jbfb4q8bt';
SQL_ID LOADS INVALIDATIONS FIRST_LOAD_TIME LAST_LOAD_TIME ADDRESS HASH_VALUE
-------------- ---------- ------------- -------------------------------------- -------------------------------------- ---------------- ----------
adh4jbfb4q8bt 1 0 2020-12-30/00:06:19 2020-12-30/00:06:19 000000019DC2D5B8 2521506169
2. 將 cusor keep 起來:
SQL> exec DBMS_SHARED_POOL.KEEP('000000019DC2D5B8,2521506169','C');
PL/SQL procedure successfully completed.
3. 做一次統計資訊收集,讓遊標立即失效 ,no_invalidate=>FALSE 。
SQL> delete from cwdtest.TEST_STA1 where rownum<=5000;
5000 rows deleted.
SQL> commit;
Commit complete.
SQL> exec DBMS_STATS.GATHER_TABLE_STATS(ownname=>'CWDTEST',tabname=>'TEST_STA1',cascade=>true,force=>true,no_invalidate=>FALSE);
PL/SQL procedure successfully completed.
4. 再次執行 sql 之後還是會出現 INVALIDATIONS ,並再 reload 一次。
select sql_id, LOADS,INVALIDATIONS,FIRST_LOAD_TIME,LAST_LOAD_TIME,address,hash_value
from v$sql
3 where sql_id='adh4jbfb4q8bt';
SQL_ID LOADS INVALIDATIONS FIRST_LOAD_TIME LAST_LOAD_TIME ADDRESS HASH_VALUE
-------------------------- ---------- ------------- -------------------------------------- -------------------------------------- ---------------- ----------
adh4jbfb4q8bt 2 1 2020-12-30/00:06:19 2020-12-30/00:15:51 000000019DC2D5B8 2521506169
SQL>
SQL> /
SQL_ID LOADS INVALIDATIONS FIRST_LOAD_TIME LAST_LOAD_TIME ADDRESS HASH_VALUE
-------------------------- ---------- ------------- -------------------------------------- -------------------------------------- ---------------- ----------
adh4jbfb4q8bt 2 1 2020-12-30/00:06:19 2020-12-30/00:15:51 000000019DC2D5B8 2521506169
5. 再次做一次統計資訊收集,遊標不失效 no_invalidate=>TRUE 。
SQL> delete from cwdtest.TEST_STA1 where rownum<=5000;
5000 rows deleted.
SQL> commit;
Commit complete.
SQL> exec DBMS_STATS.GATHER_TABLE_STATS(ownname=>'CWDTEST',tabname=>'TEST_STA1',cascade=>true,force=>true,no_invalidate=>TRUE);
PL/SQL procedure successfully completed.
6. 再次執行 sql 後不會出現 INVALIDATIONS 且不會 reload.
select sql_id, LOADS,INVALIDATIONS,FIRST_LOAD_TIME,LAST_LOAD_TIME,address,hash_value
from v$sql
3 where sql_id='adh4jbfb4q8bt';
SQL_ID LOADS INVALIDATIONS FIRST_LOAD_TIME LAST_LOAD_TIME ADDRESS HASH_VALUE
-------------------------- ---------- ------------- -------------------------------------- -------------------------------------- ---------------- ----------
adh4jbfb4q8bt 2 1 2020-12-30/00:06:19 2020-12-30/00:15:51 000000019DC2D5B8 2521506169
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29863023/viewspace-2783932/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- import reload from...reload的區別Import
- Nginx reloadNginx
- Flink的Table以及SQLSQL
- Python模組reloadPython
- nmcli connection reload
- reload在python中的使用Python
- Flutter的Hot Reload是如何做到的Flutter
- Metasploit reload命令使用技巧
- MySQL reload許可權MySql
- 【Oracle】lsnrctl reload 命令操作Oracle
- 踩一個Flutter Hot Reload的新坑Flutter
- 【Oracle】lsnrctl reload 命令簡介Oracle
- 揭秘Flutter Hot Reload(基礎篇)Flutter
- 3 、lsnrctl> reload L1命令
- SQL server 中SUBSTRING()以及CONVERT()的用法SQLServer
- import reload __import__在python中的區別ImportPython
- struts的1.2.9還是不能auto reload配置檔案?
- Rolling Cursor Invalidations with DBMS_STATS.AUTO_INVALIDATE (文件 ID 557661.1)
- 揭祕Flutter Hot Reload(基礎篇)Flutter
- 揭祕Flutter Hot Reload(原理篇)Flutter
- 如何獲取objects的定義 - imp show=y 以及 impdp sqlfile=meta_sql.sqlObjectSQL
- Python 解決 :NameError: name 'reload' is not defined 問題PythonError
- js重新整理頁面location.reload()用法JS
- android studio Cannot reload AVD list問題Android
- DuckDB_SQL-使用示例以及和PG之間的概念SQL
- LangChain SQL介紹以及使用Qwen1.5執行SQL查詢教程LangChainSQL
- Homestead 的 Nginx 配置 Vagrant reload --provision 後不能定製的問題Nginx
- 使用SQL以及函式等做資料分析SQL函式
- Oracle檢視正在執行的SQL以及執行計劃分析OracleSQL
- Oracle 查詢重複記錄,以及簡單的sql應用。OracleSQL
- 配置熱更新/支援 Reload、QUIC 橋接再升級UI橋接
- Spark SQL中Not in Subquery為何低效以及如何規避SparkSQL
- Mysql許可權管理以及sql資料備份MySql
- SQL隱碼攻擊問題以及解決方法SQL
- [譯] 如何使用 Pandas 重寫你的 SQL 查詢以及其他操作SQL
- 使用Hibernate+MySql+native SQL的BUG,以及解決辦法MySql
- 【常見的SQL Server連線失敗錯誤以及解決方法】SQLServer
- 邏輯有點難理解的Sql執行結果,以及用處SQL