프린트 하기

OS 환경 : Oracle Linux 8.7 (64bit)

 

DB 환경 : Oracle Database 19.27.0.0

 

방법 : 오라클 19c utlrp 시 수행되는 job

utlrp는 invalid 오브젝트를 컴파일해주는 오라클 스크립트임
utlrp를 수행해봤다면 수행시 나오는 아래 쿼리를 본적이 있을것임
본문에서는 dba_scheduler_jobs나 dba_scheduler_running_jobs 내용을 확인해보고
이 부분이 무슨 역할을 하는지 확인해봄

 

 

utlrp 수행

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
81
82
83
84
85
86
87
SQL> @?/rdbms/admin/utlrp.sql
 
Session altered.
 
 
TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP UTLRP_BGN              2025-10-18 09:51:48
 
DOC>   The following PL/SQL block invokes UTL_RECOMP to recompile invalid
DOC>   objects in the database. Recompilation time is proportional to the
DOC>   number of invalid objects in the database, so this command may take
DOC>   a long time to execute on a database with a large number of invalid
DOC>   objects.
DOC>
DOC>   Use the following queries to track recompilation progress:
DOC>
DOC>   1. Query returning the number of invalid objects remaining. This
DOC>      number should decrease with time.
DOC>         SELECT COUNT(*) FROM obj$ WHERE status IN (4, 5, 6);
DOC>
DOC>   2. Query returning the number of objects compiled so far. This number
DOC>      should increase with time.
DOC>         SELECT COUNT(*) FROM UTL_RECOMP_COMPILED;
DOC>
DOC>   This script automatically chooses serial or parallel recompilation
DOC>   based on the number of CPUs available (parameter cpu_count) multiplied
DOC>   by the number of threads per CPU (parameter parallel_threads_per_cpu).
DOC>   On RAC, this number is added across all RAC nodes.
DOC>
DOC>   UTL_RECOMP uses DBMS_SCHEDULER to create jobs for parallel
DOC>   recompilation. Jobs are created without instance affinity so that they
DOC>   can migrate across RAC nodes. Use the following queries to verify
DOC>   whether UTL_RECOMP jobs are being created and run correctly:
DOC>
DOC>   1. Query showing jobs created by UTL_RECOMP
DOC>         SELECT job_name FROM dba_scheduler_jobs
DOC>            WHERE job_name like 'UTL_RECOMP_SLAVE_%';
DOC>
DOC>   2. Query showing UTL_RECOMP jobs that are running
DOC>         SELECT job_name FROM dba_scheduler_running_jobs
DOC>            WHERE job_name like 'UTL_RECOMP_SLAVE_%';
DOC>#
 
PL/SQL procedure successfully completed.
 
 
TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP UTLRP_END              2025-10-18 09:55:57
 
DOC> The following query reports the number of invalid objects.
DOC>
DOC> If the number is higher than expected, please examine the error
DOC> messages reported with each object (using SHOW ERRORS) to see if they
DOC> point to system misconfiguration or resource constraints that must be
DOC> fixed before attempting to recompile these objects.
DOC>#
 
OBJECTS WITH ERRORS
-------------------
                  0
 
DOC> The following query reports the number of exceptions caught during
DOC> recompilation. If this number is non-zero, please query the error
DOC> messages in the table UTL_RECOMP_ERRORS to see if any of these errors
DOC> are due to misconfiguration or resource constraints that must be
DOC> fixed before objects can compile successfully.
DOC> Note: Typical compilation errors (due to coding errors) are not
DOC>       logged into this table: they go into DBA_ERRORS instead.
DOC>#
 
ERRORS DURING RECOMPILATION
---------------------------
                          0
 
 
Function created.
 
 
PL/SQL procedure successfully completed.
 
 
Function dropped.
 
 
PL/SQL procedure successfully completed.

 

 

utlrp 수행시 위 쿼리를 수행해보면 아래와 같이 표시됨

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
SQL> SELECT job_name FROM dba_scheduler_jobs
     WHERE job_name like 'UTL_RECOMP_SLAVE_%';
 
