-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtemptblinstances.sql
47 lines (44 loc) · 1.3 KB
/
temptblinstances.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
REM temptblinstances.sql
REM (c)David Kurtz, Go-Faster Consultancy Ltd. 2009
REM https://blog.psftdba.com/2009/01/managing-changes-to-number-of-instances.html
ttitle 'Missing Instances of Temporary Tables'
SELECT r.recname
, n.n instance
, c.temptblinstances
+o.temptblinstances temptblinstances
FROM pstemptblcntvw c
, psrecdefn r
, (SELECT rownum-1 n FROM psrecdefn
WHERE rownum <= 100) n
, psoptions o
WHERE r.recname = c.recname
AND n.n <= c.temptblinstances+o.temptblinstances
AND NOT EXISTS(
SELECT 'x'
FROM user_tables t
WHERE t.table_name =
DECODE(r.sqltablename, ' ', 'PS_'||r.recname,
r.sqltablename) ||DECODE(n.n,0,'',n.n)
)
ORDER BY 1,2
/
ttitle 'Excess Instances of Temporary Tables'
SELECT r.recname
, n.n instance
, c.temptblinstances
+o.temptblinstances temptblinstances
, t.table_name
FROM pstemptblcntvw c
, psrecdefn r
, (SELECT rownum-1 n FROM psrecfield
WHERE rownum <= 100) n
, user_tables t
, psoptions o
WHERE r.recname = c.recname
AND t.table_name =
DECODE(r.sqltablename, ' ', 'PS_'||r.recname,
r.sqltablename) ||DECODE(n.n,0,'',n.n)
AND n.n > c.temptblinstances+o.temptblinstances
ORDER BY 1,2
/
ttitle off