-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple_dml_comparison.sql
More file actions
91 lines (71 loc) · 1.98 KB
/
simple_dml_comparison.sql
File metadata and controls
91 lines (71 loc) · 1.98 KB
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
88
89
90
91
set feed off
set term on
-- Prepare Test
create table test_table(col1 varchar2(100))
/
-- Create template PL/SQL implementation
create or replace procedure simple_select_performance as
l_test test_table.col1%type;
begin
insert into test_table(col1)
values('Test');
select col1
into l_test
from test_table fetch first 1 rows only;
update test_table
set col1 = 'Updated Test';
delete from test_table;
end simple_select_performance;
/
-- Create JavaScript module, implementing the same functionality
create or replace mle module simple_select_performance_module
language javascript AS
function simple_select_performance_js() {
let connection;
connection = oracledb.defaultConnection();
let result = connection.execute(`
insert into test_table(col1)
values('Test')`
);
result = connection.execute(`
select col1
from test_table fetch first 1 rows only`
);
result = connection.execute(`
update test_table
set col1 = 'Updated Test'`
);
result = connection.execute(`
delete from test_table`
);
}
export { simple_select_performance_js };
/
-- Create PL/SQL wrapper to call JavaScript
create or replace procedure simple_select_performance_js
as mle module simple_select_performance_module
signature 'simple_select_performance_js';
/
set serverout on
prompt Test Results:
-- Run test
declare
l_start_time timestamp;
begin
l_start_time := systimestamp;
simple_select_performance;
dbms_output.put_line(
'PL/SQL took ' || extract( second from (systimestamp - l_start_time) ) || ' seconds'
);
l_start_time := systimestamp;
simple_select_performance_js;
dbms_output.put_line(
'JavaScript took ' || extract( second from (systimestamp - l_start_time) ) || ' seconds'
);
end;
/
-- Cleanup
drop procedure simple_select_performance;
drop procedure simple_select_performance_js;
drop mle module simple_select_performance_module;
drop table test_table;