learning v$ view-> v$sqltext&v$sqlarea
2011-09-28 08:49
316 查看
V$SQLTEXT
This view contains the complete SQL text for the SQL statements in the shared pool.Note:V$SQLAREAonly contains only the first 1000 characters. |
Useful Columns for V$SQLTEXT
HASH_VALUE: Hash value for the SQL statement
ADDRESS: Address of the SQL statement cursor in SGA
SQL_TEXT: Statement text in 64 character chunks
PIECE: Ordering information for the SQL statement pieces
Join Columns for V$SQLTEXT
Table 24-27 lists the join columns forV$SQLTEXT.
[b]Table 24-27 Join Columns for V$SQLTEXT[/b]
Column | View | Joined Column(s) |
---|---|---|
HASH_VALUE, ADDRESS | V$SQL, V$SESSION | HASH_VALUE, ADDRESS |
HASH_VALUE. ADDRESS | V$SESSION | SQL_HASH_VALUE. SQL_ADDRESS |
Example 24-30 Finding the SQL Statement for a Hash Value
SELECT sql_text FROM V$SQLTEXT WHERE hash_value = 228801498 ORDER BY piece; SQL_TEXT ---------------------------------------------------------------- select dbsu.primary_flag, i.site_use_code, i.rowid from ra_customers dbc, ra_addresses dbad, ra_site_uses dbsu, ra_customers_ interface i where (((((((i.orig_system_customer_ref=dbc.orig_system_reference and dbad.address_id=dbsu.address_id) and i.site_use_code=dbsu.site_use_code) and dbsu.status='A') and dbad.customer_id=dbc.customer_id) and i.request_id=:b0) and nvl(i.validated_flag,'N')<>'Y') and ((i.primary_site_use_flag='Y' and dbsu.primary_flag='Y') or dbsu.site_use_code in ('STMTS','DUN','LEGAL')))
V$SQLAREA
This view keeps track of all the shared cursors present in the shared pool. It has one row for every SQL statement present in the shared pool. It is an invaluable view for finding the resource usage of a SQL statement.Information columns in V$SQLAREA
HASH_VALUE: Hash value of the SQL statement
ADDRESS: SGA address for the SQL statement
These two columns are used to identify the SQL statement. Sometimes, two different statements could hash to the same value. In such cases, it is necessary to use the address along with the hash_value.
PARSING_USER_ID: User who parsed the first cursor for the statement
VERSION_COUNT: Number of cursors for the statement
KEPT_VERSIONS: Cursors of the statement pinned using
DBMS_SHARED_POOL.
KEEP()
SHARABLE_MEMORY: Total shared memory used by the cursor
PERSISTENT_MEMORY: Total persistent memory used by the cursor
RUNTIME_MEMORY: Total runtime memory used by the cursor
SQL_TEXT: Up to first 1000 characters of SQL statement
MODULE,
ACTION: Information about the session parsing the first cursor if set using
DBMS_APPLICATION_INFO
Other Useful Columns in V$SQLAREA
These columns get incremented with each execution of the statement.BUFFER_GETS: Number of logical reads for this statement
DISK_READS: Number of physical reads for this statement
SORTS: Number of sorts for this statement
CPU_TIME: CPU time used for parsing and executing this statement
ELAPSED_TIME: Elapsed time for parsing and executing this statement
PARSE_CALLS: Number of parse calls (hard and soft) for this statement
EXECUTIONS: Number of times this statement was executed
INVALIDATIONS: Number of times the cursors for this statement have been invalidated
LOADS: Number of loads (and reloads) for this statement
ROWS_PROCESSED: Total number of rows this statement returns
Join Columns in V$SQLAREA
Table 24-26 lists the join columns forV$SQLAREA.[b]Table 24-26 Join Columns for V$SQLAREA[/b]
Column | View | Joined Column(s) |
---|---|---|
HASH_VALUE, ADDRESS | V$SESSION | SQL_HASH_VALUE, SQL_ADDRESS |
HASH_VALUE, ADDRESS | V$SQLTEXT, V$SQL, V$OPEN_CURSOR | HASH_VALUE, ADDRESS |
SQL_TEXT | V$DB_OBJECT_CACHE | NAME |
Example 24-28 Finding Resource-intensive SQL
There are several costs you can use:Total logical I/O (LIO), LIO for each executionTotal physical I/O (PIO), PIO for each execution
PIO/LIO (poor cache hit ratio)
parse_calls, parse_calls for each executions
SELECT hash_value, executions, buffer_gets, disk_reads, parse_calls FROM V$SQLAREA WHERE buffer_gets > 10000000 OR disk_reads > 1000000 ORDER BY buffer_gets + 100*disk_reads DESC; HASH_VALUE EXECUTIONS BUFFER_GETS DISK_READS PARSE_CALLS ---------- ---------- ----------- ---------- ----------- 2676594883 126 7583140 6199113 126 4074144966 126 7264362 6195433 49 228801498 136 236116544 2371187 136 360282550 5467 21102603 4476317 2355 1559420740 201 8197831 4537591 39 3213702248 28039654 364516977 44 131 1547710012 865 7579025 3337735 865 3000880481 4481 3676546 2212658 2885 1398193708 4946 73018658 1515257 1418 1052917712 8342025 201246652 38240 327462 371697988 7 74380777 862611 7 1514306888 3922461 29073852 1223482 268 1848522009 1 1492281 1483635 1 1478599096 28042103 140210513 594 164 226079402 21473 22121577 1034787 4484 478652562 4468 21669366 1020370 4438 2054874295 73520 118272694 29987 73520
Note: If a statement is executing for the first time on the system and responsible for large fraction of the current resource usage, then this statement does not find that statement, because the BUFFER_GETSand DISK_READSstatistics do not get updated until the statement finishes execution. |
Example 24-29 Finding Resources Used by a SQL Statement
SELECT hash_value, buffer_gets, disk_reads, executions, parse_calls FROM V$SQLAREA WHERE hash_Value = 228801498 AND address = hextoraw('CBD8E4B0'); HASH_VALUE BUFFER_GETS DISK_READS EXECUTIONS PARSE_CALLS ---------- ----------- ---------- ---------- ----------- 228801498 236116544 2371187 136 136
相关文章推荐
- learning v$ view-> v$sql & V$sql_plan
- This tag and its children can be replaced by one <TextView/> and a compound drawable
- AutoCompleteTextView 自定义adapter。 可以添加List<Map<String,Object>>
- 从零开始学android<TextView的使用.四.>
- 从头学起android<AutoCompleteTextView文章提示文本框.十九.>
- Android入门:向TextView添加滚动条(添加<ScrollView>标签)
- Android学习 19 ->自动提示输入AutoCompleteTextView
- 我的Android进阶之旅------> Android为TextView组件中显示的文本加入背景色
- 学习动态性能表(4)--v$sqltext&v$sqlarea
- Android UI设计之<四>自定义TextView属性,实现带边框效果的TextView
- Android学习 11 ->控件之TextView和EditText
- Android实战简易教程<三十二>(自定义View登录注册界面EditText-实现一键清空)
- This tag and its children can be replaced by one <TextView/> and a compound drawable
- This tag and its children can be replaced by one <TextView/> and a compound drawable
- Android UI设计之<六>使用HTML标签,实现在TextView中对部分文字进行加粗显示
- This tag and its children can be replaced by one <TextView/> and a compound drawable
- android This tag and its children can be replaced by one <TextView/> and a compound drawable 布局文件提示
- eclipse提示:This tag and its children can be replaced by one <TextView/> and a compound drawable
- android中使用TextView来显示某个网址的内容,使用<ScrollView>来生成下拉列表框
- android中使用TextView来显示某个网址的内容,使用<ScrollView>来生成下拉列表框