v$sql v$sqlarea v$sqltext
V$SQL lists statistics on shared SQL areas without the GROUP BY clause and contains one row for each child of the original SQL text entered. Statistics displayed in V$SQL are normally updated at the end of query execution. However, for long running queries, they are updated every 5 seconds. This makes it easy to see the impact of long running SQL statements while they are still in progress.
明顯v$sql的信息來源於共享內存區shared SQL areas,也就是說相關SQL信息在數據庫重啟,數據庫緩存被刷,或相關SQL信息被踢出緩存區,此SQL的信息就不能在V$SQL裏查詢。而V$SQL記錄每一個SQL的每一個子遊標的信息。
V$SQLAREA displays statistics on shared SQL areas and contains one row per SQL string. It provides statistics on SQL statements that are in memory, parsed, and ready for execution.
同樣v$sqlarea也存儲於library cache,然而這個視圖卻做了一個統計分析,統計的方式是以sql string,也就是以sql_text文本做了group by,在此前提下對其他信息統計sum()。通過version_count可以得出SQL子遊標的總數。所以簡單的說:v$sqlarea存放的是相同SQL語句不同version一個匯總。
version_count:Number of child cursors that are present in the cache under this parent
excutions : Total number of executions, totalled over all the child cursors
V$SQLTEXT displays the text of SQL statements belonging to shared SQL cursors in the SGA.
v$sql及v$sqlarea存放的更多的是性能數據,但其sql_text是不完整的的,如果想獲得完整的sql就要用v$sqltext。
v$sql v$sqlarea v$sqltext