Skip to content

Commit 3a21697

Browse files
committed
Merge branch 'oramain' into '3.2.0'
Oramain to 3.2.0 See merge request rwp/rwloadsim!37
2 parents 54b05ae + 5b6ebc3 commit 3a21697

File tree

11 files changed

+338
-42
lines changed

11 files changed

+338
-42
lines changed

bin/sqlexplain

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
3+
# RWP*Load Simulator
4+
#
5+
# Copyright (c) 2024 Oracle Corporation
6+
# Licensed under the Universal Permissive License v 1.0
7+
# as shown at https://oss.oracle.com/licenses/upl/
8+
#
9+
# call rwloadsim -u sqlreport.rwl
10+
11+
# bengsig 6-dec-2024 - Created
12+
13+
exec rwloadsim --pretend-gen-banner='RWP*SQL Explain' -u sqlexplain.rwl "$@"

docs/refman/Makefile.refman

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
ALL1=atclause.html bengsig.html compoundstatement.html conditional.html controlloop.html database.html databasedeclaration.html databasestatement.html declaration.html directive.html double.html expression.html filestatement.html histogram.html identifier.html include.html integer.html lob.html lobdeclaration.html multiprocess.html oerstats.html percentiles.html persec.html proceduredeclaration.html randomproceduredeclaration.html randomstringdeclaration.html regex.html runres.html rwlcpu.html rwlman.html rwloadsim.html rwlprogram.html rwlrun.html simpledeclaration.html sqldeclaration.html sqlexecution.html sqlstatement.html statement.html statistics.html string.html sysres.html threadexecution.html useroption.html rwlerror.html random.html procedure.html printfstatement.html cqnthread.html clob.html concatenation.html constant.html cursor.html cursorloop.html directives.html executionblock.html file.html forloop.html fractiles.html function.html functiondeclaration.html histogram_a.html if.html ifstatement.html longoption.html loop.html persec_a.html printline.html readline.html readlob.html readloop.html regexextract.html regexsearch.html regexsubstitute.html run.html runres_a.html rwl.html rwlcpu_a.html scalardeclaration.html sql.html statementlist.html thread.html threads.html userswitch.html variable.html while.html writeline.html writelob.html userhelp.html
2323

24-
ALL2=ashplot.html awrreport.html awreport.html awrdump.html connping.html nettest.html oltp.html oltpcheckkey.html oltpcore.html oltpcreate.html oltpday.html oltpping.html oltpdrop.html oltpfilloe.html oltpforever.html oltpparams.html oltpplot.html oltprun.html oltpscale.html oltpscalereport.html oltpverify.html ovid2.html sqlid2file.html sqlmonitor.html sqlmonitorawr.html ociping.html oltpsetup.html oltpawcols.html oltpplus.html oltpconnect.html utilities.html sqlreport.html netthroughput.html oltpxcset.html oltpxcrun.html oltpxc.html oltpdirectory.html oltpkomment.html ashdata.html rwlash.html filecommands.html
24+
ALL2=ashplot.html awrreport.html awreport.html awrdump.html connping.html nettest.html oltp.html oltpcheckkey.html oltpcore.html oltpcreate.html oltpday.html oltpping.html oltpdrop.html oltpfilloe.html oltpforever.html oltpparams.html oltpplot.html oltprun.html oltpscale.html oltpscalereport.html oltpverify.html ovid2.html sqlid2file.html sqlexplain.html sqlmonitor.html sqlmonitorawr.html ociping.html oltpsetup.html oltpawcols.html oltpplus.html oltpconnect.html utilities.html sqlreport.html netthroughput.html oltpxcset.html oltpxcrun.html oltpxc.html oltpdirectory.html oltpkomment.html ashdata.html rwlash.html filecommands.html
2525

2626
all: $(ALL1) $(ALL2)
2727

@@ -145,6 +145,7 @@ oltpverify.html: ../../man/man2rwl/oltpverify.2rwl
145145
ovid2.html: ../../man/man2rwl/ovid2.2rwl
146146
sqlid2file.html: ../../man/man2rwl/sqlid2file.2rwl
147147
sqlreport.html: ../../man/man2rwl/sqlreport.2rwl
148+
sqlexplain.html: ../../man/man2rwl/sqlexplain.2rwl
148149
sqlmonitor.html: ../../man/man2rwl/sqlmonitor.2rwl
149150
sqlmonitorawr.html: ../../man/man2rwl/sqlmonitorawr.2rwl
150151
rwlash.html: ../../man/man2rwl/rwlash.2rwl

docs/refman/sqlexplain.html

