Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8779025

Browse files
committed
Moving away from full outer join.
Added static schema name rather than bind variable.
1 parent cb9cf97 commit 8779025

2 files changed

Lines changed: 55 additions & 70 deletions

File tree

source/core/annotations/ut_annotation_manager.pkb

Lines changed: 48 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -19,37 +19,37 @@ create or replace package body ut_annotation_manager as
1919
------------------------------
2020
--private definitions
2121

22-
-- function get_missing_objects(a_object_owner varchar2, a_object_type varchar2) return ut_annotation_objs_cache_info is
23-
-- l_rows sys_refcursor;
24-
-- l_ut_owner varchar2(250) := ut_utils.ut_owner;
25-
-- l_objects_view varchar2(200) := ut_metadata.get_dba_view('dba_objects');
26-
-- l_cursor_text varchar2(32767);
27-
-- l_result ut_annotation_objs_cache_info;
28-
-- begin
29-
-- l_cursor_text :=
30-
-- q'[select ]'||l_ut_owner||q'[.ut_annotation_obj_cache_info(
31-
-- object_owner => i.object_owner,
32-
-- object_name => i.object_name,
33-
-- object_type => i.object_type,
34-
-- needs_refresh => null
35-
-- )
36-
-- from ]'||l_ut_owner||q'[.ut_annotation_cache_info i
37-
-- where
38-
-- not exists (
39-
-- select 1 from ]'||l_objects_view||q'[ o
40-
-- where o.owner = i.object_owner
41-
-- and o.object_name = i.object_name
42-
-- and o.object_type = i.object_type
43-
-- and o.owner = :a_object_owner
44-
-- and o.object_type = :a_object_type
45-
-- )
46-
-- and i.object_owner = :a_object_owner
47-
-- and i.object_type = :a_object_type]';
48-
-- open l_rows for l_cursor_text using a_object_owner, a_object_type, a_object_owner, a_object_type;
49-
-- fetch l_rows bulk collect into l_result limit 1000000;
50-
-- close l_rows;
51-
-- return l_result;
52-
-- end;
22+
function get_missing_objects(a_object_owner varchar2, a_object_type varchar2) return ut_annotation_objs_cache_info is
23+
l_rows sys_refcursor;
24+
l_ut_owner varchar2(250) := ut_utils.ut_owner;
25+
l_objects_view varchar2(200) := ut_metadata.get_dba_view('dba_objects');
26+
l_cursor_text varchar2(32767);
27+
l_result ut_annotation_objs_cache_info;
28+
begin
29+
l_cursor_text :=
30+
q'[select ]'||l_ut_owner||q'[.ut_annotation_obj_cache_info(
31+
object_owner => i.object_owner,
32+
object_name => i.object_name,
33+
object_type => i.object_type,
34+
needs_refresh => null
35+
)
36+
from ]'||l_ut_owner||q'[.ut_annotation_cache_info i
37+
where
38+
not exists (
39+
select 1 from ]'||l_objects_view||q'[ o
40+
where o.owner = i.object_owner
41+
and o.object_name = i.object_name
42+
and o.object_type = i.object_type
43+
and o.owner = :a_object_owner
44+
and o.object_type = :a_object_type
45+
)
46+
and i.object_owner = :a_object_owner
47+
and i.object_type = :a_object_type]';
48+
open l_rows for l_cursor_text using a_object_owner, a_object_type, a_object_owner, a_object_type;
49+
fetch l_rows bulk collect into l_result limit 1000000;
50+
close l_rows;
51+
return l_result;
52+
end;
5353

