-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathcbo_last_analyzed_stats.sql
80 lines (74 loc) · 1.5 KB
/
cbo_last_analyzed_stats.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
column counted format 9G999G999G999
accept OWNER prompt 'Owner Name: '
break on report on stattype_locked skip 2 on last_analyzed_day skip 1
compute sum of counted on last_analyzed_day
compute sum of counted on stattype_locked
compute sum of counted on report
select
stattype_locked,
trunc(last_analyzed) last_analyzed_day,
object_type,
count(*) counted
from
( select
object_type,
last_analyzed,
stattype_locked
from
dba_tab_statistics
where
owner = '&OWNER'
and table_name not in
( select
table_name
from
dba_external_tables
where
owner = '&OWNER'
union all
select
table_name
from
dba_tables
where
temporary = 'Y'
and owner = '&OWNER'
)
union all
select
object_type,
last_analyzed,
stattype_locked
from
dba_ind_statistics
where
owner = '&OWNER'
and table_name not in
( select
table_name
from
dba_external_tables
where
owner = '&OWNER'
union all
select
table_name
from
dba_tables
where
temporary = 'Y'
and owner = '&OWNER'
)
)
group by
stattype_locked,
trunc(last_analyzed),
object_type
order by
stattype_locked,
last_analyzed_day,
object_type
;
clear breaks
clear computes
undef OWNER