Lines changed: 143 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/refman/sqlmonitor.html

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/refman/sqlreport.html

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/man2rwl/sqlexplain.2rwl

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
.TH sqlexplain "2rwl" "December 2024" "RWP*Load Simulator" "Utilities Syntax"
2+
.SH NAME
3+
sqlexplain \- Create an explain plan
4+
.SH SYNOPSIS
5+
\fBsqlexplain [options] -l u/p@c sqlid \fR
6+
.P
7+
For the provided sqlid, the sqlexplain utility will write an explain plan
8+
to stdout
9+
calling dbms_xplan.display_cursor or dbms_xplan.display_awr
10+
.P
11+
.SH OPTIONS
12+
.B -l u/p
13+
.P
14+
.B -l u/p@c
15+
.RS 4
16+
Compulsory option to provide the username, password, and potentially
17+
connect string for a database connection that provides access to
18+
a login with access to various gv$ and dba_ views.
19+
If you omit /p, rwloadsim will prompt for the password.
20+
.RE
21+
.P
22+
.B --awr
23+
.RS 4
24+
Use the display_awr function rather then the display_cursor function from the dbms_xplan package.
25+
.RE
26+
.P
27+
.B --format=' text string '
28+
.RS 4
29+
Provide the format argument; the default is 'last, all, allstats'.
30+
.RE
31+
.P
32+
.B --child-no=child#
33+
.RS 4
34+
When using the display_cursor function, provide this cursor_child_no, the default is 0.
35+
.RE
36+
.P
37+
.B --sessionid=sid
38+
.br
39+
.B --instance=inst#
40+
.RS 4
41+
Rather than providing the sqlid as a command line argument, get it by querying
42+
v$session for the provided sessionid
43+
or gv$session for the provided sessionid and instance number.
44+
.RE
45+
.P
46+
\fBsqlid\fR
47+
.RS 4
48+
.P
49+
Unless --sessionid is specified, exactly one sqlid must be given as a command line argument.
50+
.RE
51+
.SH EXAMPLE
52+
.nf
53+
\fC
54+
sqlexplain -l system/{password} 07rw9znc8g7aj
55+
\fR
56+
.fi
57+
.P
58+
will print the output of running the query
59+
select * from table(dbms_xplan.display_cursor('07rw9znc8g7aj',0,'last, all, allstats'))
60+
to stdout
61+
.SH COPYRIGHT
62+
Copyright \(co 2024 Oracle Corporation
63+
.br
64+
Licensed under the Universal Permissive License v 1.0
65+
as shown at https://oss.oracle.com/licenses/upl
66+
.SH "SEE ALSO"
67+
rwloadsim(1rwl), sqlreport(2rwl), sqlmonitor(2rwl) sqlmonitorawr(2rwl), utilities(2rwl)

man/man2rwl/sqlmonitor.2rwl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,4 @@ Copyright \(co 2023 Oracle Corporation
8080
Licensed under the Universal Permissive License v 1.0
8181
as shown at https://oss.oracle.com/licenses/upl
8282
.SH "SEE ALSO"
83-
rwloadsim(1rwl), sqlreport(2rwl), sqlmonitorawr(2rwl), utilities(2rwl)
83+
rwloadsim(1rwl), sqlreport(2rwl), sqlmonitorawr(2rwl), sqlexplain(2rwl), utilities(2rwl)

man/man2rwl/sqlreport.2rwl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ Copyright \(co 2023 Oracle Corporation
5858
Licensed under the Universal Permissive License v 1.0
5959
as shown at https://oss.oracle.com/licenses/upl
6060
.SH "SEE ALSO"
61-
rwloadsim(1rwl), sqlmonitor(2rwl) sqlmonitorawr(2rwl), utilities(2rwl)
61+
rwloadsim(1rwl), sqlmonitor(2rwl) sqlmonitorawr(2rwl), sqlexplain(2rwl), utilities(2rwl)

public/sqlexplain.rwl

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# sqlexplain.rwl
2+
#
3+
# Copyright (c) 2024 Oracle Corporation
4+
# Licensed under the Universal Permissive License v 1.0
5+
# as shown at https://oss.oracle.com/licenses/upl/
6+
#
7+
# History
8+
#
9+
# bengsig 5-dec-2024 - Creation
10+
#
11+
# usage:
12+
#
13+
# rwloadsim -ul system/{password}@//host/database sqlexplain.rwl sqlid
14+
#
15+
$alwaysmute:206
16+
17+
# If we didn't connect, don't do anything
18+
$if not defined(default database) $then
19+
writeline stderr, "Missing or incorrect -l option; use -h to get help";
20+
exit 1;
21+
$endif
22+
23+
$longoption:file-count=1
24+
25+
integer sessionid, instance;
26+
integer awr := 0, child_no := 0;
27+
string format := "last, all, allstats";
28+
29+
$userhelp:"Create a sql explain plan by calling dbms_xplan.display_cursor"
30+
$userhelp:"-l usr/pwd@con : required option to give database logon"
31+
$userhelp:"sqlid : if provided, use that sqlid"
32+
$useroption:child-no:"--child-no=child# : provide cursor_child_no, default 0"
33+
$useroption:format:"--format='format text' : provide format, default 'last, all, allstats'"
34+
$useroption:sessionid:"--sesssionid=sid : query v$session for the sqlid"
35+
$useroption:instance:"--instance=inst# : query gv$session"
36+
$userswitch:awr:"--awr : use display_awr in stead of display_cursor"
37+
38+
$oraerror:stop
39+
40+
string(13) sqlid;
41+
42+
if $# = 1 then
43+
sqlid := $1;
44+
elseif instance is null and sessionid is not null then
45+
select nvl(sql_id,prev_sql_id) sqlid
46+
from v$session where sid=:sessionid
47+
/
48+
elseif instance is not null and sessionid is not null then
49+
select nvl(sql_id,prev_sql_id) sqlid
50+
from gv$session where sid=:sessionid
51+
and inst_id = :instance
52+
/
53+
end if;
54+
55+
if sqlid = "" then
56+
writeline stderr, "\nusage: sqlexplain [--help] [options] -l system/{password}@//host/database sqlid";
57+
exit 1;
58+
end if;
59+
60+
string(10000) plan_table_output;
61+
62+
if awr then
63+
for
64+
select * from
65+
table(dbms_xplan.display_awr(sql_id=>:sqlid,format=>:format))
66+
/
67+
loop
68+
printline plan_table_output;
69+
end loop;
70+
else
71+
for
72+
select * from
73+
table(dbms_xplan.display_cursor(sql_id=>:sqlid,cursor_child_no=>:child_no,format=>:format))
74+
/
75+
loop
76+
printline plan_table_output;
77+
end loop;
78+
end if;
79+

0 commit comments

Comments
 (0)