5454
function get_annotation_objs_info(a_object_owner varchar2, a_object_type varchar2, a_parse_date timestamp := null) return ut_annotation_objs_cache_info is
5555
l_rows sys_refcursor;
@@ -60,36 +60,25 @@ create or replace package body ut_annotation_manager as
6060
begin
6161
l_cursor_text :=
6262
q'[select ]'||l_ut_owner||q'[.ut_annotation_obj_cache_info(
63-
object_owner => nvl( o.owner, i.object_owner ),
64-
object_name => nvl( o.object_name, i.object_name ),
65-
object_type => nvl( o.object_type, i.object_type ),
66-
needs_refresh =>
67-
case
68-
when o.last_ddl_time < cast(i.parse_time as date) then 'N'
69-
when o.owner is null then null
70-
else 'Y'
71-
end
63+
object_owner => o.owner,
64+
object_name => o.object_name,
65+
object_type => o.object_type,
66+
needs_refresh => case when o.last_ddl_time < cast(i.parse_time as date) then 'N' else 'Y' end
7267
)
73-
from (
74-
select * from ]'||l_objects_view||q'[ o
75-
where o.owner = :a_object_owner
76-
and o.object_type = :a_object_type
77-
) o
78-
full outer join (
79-
select * from ]'||l_ut_owner||q'[.ut_annotation_cache_info i
80-
where i.object_owner = :a_object_owner
81-
and i.object_type = :a_object_type
82-
) i
68+
from ]'||l_objects_view||q'[ o
69+
left join ]'||l_ut_owner||q'[.ut_annotation_cache_info i
8370
on o.owner = i.object_owner
8471
and o.object_name = i.object_name
8572
and o.object_type = i.object_type
86-
where ]'
87-
|| case
73+
where o.owner = ']'||a_object_owner||q'['
74+
and o.object_type = ']'||a_object_type||q'['
75+
and ]'
76+
|| case
8877
when a_parse_date is null
89-
then ':a_parse_date is null'
90-
else 'o.last_ddl_time >= cast(:a_parse_date as date) or o.last_ddl_time is null'
91-
end;
92-
open l_rows for l_cursor_text using a_object_owner, a_object_type, a_object_owner, a_object_type, a_parse_date;
78+
then ':a_parse_date is null'
79+
else 'o.last_ddl_time >= cast(:a_parse_date as date)'
80+
end;
81+
open l_rows for l_cursor_text using a_parse_date;
9382
fetch l_rows bulk collect into l_result limit 1000000;
9483
close l_rows;
9584
return l_result;
@@ -197,7 +186,6 @@ create or replace package body ut_annotation_manager as
197186
a_info_rows ut_annotation_objs_cache_info
198187
) is
199188
l_objects_to_parse ut_annotation_objs_cache_info;
200-
l_objects_to_remove ut_annotation_objs_cache_info;
201189
begin
202190
select value(x)bulk collect into l_objects_to_parse
203191
from table(a_info_rows) x where x.needs_refresh = 'Y';
@@ -208,13 +196,9 @@ create or replace package body ut_annotation_manager as
208196
or ut_metadata.is_object_visible('ut3.ut_utils')
209197
or ut_metadata.is_object_visible('dba_objects')
210198
then
211-
select value(x)bulk collect into l_objects_to_remove
212-
from table(a_info_rows) x where x.needs_refresh is null;
213-
214-
ut_annotation_cache_manager.remove_from_cache(l_objects_to_remove);
215-
-- ut_annotation_cache_manager.remove_from_cache(
216-
-- get_missing_objects(a_object_owner, a_object_type)
217-
-- );
199+
ut_annotation_cache_manager.remove_from_cache(
200+
get_missing_objects(a_object_owner, a_object_type)
201+
);
218202
end if;
219203

220204
--if some source needs parsing and putting into cache

source/core/ut_suite_builder.pkb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,10 +1020,10 @@ create or replace package body ut_suite_builder is
10201020
where o.owner = i.object_owner
10211021
and o.object_name = i.object_name
10221022
and o.object_type = 'PACKAGE'
1023-
and o.owner = :a_object_owner
1023+
and o.owner = ']'||a_object_owner||q'['
10241024
)
1025-
and i.object_owner = :a_object_owner]';
1026-
open l_rows for l_cursor_text using a_object_owner, a_object_owner;
1025+
and i.object_owner = ']'||a_object_owner||q'[']';
1026+
open l_rows for l_cursor_text;
10271027
fetch l_rows bulk collect into l_result limit 1000000;
10281028
close l_rows;
10291029
return l_result;
@@ -1061,10 +1061,11 @@ create or replace package body ut_suite_builder is
10611061
( select 1
10621062
from all_objects a
10631063
where a.object_name = c.object_name
1064+
and a.object_owner = ']'||upper(a_object_owner)||q'['
10641065
and a.owner = c.object_owner
10651066
and a.object_type = 'PACKAGE'
10661067
)]' end ||q'[
1067-
and c.object_owner = :a_object_owner
1068+
and c.object_owner = ']'||upper(a_object_owner)||q'['
10681069
and ( ]' || case when l_path is not null then q'[
10691070
:l_path||'.' like c.path || '.%' /*all children and self*/
10701071
or ( c.path||'.' like :l_path || '.%' --all parents
@@ -1134,7 +1135,7 @@ create or replace package body ut_suite_builder is
11341135
end, '.', chr(0)) desc nulls last,
11351136
c.object_name desc,
11361137
c.line_no]'
1137-
using upper(a_object_owner), l_path, l_path, upper(a_object_name), upper(a_procedure_name);
1138+
using l_path, l_path, upper(a_object_name), upper(a_procedure_name);
11381139

11391140
return l_result;
11401141
end;
@@ -1238,7 +1239,7 @@ create or replace package body ut_suite_builder is
12381239
then
12391240
l_need_all_objects_scan := false;
12401241
end if;
1241-
1242+
12421243
execute immediate 'select c.object_owner, c.object_name
12431244
from '||l_ut_owner||q'[.ut_suite_cache_package c
12441245
join table ( :a_schema_names ) s

0 commit comments

Comments
 (0)