Wednesday, May 11, 2022
Tables used for sqlid and its stats
SELECT a.object_owner,
a.object_name,
a.object_type,
b.stale_stats
FROM v$sql_plan a
JOIN dba_tab_statistics b
ON a.object_owner = b.owner AND a.object_name = b.TABLE_NAME
WHERE b.object_type = 'TABLE'
AND a.sql_id = TRIM ('&1')
AND (stale_stats IS NULL OR stale_stats = 'YES')
UNION ALL
SELECT a.object_owner,
a.object_name,
a.object_type,
b.stale_stats
FROM v$sql_plan a
JOIN dba_tab_statistics b
ON a.object_owner = b.owner AND a.object_name = b.PARTITION_NAME
WHERE b.object_type = 'PARTITION'
AND a.sql_id = TRIM ('&1')
AND (stale_stats IS NULL OR stale_stats = 'YES')
UNION ALL
SELECT a.object_owner,
a.object_name,
b.object_type,
b.stale_stats
FROM v$sql_plan a
JOIN dba_ind_statistics b
ON a.object_owner = b.owner AND a.object_name = b.index_name
WHERE b.object_type!='SUBPARTITION' and a.sql_id = TRIM ('&1')
AND (stale_stats IS NULL OR stale_stats = 'YES');
Subscribe to:
Post Comments (Atom)
Plan SQL's
SELECT sql_id, plan_hash_value, executions, inst_id FROM gv$sql WHERE sql_id='bhwamkg4y2pxb'; SELECT ...
No comments:
Post a Comment