How to display database statistics for all objects used in a SQL statement
Database stats based on objects found in v$sql_plan
JKSTILL@oravm > @stats-sqlid 0urxa3bh3g3y4 N
SQL_ID? :
Diag Pack (Y/N)? :
SQL_ID PHV OWNER TABLE_NAME INDEX_NAME PP PSTART PSTOP NUM_ROWS BLOCKS LAST_ANALYZED STL
------------- ------------ ------ ----------------- ------------ ------- ------ ------ --------- ------- ------------------- ---
0urxa3bh3g3y4 1114365703 SYS FIXED_OBJ$ 928 3 2016-04-20 20:00:19 NO
1114365703 SYS INDCOMPART$ 37 7 2015-05-02 00:10:39 NO
1114365703 SYS INDPART$ 24,890 696 2017-12-30 04:18:25 NO
1114365703 SYS INDSUBPART$ 148 142 2015-05-01 20:06:58 NO
1114365703 SYS MON_MODS_ALL$ 616 12 2018-01-17 00:09:53 NO
1114365703 SYS OBJ$ 108,056 1,405 2018-01-07 16:26:30 NO
1114365703 SYS PARTOBJ$ 218 3 2018-01-14 16:16:50 NO
1114365703 SYS TAB$ I_TAB1 139 1 2018-01-17 00:09:53 NO
1114365703 SYS TABCOMPART$ 84 7 2015-10-22 00:07:23 NO
1114365703 SYS TABPART$ 5,491 152 2018-01-07 16:26:00 NO
1114365703 SYS TABSUBPART$ 912 184 2015-10-22 00:07:20 NO
1114365703 SYS TAB_STATS$ 509 4 2016-11-22 20:00:14 NO
1114365703 SYS WRH$_SQL_PLAN 34,084 9,077 2018-01-16 20:01:22 NO
13 rows selected.
Database stats based on objects found in v$sql_plan and dba_hist_sql_plan
JKSTILL@oravm > @stats-sqlid 0urxa3bh3g3y4 Y
SQL_ID? :
Diag Pack (Y/N)? :
SQL_ID PHV OWNER TABLE_NAME INDEX_NAME PP PSTART PSTOP NUM_ROWS BLOCKS LAST_ANALYZED STL
------------- ------------ ------ --------------- ----------- ------- ------ ------ --------- ------- ------------------- ---
0urxa3bh3g3y4 1114365703 SYS FIXED_OBJ$ 928 3 2016-04-20 20:00:19 NO
1114365703 SYS INDCOMPART$ 37 7 2015-05-02 00:10:39 NO
1114365703 SYS INDPART$ 24,890 696 2017-12-30 04:18:25 NO
1114365703 SYS INDSUBPART$ 148 142 2015-05-01 20:06:58 NO
1114365703 SYS MON_MODS_ALL$ 616 12 2018-01-17 00:09:53 NO
1114365703 SYS OBJ$ 108,056 1,405 2018-01-07 16:26:30 NO
1114365703 SYS PARTOBJ$ 218 3 2018-01-14 16:16:50 NO
1114365703 SYS TAB$ I_TAB1 139 1 2018-01-17 00:09:53 NO
1114365703 SYS TABCOMPART$ 84 7 2015-10-22 00:07:23 NO
1114365703 SYS TABPART$ 5,491 152 2018-01-07 16:26:00 NO
1114365703 SYS TABSUBPART$ 912 184 2015-10-22 00:07:20 NO
1114365703 SYS TAB_STATS$ 509 4 2016-11-22 20:00:14 NO
1114365703 SYS WRH$_SQL_PLAN 34,084 9,077 2018-01-16 20:01:22 NO
13 rows selected.
Using this script greatly simplifies this aspect of SQL optimization, that is, determining if the statistics are up to date before continuing work on the SQL tuning effort.
On this page
Share this
Share this
More resources
Learn more about Pythian by reading the following blogs and articles.
Statspack vs. AWR: Wrong number of SQL Executions

Statspack vs. AWR: Wrong number of SQL Executions
Oct 27, 2021 12:00:00 AM
9
min read
DML by Unique Index Supposedly Affecting Many Rows
DML by Unique Index Supposedly Affecting Many Rows
Mar 16, 2021 12:00:00 AM
6
min read
How To Improve SQL Statements Performance: Using SQL Plan Baselines
How To Improve SQL Statements Performance: Using SQL Plan Baselines
Feb 3, 2014 12:00:00 AM
6
min read
Ready to unlock value from your data?
With Pythian, you can accomplish your data transformation goals and more.