JOB_NAME
------------------------------
UTL_RECOMP_SLAVE_2
UTL_RECOMP_SLAVE_3
UTL_RECOMP_SLAVE_4
 
SQL> SELECT job_name FROM dba_scheduler_running_jobs
     WHERE job_name like 'UTL_RECOMP_SLAVE_%';
 
JOB_NAME
------------------------------
UTL_RECOMP_SLAVE_2
UTL_RECOMP_SLAVE_3
UTL_RECOMP_SLAVE_4

utlrp가 invalid 오브젝트를 컴파일해주는 작업인데
하나의 세션에서 하는것이 아니라 job을 생성해서 여러 세션에서 컴파일을 하는것임

 

 

실제로 컴파일된 항목을 조회해보면 갈수록 늘어나고 있음

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
SQL> SELECT COUNT(*) FROM UTL_RECOMP_COMPILED;
 
COUNT(*)
-----------
1480
 
SQL> /
COUNT(*)
-----------
1500
 
SQL> /
COUNT(*)
-----------
1536
..

 

 

반대로 invalid 오브젝트를 뜻하는 status 4, 5, 6은 갈수록 줄고 있음

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
SQL> SELECT COUNT(*) FROM obj$ WHERE status IN (4, 5, 6);
 
COUNT(*)
-----------
412
 
SQL> /
COUNT(*)
-----------
406
 
SQL> /
COUNT(*)
-----------
386
..

 

 

참고로 이렇게 병렬 컴파일을 job을 만들어서 수행하기때문에
job_queue_process를 0으로 변경했을때 utlrp를 수행하게되면
직렬(단일세션)으로 컴파일을 해서 기존보다 느릴 수 있음
그리고 utlrp에 나오는 영어를 잘 읽어보면 이런내용을 이미 설명하고 있음

Doc
This script automatically chooses serial or parallel recompilation
based on the number of CPUs available (parameter cpu_count) multiplied
by the number of threads per CPU (parameter parallel_threads_per_cpu).
On RAC, this number is added across all RAC nodes.

UTL_RECOMP uses DBMS_SCHEDULER to create jobs for parallel
recompilation. Jobs are created without instance affinity so that they
can migrate across RAC nodes. Use the following queries to verify
whether UTL_RECOMP jobs are being created and run correctly:
번역
이 스크립트는 사용 가능한 CPU 수(cpu_count 파라미터)에 각 CPU당 스레드 수(parallel_threads_per_cpu 파라미터)를
곱한 값을 기준으로 직렬 또는 병렬 재컴파일을 자동으로 선택합니다. RAC 환경에서는 이 값이 모든 RAC 노드를 기준으로 합산됩니다.

UTL_RECOMP은 병렬 재컴파일을 위해 DBMS_SCHEDULER를 사용해 작업(job)을 생성합니다.
작업은 특정 인스턴스에 고정되지 않고 생성되므로 RAC 노드 간에 이동할 수 있습니다.
UTL_RECOMP 작업이 제대로 생성되고 실행되는지 확인하려면 아래의 쿼리를 사용할 수 있습니다.

 

 

결론 :
utlrp는 invalid 오브젝트를 컴파일해주는 오라클 스크립트임
utlrp 수행시 job_queue_process가 0이 아닌 경우 여러개의 slave job을 만들어서 compile을 나눠서 수행함
하지만 job_queue_process가 0인 경우 slave를 못만들기 때문에 전자의 경우보다 느리게 compile이 완료될 수 있음(안되진 않고 느릴뿐임)
그리고 utlrp 수행시 나오는 쿼리를 조회해서 얼마나 compile 되었는지, 남은 invalid 오브젝트가 몇개인지 확인 가능함

 

 

참조 : 

https://docs.oracle.com/en/database/oracle/oracle-database/19/refrn/JOB_QUEUE_PROCESSES.html