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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Nginx reloadNginx
- Flink的Table以及SQLSQL
- location.reload()
- nmcli connection reload
- reload在python中的使用Python
- Python模組reloadPython
- Flutter的Hot Reload是如何做到的Flutter
- Metasploit reload命令使用技巧
- 踩一個Flutter Hot Reload的新坑Flutter
- 揭秘Flutter Hot Reload(基礎篇)Flutter
- 揭祕Flutter Hot Reload(基礎篇)Flutter
- 揭祕Flutter Hot Reload(原理篇)Flutter
- DuckDB_SQL-使用示例以及和PG之間的概念SQL
- Homestead 的 Nginx 配置 Vagrant reload --provision 後不能定製的問題Nginx
- Python 解決 :NameError: name 'reload' is not defined 問題PythonError
- LangChain SQL介紹以及使用Qwen1.5執行SQL查詢教程LangChainSQL
- 使用SQL以及函式等做資料分析SQL函式
- Oracle 11 sql tuning advisor sql access advisor關閉以及job檢視與停止OracleSQL
- js重新整理頁面location.reload()用法JS
- SQL 第一章 SQL2008R2的安裝以及資料庫的簡單應用SQL資料庫
- SQL隱碼攻擊問題以及解決方法SQL
- Mysql許可權管理以及sql資料備份MySql
- Spark SQL中Not in Subquery為何低效以及如何規避SparkSQL
- [譯] 如何使用 Pandas 重寫你的 SQL 查詢以及其他操作SQL
- 配置熱更新/支援 Reload、QUIC 橋接再升級UI橋接
- Oracle表 列欄位的增加、刪除、修改以及重新命名操作sqlOracleSQL
- sql中別名as,不寫,以及使用雙引號總結SQL
- 報錯install_driver(mysql) failed: Attempt to reload DBD/mysql.pmMySqlAI
- Laravel 中引入 Swoole Websocket 並實現熱更新 Reload 程式碼LaravelWeb
- python3中reload()函式報錯怎麼解決Python函式
- 一次搞定各種資料庫SQL執行計劃:MySQL、Oracle、SQL Server、PostgreSQL以及SQLite資料庫MySqlOracleServerSQLite
- oracle學習筆記(十五) PL/SQL語法結構以及使用Oracle筆記SQL
- spark sql在scala中使用的兩種方式,以及其他一些知識點SparkSQL
- [20200417]跟蹤特定sql語句以及v$open_cursor檢視.txtSQL
- EMQX 近期更新:規則引擎新增多項 SQL 函式以及 Tablestore 整合MQSQL函式
- Sql Server關於許可權、角色以及登入名、使用者名稱的總結SQLServer
- 【SQL】SQL中if條件的使用SQL
- 【SQL】Oracle SQL處理的流程SQLOracle