SQL Plus Script Execution Time
Anyone,
Is there an easy way to start a timer inside a SQL Plus script that shows exact run time at end of script completion?
Right now I use the TIME option and have a time as the prompt start and then one at end but would like if the SQL Plus script could simply put a begin/end/run time for me as last output. TIMING is to much since I have many things execute and do not wnat to see every individual runtime.
Thanks in advance,
Miller
http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14357/ch12047.htm#i2699704
You can use TIMING with a named timer
SQL> timing start script_time
SQL> select 1 from dual;
1
1
SQL> /
1
1
SQL> /
1
1
SQL> timing stop
timing for: script_time
Elapsed: 00:00:07.37
SQL>
Similar Messages
-
SQL*Plus script with a dynamic SPOOL File Location?
Anyone,
I have a numbr of SQL Plus scripts that I need to run many times but each run against a different database. Each script SPOOLS the output like this:
spool c:\temp\BUILD_ASSET.lis
spool c:\temp\BUILD_WORKORDER.lis
etc
(each spool is a seperate script run)
The spool is at the top of each BUILD SQL Script.
Example:
set time on
SET FEEDBACK ON
SET ECHO ON
SET TIMING ON
spool c:\temp\BUILD_ASSET.lisBut I need each run to go into its own directory based on the database I am connected to. Like this:
CONNECT DB1
@C:\temp\BUILD_ASSET.SQL =====> spool c:\temp\DB1\BUILD_ASSET.lis
@c:\temp\BUILD_WORKORDER.SQL =====> spool c:\temp\DB1\BUILD_WORKORDER.lis
etc
CONNECT DB2
@C:\temp\BUILD_ASSET.SQL =====> spool c:\temp\DB2\BUILD_ASSET.lis
@c:\temp\BUILD_WORKORDER.SQL =====> spool c:\temp\DB2\BUILD_WORKORDER.lisIs there a way to dynaically code this without having to create a version of the BUILD scripts for every single DB I connect to?
I would like to have one big script that executes all the individual BUILD scripts.
Seems very easy in concept but I can not see an easy way. I would appreciate any help I can get.
Thanks in advance,
Millercolumn db new_Value db
select sys_context('userenv','db_name') db from dual;
spool c:\temp\&db\file.lis -
How to detect client OS from SQL*Plus script
Sometimes in a SQL*Plus script I need to execute OS commands e.g.
host rm tempfile.bufHowever of course Windows has no "rm" command by default, so I have to edit the script to use
host del tempfile.bufNow if I could define &DELETE (for example, "cat"/"type" is another) as a substitution variable, I could just use
host &DELETE tempfile.bufMaybe I need more coffee but all I could come up with was something like this:
def rm=rm
def cat=cat
spool sqlplus_windows_defs.cmd
prompt echo def rm=del
prompt echo def cat=type
spool off
host .\sqlplus_windows_defs > sqlplus_windows_defs.sql
@sqlplus_windows_defs.sql
host &rm sqlplus_windows_defs.cmd
host &rm sqlplus_windows_defs.sqlthe idea being that you first define the variables for nix ("rm" and "cat"), then attempt to create and execute a Windows command file containing DOS versions ("dele" and "type"), which does not run under nix. Unfortunately the OS failure message (".sqlplus_windows_defs: not found" in Unix) appears on the screen despite SET TERM OFF, so I'm back where I started.
I know there are various ways to get the server OS, and you can get the SQL*Plus version with &_SQLPLUS_RELEASE and so on, but I can't see a way to determine the client OS. Any suggestions?Thanks guys. This seems to work in Windows XP - will try on Unix when I get a chance:
col DELETE_COMMAND new_value DELETE_COMMAND
col LIST_COMMAND new_value LIST_COMMAND
def list_command = TYPE
def delete_command = DEL
SELECT DECODE(os,'MSWIN','TYPE','cat') AS list_command
, DECODE(os,'MSWIN','DEL','rm') AS delete_command
FROM ( SELECT CASE WHEN UPPER(program) LIKE '%.EXE' THEN 'MSWIN' END AS os
FROM v$session
WHERE audsid = SYS_CONTEXT('userenv','sessionid') );
host &LIST_COMMAND xplan_errors.lst
host &DELETE_COMMAND xplan_errors.lstIf the user doesn't have access to v$session it will just default to the Windows commands.
http://www.williamrobertson.net/code/xplan.sql -
Execute SQL*PLUS script from VB6?
I'm using VB6 to connect to oracle 10 with oracle client 8i, I can establish the connection without any problems.
If I run a SQL statement from VB it works prefect, but when I try to run a SQL Plus script from VB I get error ORA-00900, "invalid SQL statement". Everything works fine in oracle SQLPLUS.
Is there anything I have missed about running SQL*PLUS script from VB6? Is'nt it the same as a SQL statement?Thanks for you answer Justin,
This is a short variant of SQL*Plus I wanna execute from VB and transfer the result into a listview in VB.
If this is possible from VB, can you show me how I should do?
COLUMN customer_1 NEW_VALUE customer_1 NOPRINT
COLUMN customer_2 NEW_VALUE customer_2 NOPRINT
SELECT customer customer_1
FROM (
SELECT customer,
ROW_NUMBER() OVER(PARTITION BY customer ORDER BY CustomerTotalSales DESC) CustomerTotalSalesRank
FROM (
SELECT customer,
SUM(SalesQty) OVER(PARTITION BY customer) CustomerTotalSales
FROM CustTable
WHERE year_month BETWEEN 200709 AND 200801
WHERE CustomerTotalSalesRank = 1
AND ROWNUM = 1
SELECT customer customer_2
FROM (
SELECT customer,
ROW_NUMBER() OVER(PARTITION BY customer ORDER BY CustomerTotalSales DESC) CustomerTotalSalesRank
FROM (
SELECT customer,
SUM(SalesQty) OVER(PARTITION BY customer) CustomerTotalSales
FROM CustTable
WHERE year_month BETWEEN 200709 AND 200801
WHERE CustomerTotalSalesRank = 2
AND ROWNUM = 1
SET VERIFY OFF
SELECT year_month,
SUM(
CASE CustomerTotalSalesRank
WHEN 1
THEN
SalesQty
ELSE
NULL;
END
) "&customer_1",
SUM(
CASE CustomerTotalSalesRank
WHEN 2
THEN
SalesQty
ELSE
NULL;
END
) "&customer_2"
FROM (
SELECT year_month,
SalesQty,
ROW_NUMBER() OVER(PARTITION BY customer ORDER BY CustomerTotalSales DESC) CustomerTotalSalesRank
FROM (
SELECT customer,
year_month,
SalesQty,
SUM(SalesQty) OVER(PARTITION BY customer) CustomerTotalSales
FROM CustTable
WHERE year_month BETWEEN 200709 AND 200801
WHERE CustomerTotalSalesRank <= 10
GROUP BY year_month
ORDER BY year_month
/ -
Semicolon and / in SQL Plus scripts?
Anyone,
Seem to have some confusion over the use of / and ; inside PL SQL Scripts run in SQL Plus.
I seem to get two commits thereby two rows on INSERT clase that has a ; and a /.
i.e.
/* Insert record into table for recording statistics on the runtime of this script */
INSERT INTO MYTABLE ( col1, col2) VALUES ( value1, value2);
COMMIT;
/The above will get two of the same rows in the table. Is this an issue with SQL Plus settings? What do people typically use? I have a combination of SQL and DDL in my scripts and I need / for the DDL typically as I understand. How do othere intermix these and what standard is used.Dave, here are the very basics.
The SQL language does not have command separators as only a single command at a time can be issued. Thus the following is invalid SQL:
SELECT * FROM emp;
The semicolon as command separator (or terminator) is not valid SQL. This is valid SQL:
SELECT * FROM emp
PL/SQL is a programming language similar to Pascal, C and Java. Multiple commands are used in a program. These need to be separated so that the parser/compiler can know where a command starts and where it ends. In PL/SQL the semicolon is used.
The following is invalid PL/SQL as it is missing command separators:
declare
i integer
begin
i := 1234
endThe following is valid PL/SQL :
declare
i integer;
begin
i := 1234;
end;SQL*Plus is an Oracle CLI (command line interface) client. It can submit both SQL and PL/SQL to the database. It needs to know when you have stopped entering commands into its input buffer and to submit what you've entered to the database.
SQL*Plus uses two characters for this. The semicolon and the forward slash. If you want to submit the above SELECT to Oracle using SQL*Plus, SQL*Plus needs to know when to submit its input buffer's content - thus:
SQL> SELECT * FROM emp;
Or:
SQL> SELECT * FROM emp
SQL> /
When using PL/SQL in SQL*Plus, SQL*Plus "understands" that the semicolons you use are for the PL/SQL language - not an instruction from you to it to submit its buffer to Oracle for execution.
The forward slash can also be at anytime used to resubmit the current SQL*Plus input buffer again. E.g.
SQL> SELECT * FROM emp;
.. now do the last SQL (or PL/SQL) in the buffer again
SQL> /[i] -
Connect via SQL*Plus taking more time in Oracle 11 than in 10
Oracle Version
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE 11.2.0.3.0 Production
TNS for IBM/AIX RISC System/6000: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Productioncurrently migrating from
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
TNS for IBM/AIX RISC System/6000: Version 10.2.0.4.0 - Productio
NLSRTL Version 10.2.0.4.0 - ProductionOS is AIX 5.3 for Oracle 10 and AIX 6.1 for Oracle 11.
We are currently in the process of migrating some applications from Oracle 10 to 11. Our admins have setup a new development system for us with an Oracle 11 instance. Regarding performance the new system behaves more or less the same than our old, e.g. when executing SQLs we notice hardly any performance differences and those we find are slightly in favour of the new system.
But now we discovered that the time it takes to establish a database connection via SQL*Plus is longer on the Oracle 11 system. Running the following code
sqlplus -s user/pw@database <<END
quit
ENDa thousand times takes ~60s under Oracle 10 but ~140s under Oracle 11. This may not seem much but we are running a test framework consisting of a bunch of shell scripts where several thousand connections are openend via SQL*Plus to execute some SQLs, so that even this small time difference results in rather huge difference in total runtime. The SQLs themself require roughly the same time in both databases, as already mentioned above they are in fact slightly faster in Oracle 11.
To analyze the time difference I ran a trace for the connect with the following parameters in sqlnet.ora
TRACE_LEVEL_CLIENT=4
TRACE_UNIQUE_CLIENT=ONand found out that there is a time difference of about 70ms during the connect handshake:
Oracle 10
[22-MAR-2013 12:13:09:595] nscon: doing connect handshake...
[22-MAR-2013 12:13:09:595] nscon: sending NSPTCN packet
[22-MAR-2013 12:13:09:621] nscon: got NSPTRS packet
[22-MAR-2013 12:13:09:621] nscon: sending NSPTCN packetOracle 11
(1) [22-MAR-2013 12:15:26:812] nscon: doing connect handshake...
(1) [22-MAR-2013 12:15:26:812] nscon: sending NSPTCN packet
(1) [22-MAR-2013 12:15:26:906] nscon: got NSPTRS packet
(1) [22-MAR-2013 12:15:26:906] nscon: sending NSPTCN packetUnder Oracle 10 there are 26ms between sending the NSPTCN packet and getting the NSPTRS packet, whereas under Oracle 11 this takes 94ms. I ran the trace again, this time with
TRACE_LEVEL_CLIENT=16and got the following results for the critical interval:
Oracle 10:
[22-MAR-2013 13:17:37:638] nscon: sending NSPTCN packet
[22-MAR-2013 13:17:37:638] nspsend: entry
[22-MAR-2013 13:17:37:638] nspsend: plen=218, type=1
[22-MAR-2013 13:17:37:638] nttwr: entry
[22-MAR-2013 13:17:37:638] nttwr: socket 9 had bytes written=218
[22-MAR-2013 13:17:37:638] nttwr: exit
[22-MAR-2013 13:17:37:638] nspsend: packet dump
<<packet dump removed>>
[22-MAR-2013 13:17:37:638] nspsend: 218 bytes to transport
[22-MAR-2013 13:17:37:638] nspsend: normal exit
[22-MAR-2013 13:17:37:638] nscon: exit (0)
[22-MAR-2013 13:17:37:638] nsdo: nsctxrnk=0
[22-MAR-2013 13:17:37:638] nsdo: normal exit
[22-MAR-2013 13:17:37:638] nsdo: entry
[22-MAR-2013 13:17:37:638] nsdo: cid=0, opcode=68, *bl=512, *what=9, uflgs=0x0, cflgs=0x3
[22-MAR-2013 13:17:37:638] nsdo: rank=64, nsctxrnk=0
[22-MAR-2013 13:17:37:638] nsdo: nsctx: state=2, flg=0x4005, mvd=0
[22-MAR-2013 13:17:37:638] nsdo: gtn=10, gtc=10, ptn=10, ptc=2011
[22-MAR-2013 13:17:37:638] nscon: entry
[22-MAR-2013 13:17:37:638] nscon: recving a packet
[22-MAR-2013 13:17:37:638] nsprecv: entry
[22-MAR-2013 13:17:37:638] nsprecv: reading from transport...
[22-MAR-2013 13:17:37:638] nttrd: entry
[22-MAR-2013 13:17:37:665] nttrd: socket 9 had bytes read=8
[22-MAR-2013 13:17:37:665] nttrd: exit
[22-MAR-2013 13:17:37:665] nsprecv: 8 bytes from transport
[22-MAR-2013 13:17:37:665] nsprecv: tlen=8, plen=8, type=11
[22-MAR-2013 13:17:37:665] nsprecv: packet dump
[22-MAR-2013 13:17:37:665] nsprecv: 00 08 00 00 0B 00 00 00 |........|
[22-MAR-2013 13:17:37:665] nsprecv: normal exit
[22-MAR-2013 13:17:37:665] nscon: got NSPTRS packetOracle 11
(1) [22-MAR-2013 13:33:40:504] nscon: sending NSPTCN packet
(1) [22-MAR-2013 13:33:40:504] nspsend: entry
(1) [22-MAR-2013 13:33:40:504] nspsend: plen=205, type=1
(1) [22-MAR-2013 13:33:40:504] nttwr: entry
(1) [22-MAR-2013 13:33:40:504] nttwr: socket 8 had bytes written=205
(1) [22-MAR-2013 13:33:40:504] nttwr: exit
(1) [22-MAR-2013 13:33:40:504] nspsend: packet dump
<<packet dump removed>>
(1) [22-MAR-2013 13:33:40:505] nspsend: 205 bytes to transport
(1) [22-MAR-2013 13:33:40:505] nspsend: normal exit
(1) [22-MAR-2013 13:33:40:505] nscon: exit (0)
(1) [22-MAR-2013 13:33:40:505] snsbitts_ts: entry
(1) [22-MAR-2013 13:33:40:505] snsbitts_ts: acquired the bit
(1) [22-MAR-2013 13:33:40:505] snsbitts_ts: normal exit
(1) [22-MAR-2013 13:33:40:505] nsdo: nsctxrnk=0
(1) [22-MAR-2013 13:33:40:505] snsbitcl_ts: entry
(1) [22-MAR-2013 13:33:40:505] snsbitcl_ts: normal exit
(1) [22-MAR-2013 13:33:40:505] nsdo: normal exit
(1) [22-MAR-2013 13:33:40:505] nsdo: entry
(1) [22-MAR-2013 13:33:40:505] nsdo: cid=0, opcode=68, *bl=2048, *what=9, uflgs=0x0, cflgs=0x3
(1) [22-MAR-2013 13:33:40:505] snsbitts_ts: entry
(1) [22-MAR-2013 13:33:40:505] snsbitts_ts: acquired the bit
(1) [22-MAR-2013 13:33:40:505] snsbitts_ts: normal exit
(1) [22-MAR-2013 13:33:40:505] nsdo: rank=64, nsctxrnk=0
(1) [22-MAR-2013 13:33:40:505] snsbitcl_ts: entry
(1) [22-MAR-2013 13:33:40:505] snsbitcl_ts: normal exit
(1) [22-MAR-2013 13:33:40:505] nsdo: nsctx: state=2, flg=0x4005, mvd=0
(1) [22-MAR-2013 13:33:40:505] nsdo: gtn=10, gtc=10, ptn=10, ptc=8155
(1) [22-MAR-2013 13:33:40:505] nscon: entry
(1) [22-MAR-2013 13:33:40:505] nscon: recving a packet
(1) [22-MAR-2013 13:33:40:505] nsprecv: entry
(1) [22-MAR-2013 13:33:40:505] nsprecv: reading from transport...
(1) [22-MAR-2013 13:33:40:505] nttrd: entry
(1) [22-MAR-2013 13:33:40:618] nttrd: socket 8 had bytes read=8
(1) [22-MAR-2013 13:33:40:618] nttrd: exit
(1) [22-MAR-2013 13:33:40:618] nsprecv: 8 bytes from transport
(1) [22-MAR-2013 13:33:40:618] nsprecv: tlen=8, plen=8, type=11
(1) [22-MAR-2013 13:33:40:618] nsprecv: packet dump
(1) [22-MAR-2013 13:33:40:618] nsprecv: 00 08 00 00 0B 00 00 00 |........|
(1) [22-MAR-2013 13:33:40:618] nsprecv: normal exit
(1) [22-MAR-2013 13:33:40:618] nscon: got NSPTRS packetAny ideas what could be the reason for this time difference? Something in our network configuration or something else?With local connections - I do not think a TCP packet send from an IP to the same IP, leaves the interface as an actual wire protocol/signal. If I'm correct, then running local connection tests will be mostly useless in checking the actual network infrastructure.
Tests 3 and 4 should be showing the same connection times as the same physical network infrastructure is used - only the direction is reversed in the tests.
I would assume that port settings on the switches and interface settings on the routers treat packets equally in both directions between 2 servers. But this could in part explain the problem if this is not the case. In a case of a router for example, the 1st test's ingress interface is the egress interface of the 2nd test (and vice versa). Configurations can differ substantially between interfaces on the same router. Likewise if there is a firewall - as different rule sets are applied in each test and these rule sets could differ.
So I would not be too quick to state that this is definitely not a network problem. But I agree that based on the small percentage difference (assuming comparable tests), it does not look like a network issue.
The next step is to determine what the delay is between the listener accepting the client connection, and the connection being serviced by a dedicated server process.
This will require listener tracing - tracing the time from when the listener accepted the connection (and parsed the TNS connection string), to handing off the connection to the dedicated server process.
As a comparison test, you can also test shared server connections. Dispatcher processes (of the db instance) register themselves with the listener. The shared server client hand off is thus done to an existing server process - no need for the Listener to make a kernel call to load and initialise an executable image.
Shared connections are typically faster than dedicated connections in this respect.
If there is a major time difference, then it means some kind of issue with the listener dealing with dedicated servers as oppose to dispatcher hand off's. As both connections would have had very similar network transit time - which means the connection time difference is related directly to dealing with a dedicated server connection request and hand off.
You can also substitute the oracle executable with a wrapper - and troubleshoot the actual dedicated server startup. I've only done this with Oracle XE 10.2 though and with local IPC connections. Unsure how robust this will be for testing purposes via TCP using 11g. -
How to control logic flow in SQL Plus script
Hi
I have the requirement below:
Before I start running an SQL script, I need to ensure that I am connecting as a particular user. If I am not that user, then the script should show a msg "Error - Invalid User - Log in as <<username>>"
Let's say i am executing a script A.sql.
SQL > @<path>a.sql
But before this script is executed -- i shall check for the user:
block begins...
select user into var1 from dual
if upper(var1) != 'ABCUSER' then
-- display the error message and stop execution of this script
else
@<path>a.sql (*it executes what i want :) )
end if;
block ends...
How do I write this code using an SQL script ? Pls suggesHi,
As Centinul said, SQL*Plus is poorly equipped to deal with problems like this. If possible, try to do what you want outside of SQL*Plus.
If you really have to do it in SQL*Plus, here are two ideas:
(1) run a script conditionally
(2) deliberately raise an error
(1) Using SQL*Plus substitution variables, you can decide which of several scripts to run as a sub-script, based on the results of some query.
For example, if a.sql is the script that only user ABCUSER is allowed to run, then write two other very short scripts:
(a) warning.sql, such as the following:
-- warning.sql
PROMPT You are not authorized to do this.
QUIT(b) step_1.sql, which decides whether a.sql or warning.sql should be run, and does it:
-- step_1.sql - Decide whether a.sql or warning.sql is to be run next, and do it.
-- (a) decide:
COLUMN script_name_col NEW_VALUE script_name
SELECT CASE
WHEN USER = 'ABCUSER'
THEN 'a.sql'
ELSE 'warning.sql'
END AS script_name_col
FROM dual;
-- do:
@&script_nameYou may want to use @@, or specify a complete path name.
(2) Deliberately raise an error, either in a separate script or in a.sql itself, like this:
WHENEVER SQLERROR EXIT
SELECT CASE
WHEN USER = 'ABCUSER'
THEN NULL
ELSE TO_NUMBER ('This will raise ORA-01722')
END AS "Welcome!"
FROM dual;
WHENEVER SQLERROR NONE
-- continue with the original a.sql -
How to learn sql query's execution time?
Hello All,
I am trying to find out the execution times of deterministic and non-deterministic function. Hence I have run following script and want to compare their execution times etc. Should I use v$sql? If so, which coloumns? Because I couln't find.
{code}
create table my_table
as
select mod(level,10)*10 col from dual connect by level <= 100 order by 1;
create or replace function my_det(giris number)
return number deterministic
is
num number;
begin
num :=giris*10;
return num;
end;
create or replace function my_func(giris number)
return number
is
num number;
begin
num :=giris*10;
return num;
end;
select my_det(col) from my_table; --First I want to run this query
select my_func(col) from my_table; --Then this query
{code}
What should I do in order to compare these two in terms of execution, fetch times, etc.?
Thanks in advance.Hello NightWig
As you're on 11g, if you have queries that take more than a few seconds I'd definitely recommend looking at the real-time SQL monitor (assuming you're appropriately licensed). As the name suggests, it shows the progress of an SQL statement in real-time, breaking down how long each operation has taken with details of rows fetched so far. It also keeps details of recently executed queries for a short while so can see how your changes affect a statement.
Oracle SQL Monitoring documentation:http://docs.oracle.com/cd/E11882_01/server.112/e16638/instance_tune.htm#PFGRF94543
Thank you -
My scripts all contain relative file paths e.g.
@@../directory1/file1.sql
Is there a way of setting the current working directory in SQL Developer to make this work?
In SQL*Plus for windows you simply opened the file but this does not seem to work.As I said, run them in SQL*Plus.
SQL*Developer is a development tool and database browser, not a SQLPLus clone.
It has its own methods of extracting data which may or may not suit your output requirements. You don't need col statements as much if you are viewing data in a grid, for example. [1]
I don't know what you use the sqlplus scripts for, but they could be replaced over time with some combination of Apex, SQLDeveloper reports and straight sqldeveloper queries.
As for SQL*PLus being greyed out on the menu, there are some known issues about that. I think one of them is that you need to be using tns connections. However, the sqlplus menu item is gone in sqldeveloper 1.5 so don't rely on it. Learn to run if from the command line.
[1] Despite that, I would arguethat SQLDeveloper should support all (with tiny exceptions) SQLPlus commands. Not because I see it as a sqlplus replacement, but so it can be used to develop scripts which can then be run in SQL*Plus without amendment (without the hassle of switching back and forth during development) -
Detecting clientside NLS_LANG setting in SQL*Plus script
Our company has developed an application that uses an Oracle database as it backend. Companies can buy our application and run it against their own Oracle installation.
A new version of our application often requires an update to the Oracle database schema.
Together with new application files we send our customers an update.sql script they must run against their database using SQL*Plus.
This update script may contain international characters like é for example:
UPDATE SHOPS SET DESCRIPTION = 'Café'
WHERE SHOP_ID=1We save the SQL-script file in windows-1252 encoding so the character é is encoded as 0xE9 in the script file.
When the DBA running the upgrade script has set NLS_LANG=.WE8MSWIN1252 this works perfectly.
When the DBA has set his NLS_LANG=US7ASCII the é gets replaced by an upside-down question mark. Other NLS_LANG settings can also be troublesome.
To prevent this we give very clear installation instructions. However, nobody reads them. This leads to two questions:
A) Is there a way to prevent this problem so I do not depend on the NLS_LANG setting by the DBA running the upgrade script?
B) Otherwise: is there a way to test for the NLS_LANG setting inside the script and abort if it is not WE8MSWIN1252?
Info:
Database is 10.2.0.3/10.2.0.4 and sometimes 10.2.0.5, always database character set WE8MSWIN1252.
Client software: I do not know what each DBA uses but it will be mostly 10g client software
Client OS: Some DBA's will be running the script from Windows, others from some Unix variety. I cannot control that.I agree with Sergiusz. You're much better off if you can remove character set dependencies from your scripts by using commands like this.
UPDATE SHOPS SET DESCRIPTION = unistr( 'Caf\00E9' )
WHERE SHOP_ID=1 ;If that's not possible however you can try this approach to determine the session's character set.
SQL> column USERENV_LANGUAGE format a30
SQL> column oracle_charset format a20
SQL> r
1 select
2 userenv_language
3 , substr
4 ( userenv_language
5 , instr( userenv_language, '.' ) + 1
6 ) as oracle_charset
7 from
8 ( select sys_context( 'USERENV', 'LANGUAGE' ) as userenv_language
9 from dual
10* )
USERENV_LANGUAGE ORACLE_CHARSET
AMERICAN_AMERICA.AL32UTF8 AL32UTF8 --
Joe -
SQL Query + long execution time.
Dear Gurus/masters/All,
I request you all to help me in tuning the SQL query which is taking more time. DB Version : 10.2.0.4
SQL Query WHERE condition:
select column1, column2, .........
FROM
SIEBEL.S_ORG_EXT T1,
SIEBEL.S_PROD_INT T2,
SIEBEL.S_VOD T3,
SIEBEL.S_ORG_EXT T4,
SIEBEL.S_ORG_EXT T5,
SIEBEL.S_ORG_EXT_X T6,
SIEBEL.S_PROD_LN T7,
SIEBEL.S_ASSET_OM T8,
SIEBEL.S_VOD_VER T9,
SIEBEL.S_CTLG_CAT T10,
SIEBEL.S_CONTACT T11,
SIEBEL.S_PARTY T12,
SIEBEL.S_PARTY T13,
SIEBEL.S_PROD_INT T14,
SIEBEL.S_ASSET_BU T15,
SIEBEL.S_CTLG_CAT T16,
SIEBEL.S_ORG_EXT T17,
SIEBEL.S_ORG_EXT T18,
SIEBEL.S_ASSET T19,
SIEBEL.S_ADDR_PER T20,
SIEBEL.S_ORG_EXT T21,
SIEBEL.S_ASSET_X T22,
SIEBEL.S_ASSET T23
WHERE
T16.PAR_CAT_ID = T10.ROW_ID (+) AND
T14.CG_PR_CTLG_CAT_ID = T16.ROW_ID (+) AND
T3.ROW_ID = T9.VOD_ID AND
T14.CFG_MODEL_ID = T3.OBJECT_NUM AND
T23.OWNER_CON_ID = T11.ROW_ID (+) AND
T23.OWNER_ACCNT_ID = T6.PAR_ROW_ID (+) AND
T23.PER_ADDR_ID = T20.ROW_ID (+) AND
T23.PROD_ID = T14.ROW_ID AND
T23.OWNER_ACCNT_ID = T21.PAR_ROW_ID (+) AND
T14.PR_PROD_LN_ID = T7.ROW_ID (+) AND
T23.ROOT_ASSET_ID = T19.ROW_ID (+) AND
T19.PROD_ID = T2.ROW_ID (+) AND
T23.BILL_ACCNT_ID = T18.PAR_ROW_ID (+) AND
T23.RTNG_DLR_ID = T1.PAR_ROW_ID (+) AND
T23.PREF_SRV_DLR_ID = T17.PAR_ROW_ID (+) AND
T23.DLR_ID = T4.PAR_ROW_ID (+) AND
T23.ROW_ID = T22.PAR_ROW_ID (+) AND
T23.ROW_ID = T8.PAR_ROW_ID (+) AND
T23.PR_CON_ID = T12.ROW_ID (+) AND
T23.BU_ID = T15.BU_ID (+) AND T23.ROW_ID = T15.ASSET_ID (+) AND
T15.BU_ID = T13.ROW_ID (+) AND
T15.BU_ID = T5.PAR_ROW_ID (+) AND
((T23.SERIAL_NUM IS NOT NULL AND T23.PAR_ASSET_ID IS NULL OR T23.X_PHONE_NUMBER IS NOT NULL AND T23.PAR_ASSET_ID IS NOT NULL) AND
(T9.VER_NUM = :1));Query Exection Plan:
PLAN_TABLE_OUTPUT
Plan hash value: 967177145
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 54117 | 92M| 4435K (1)| 01:58:43 |
| 1 | NESTED LOOPS OUTER | | 54117 | 92M| 4435K (1)| 01:58:43 |
| 2 | NESTED LOOPS OUTER | | 54117 | 87M| 4261K (1)| 01:54:04 |
| 3 | NESTED LOOPS OUTER | | 54117 | 86M| 4154K (1)| 01:51:13 |
| 4 | NESTED LOOPS OUTER | | 54117 | 85M| 4111K (1)| 01:50:03 |
| 5 | NESTED LOOPS OUTER | | 54117 | 84M| 3980K (1)| 01:46:33 |
| 6 | NESTED LOOPS OUTER | | 54117 | 83M| 3937K (1)| 01:45:24 |
| 7 | NESTED LOOPS OUTER | | 54117 | 81M| 3763K (1)| 01:40:44 |
| 8 | NESTED LOOPS OUTER | | 54117 | 81M| 3751K (1)| 01:40:25 |
| 9 | NESTED LOOPS OUTER | | 54117 | 80M| 3621K (1)| 01:36:57 |
| 10 | NESTED LOOPS OUTER | | 54117 | 73M| 3515K (1)| 01:34:07 |
| 11 | NESTED LOOPS OUTER | | 54117 | 71M| 3410K (1)| 01:31:18 |
| 12 | NESTED LOOPS OUTER | | 54117 | 69M| 3410K (1)| 01:31:18 |
| 13 | NESTED LOOPS OUTER | | 54117 | 67M| 3410K (1)| 01:31:18 |
| 14 | NESTED LOOPS OUTER | | 54117 | 66M| 3410K (1)| 01:31:18 |
| 15 | NESTED LOOPS OUTER | | 54117 | 64M| 3324K (1)| 01:28:59 |
| 16 | NESTED LOOPS OUTER | | 54117 | 62M| 3237K (1)| 01:26:40 |
| 17 | NESTED LOOPS | | 54117 | 57M| 3106K (1)| 01:23:10 |
| 18 | NESTED LOOPS OUTER | | 71 | 43665 | 381 (2)| 00:00:01 |
| 19 | NESTED LOOPS OUTER | | 71 | 42316 | 323 (2)| 00:00:01 |
| 20 | NESTED LOOPS OUTER | | 71 | 41322 | 322 (2)| 00:00:01 |
| 21 | NESTED LOOPS | | 71 | 24708 | 265 (3)| 00:00:01 |
| 22 | NESTED LOOPS | | 77 | 2772 | 141 (4)| 00:00:01 |
|* 23 | TABLE ACCESS FULL | S_VOD_VER | 75 | 1350 | 72 (7)| 00:00:01 |
| 24 | TABLE ACCESS BY INDEX ROWID| S_VOD | 1 | 18 | 1 (0)| 00:00:01 |
|* 25 | INDEX UNIQUE SCAN | S_VOD_P1 | 1 | | 1 (0)| 00:00:01 |
| 26 | TABLE ACCESS BY INDEX ROWID | S_PROD_INT | 1 | 312 | 2 (0)| 00:00:01 |
|* 27 | INDEX RANGE SCAN | S_PROD_INT_F9 | 1 | | 1 (0)| 00:00:01 |
| 28 | TABLE ACCESS BY INDEX ROWID | S_PROD_LN | 1 | 234 | 1 (0)| 00:00:01 |
|* 29 | INDEX UNIQUE SCAN | S_PROD_LN_P1 | 1 | | 1 (0)| 00:00:01 |
| 30 | TABLE ACCESS BY INDEX ROWID | S_CTLG_CAT | 1 | 14 | 1 (0)| 00:00:01 |
|* 31 | INDEX UNIQUE SCAN | S_CTLG_CAT_P1 | 1 | | 1 (0)| 00:00:01 |
| 32 | TABLE ACCESS BY INDEX ROWID | S_CTLG_CAT | 1 | 19 | 1 (0)| 00:00:01 |
|* 33 | INDEX UNIQUE SCAN | S_CTLG_CAT_P1 | 1 | | 1 (0)| 00:00:01 |
|* 34 | TABLE ACCESS BY INDEX ROWID | S_ASSET | 760 | 375K| 43753 (1)| 00:01:11 |
|* 35 | INDEX RANGE SCAN | S_ASSET_U2 | 55873 | | 312 (3)| 00:00:01 |
| 36 | TABLE ACCESS BY INDEX ROWID | S_ASSET_OM | 1 | 94 | 2 (0)| 00:00:01 |
|* 37 | INDEX RANGE SCAN | S_ASSET_OM_U1 | 1 | | 2 (0)| 00:00:01 |
| 38 | TABLE ACCESS BY INDEX ROWID | S_CONTACT | 1 | 39 | 2 (0)| 00:00:01 |
|* 39 | INDEX UNIQUE SCAN | S_CONTACT_P1 | 1 | | 1 (0)| 00:00:01 |
| 40 | TABLE ACCESS BY INDEX ROWID | S_ADDR_PER | 1 | 29 | 2 (0)| 00:00:01 |
|* 41 | INDEX UNIQUE SCAN | S_ADDR_PER_P1 | 1 | | 1 (0)| 00:00:01 |
| 42 | TABLE ACCESS BY INDEX ROWID | S_ORG_EXT | 1 | 32 | 1 (0)| 00:00:01 |
|* 43 | INDEX UNIQUE SCAN | S_ORG_EXT_U3 | 1 | | 1 (0)| 00:00:01 |
| 44 | TABLE ACCESS BY INDEX ROWID | S_ORG_EXT | 1 | 32 | 1 (0)| 00:00:01 |
|* 45 | INDEX UNIQUE SCAN | S_ORG_EXT_U3 | 1 | | 1 (0)| 00:00:01 |
| 46 | TABLE ACCESS BY INDEX ROWID | S_ORG_EXT | 1 | 32 | 1 (0)| 00:00:01 |
|* 47 | INDEX UNIQUE SCAN | S_ORG_EXT_U3 | 1 | | 1 (0)| 00:00:01 |
| 48 | TABLE ACCESS BY INDEX ROWID | S_ORG_EXT | 1 | 36 | 2 (0)| 00:00:01 |
|* 49 | INDEX UNIQUE SCAN | S_ORG_EXT_U3 | 1 | | 1 (0)| 00:00:01 |
| 50 | TABLE ACCESS BY INDEX ROWID | S_ORG_EXT | 1 | 139 | 2 (0)| 00:00:01 |
|* 51 | INDEX UNIQUE SCAN | S_ORG_EXT_U3 | 1 | | 1 (0)| 00:00:01 |
| 52 | TABLE ACCESS BY INDEX ROWID | S_ORG_EXT_X | 1 | 16 | 2 (0)| 00:00:01 |
|* 53 | INDEX RANGE SCAN | S_ORG_EXT_X_U1 | 1 | | 2 (0)| 00:00:01 |
|* 54 | INDEX UNIQUE SCAN | S_PARTY_P1 | 1 | 12 | 1 (0)| 00:00:01 |
| 55 | TABLE ACCESS BY INDEX ROWID | S_ASSET_BU | 1 | 34 | 3 (0)| 00:00:01 |
|* 56 | INDEX RANGE SCAN | S_ASSET_BU_U1 | 1 | | 2 (0)| 00:00:01 |
|* 57 | INDEX UNIQUE SCAN | S_PARTY_P1 | 1 | 12 | 1 (0)| 00:00:01 |
| 58 | TABLE ACCESS BY INDEX ROWID | S_ASSET | 1 | 37 | 2 (0)| 00:00:01 |
|* 59 | INDEX UNIQUE SCAN | S_ASSET_P1 | 1 | | 2 (0)| 00:00:01 |
| 60 | TABLE ACCESS BY INDEX ROWID | S_PROD_INT | 1 | 16 | 1 (0)| 00:00:01 |
|* 61 | INDEX UNIQUE SCAN | S_PROD_INT_P1 | 1 | | 1 (0)| 00:00:01 |
| 62 | TABLE ACCESS BY INDEX ROWID | S_ORG_EXT | 1 | 14 | 2 (0)| 00:00:01 |
|* 63 | INDEX UNIQUE SCAN | S_ORG_EXT_U3 | 1 | | 1 (0)| 00:00:01 |
| 64 | TABLE ACCESS BY INDEX ROWID | S_ASSET_X | 1 | 93 | 3 (0)| 00:00:01 |
|* 65 | INDEX RANGE SCAN | S_ASSET_X_U1 | 1 | | 2 (0)| 00:00:01 |
Predicate Information (identified by operation id):
23 - filter("T9"."VER_NUM"=TO_NUMBER(:1))
25 - access("T3"."ROW_ID"="T9"."VOD_ID")
27 - access("T14"."CFG_MODEL_ID"="T3"."OBJECT_NUM")
29 - access("T14"."PR_PROD_LN_ID"="T7"."ROW_ID"(+))
31 - access("T14"."CG_PR_CTLG_CAT_ID"="T16"."ROW_ID"(+))
33 - access("T16"."PAR_CAT_ID"="T10"."ROW_ID"(+))
34 - filter("T23"."PAR_ASSET_ID" IS NULL AND "T23"."SERIAL_NUM" IS NOT NULL OR "T23"."X_PHONE_NUMBER" IS
NOT NULL AND "T23"."PAR_ASSET_ID" IS NOT NULL)
35 - access("T23"."PROD_ID"="T14"."ROW_ID")
37 - access("T23"."ROW_ID"="T8"."PAR_ROW_ID"(+))
39 - access("T23"."OWNER_CON_ID"="T11"."ROW_ID"(+))
41 - access("T23"."PER_ADDR_ID"="T20"."ROW_ID"(+))
43 - access("T23"."RTNG_DLR_ID"="T1"."PAR_ROW_ID"(+))
45 - access("T23"."DLR_ID"="T4"."PAR_ROW_ID"(+))
47 - access("T23"."PREF_SRV_DLR_ID"="T17"."PAR_ROW_ID"(+))
49 - access("T23"."BILL_ACCNT_ID"="T18"."PAR_ROW_ID"(+))
51 - access("T23"."OWNER_ACCNT_ID"="T21"."PAR_ROW_ID"(+))
53 - access("T23"."OWNER_ACCNT_ID"="T6"."PAR_ROW_ID"(+))
54 - access("T23"."PR_CON_ID"="T12"."ROW_ID"(+))
56 - access("T23"."ROW_ID"="T15"."ASSET_ID"(+) AND "T23"."BU_ID"="T15"."BU_ID"(+))
57 - access("T15"."BU_ID"="T13"."ROW_ID"(+))
59 - access("T23"."ROOT_ASSET_ID"="T19"."ROW_ID"(+))
61 - access("T19"."PROD_ID"="T2"."ROW_ID"(+))
63 - access("T15"."BU_ID"="T5"."PAR_ROW_ID"(+))
65 - access("T23"."ROW_ID"="T22"."PAR_ROW_ID"(+))
Note
- dynamic sampling used for this statement
105 rows selected.out put of dbms_xplan.display_cursor :
SQL> select * from table(dbms_xplan.display_cursor('xxxxxxxxxxxxxx',NULL,'iostats last'));
PLAN_TABLE_OUTPUT
SQL_ID xxxxxxxxxxxxxx, child number 0
SELECT T23.CONFLICT_ID, T23.LAST_UPD, T23.CREATED, T23.LAST_UPD_BY, T23.CREATED_BY,
T23.MODIFICATION_NUM, T23.ROW_ID, T23.ASSET_NUM, T21.LOC, T21.NAME, T23.INSTALL_DT,
T23.INVLOC_ID, T23.NAME, T23.OU_ADDR_ID, T23.OWNER_ACCNT_ID, T23.PAR_ASSET_ID, T23.PER_ADDR_ID,
T20.STATE, T23.PR_CON_ID, T23.PR_EMP_ID, T14.DESC_TEXT, T23.PROD_ID, T14.NAME,
T21.INTEGRATION_ID, T23.COST_LST_ID, T14.SERIALIZED_FLG, T23.REGISTERED_DT, T23.SERIAL_NUM,
T23.VERSION, T23.STATUS_CD, T14.PR_PROD_LN_ID, T7.NAME, T23.QTY, T23.ASSET_COND_CD,
T23.PR_ACCNT_ID, T23.OWNERSHIP_TYPE_CD, T23.XA_CLASS_ID, T23.OPER_STATUS_CD, T23.SP_NUM,
T23.BILL_ACCNT_ID, T23.SERV_ACCT_ID, T9.RELEASED_FLG, T23.CFG_TYPE_CD, T9.VER_NUM, T23.END_DT,
T23.ASSEMBLY_PORT_ID,
Plan hash value: xxxxxxxxxxxxxx
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | Reads |
| 1 | NESTED LOOPS OUTER | | 1 | 10 | 10 |00:23:58.99 | 1236K| 460K|
| 2 | NESTED LOOPS OUTER | | 1 | 10 | 10 |00:23:58.99 | 1236K| 460K|
| 3 | NESTED LOOPS OUTER | | 1 | 10 | 10 |00:23:58.85 | 1236K| 460K|
| 4 | NESTED LOOPS OUTER | | 1 | 10 | 10 |00:23:58.69 | 1236K| 460K|
| 5 | NESTED LOOPS OUTER | | 1 | 10 | 10 |00:23:58.69 | 1236K| 460K|
| 6 | NESTED LOOPS OUTER | | 1 | 10 | 10 |00:23:58.69 | 1236K| 460K|
| 7 | NESTED LOOPS OUTER | | 1 | 11 | 10 |00:23:58.47 | 1236K| 460K|
| 8 | NESTED LOOPS OUTER | | 1 | 11 | 10 |00:23:58.47 | 1236K| 460K|
| 9 | NESTED LOOPS OUTER | | 1 | 11 | 10 |00:23:58.37 | 1236K| 460K|
| 10 | NESTED LOOPS OUTER | | 1 | 11 | 10 |00:23:58.22 | 1236K| 460K|
| 11 | NESTED LOOPS OUTER | | 1 | 11 | 10 |00:23:58.16 | 1236K| 460K|
| 12 | NESTED LOOPS OUTER | | 1 | 11 | 10 |00:23:58.16 | 1236K| 460K|
| 13 | NESTED LOOPS OUTER | | 1 | 11 | 10 |00:23:58.16 | 1236K| 460K|
| 14 | NESTED LOOPS OUTER | | 1 | 11 | 10 |00:23:58.16 | 1236K| 460K|
| 15 | NESTED LOOPS OUTER | | 1 | 11 | 10 |00:23:58.09 | 1236K| 460K|
| 16 | NESTED LOOPS OUTER | | 1 | 11 | 10 |00:23:57.99 | 1236K| 460K|
| 17 | NESTED LOOPS | | 1 | 11 | 10 |00:23:57.98 | 1236K| 460K|
| 18 | NESTED LOOPS OUTER | | 1 | 1 | 57 |00:00:00.02 | 828 | 0 |
| 19 | NESTED LOOPS OUTER | | 1 | 2 | 57 |00:00:00.02 | 828 | 0 |
| 20 | NESTED LOOPS OUTER | | 1 | 2 | 57 |00:00:00.02 | 828 | 0 |
| 21 | NESTED LOOPS | | 1 | 2 | 57 |00:00:00.01 | 786 | 0 |
| 22 | NESTED LOOPS | | 1 | 2 | 232 |00:00:00.01 | 493 | 0 |
|* 23 | TABLE ACCESS FULL | S_VOD_VER | 1 | 75 | 246 |00:00:00.01 | 12 | 0 |
| 24 | TABLE ACCESS BY INDEX ROWID| S_VOD | 246 | 1 | 232 |00:00:00.01 | 481 | 0 |
|* 25 | INDEX UNIQUE SCAN | S_VOD_P1 | 246 | 1 | 232 |00:00:00.01 | 249 | 0 |
| 26 | TABLE ACCESS BY INDEX ROWID | S_PROD_INT | 232 | 1 | 57 |00:00:00.01 | 293 | 0 |
|* 27 | INDEX RANGE SCAN | S_PROD_INT_F9 | 232 | 1 | 57 |00:00:00.01 | 236 | 0 |
| 28 | TABLE ACCESS BY INDEX ROWID | S_PROD_LN | 57 | 1 | 39 |00:00:00.01 | 42 | 0 |
|* 29 | INDEX UNIQUE SCAN | S_PROD_LN_P1 | 57 | 1 | 39 |00:00:00.01 | 3 | 0 |
| 30 | TABLE ACCESS BY INDEX ROWID | S_CTLG_CAT | 57 | 1 | 0 |00:00:00.01 | 0 | 0 |
|* 31 | INDEX UNIQUE SCAN | S_CTLG_CAT_P1 | 57 | 1 | 0 |00:00:00.01 | 0 | 0 |
| 32 | TABLE ACCESS BY INDEX ROWID | S_CTLG_CAT | 57 | 1 | 0 |00:00:00.01 | 0 | 0 |
|* 33 | INDEX UNIQUE SCAN | S_CTLG_CAT_P1 | 57 | 1 | 0 |00:00:00.01 | 0 | 0 |
|* 34 | TABLE ACCESS BY INDEX ROWID | S_ASSET | 57 | 10 | 10 |00:23:57.97 | 1235K| 460K|
|* 35 | INDEX RANGE SCAN | S_ASSET_U2 | 57 | 734 | 627K|00:00:01.34 | 4295 | 2032 |
| 36 | TABLE ACCESS BY INDEX ROWID | S_ASSET_OM | 10 | 1 | 0 |00:00:00.01 | 26 | 2 |
|* 37 | INDEX RANGE SCAN | S_ASSET_OM_U1 | 10 | 1 | 0 |00:00:00.01 | 26 | 2 |
| 38 | TABLE ACCESS BY INDEX ROWID | S_CONTACT | 10 | 1 | 10 |00:00:00.11 | 36 | 12 |
|* 39 | INDEX UNIQUE SCAN | S_CONTACT_P1 | 10 | 1 | 10 |00:00:00.06 | 26 | 6 |
| 40 | TABLE ACCESS BY INDEX ROWID | S_ADDR_PER | 10 | 1 | 10 |00:00:00.07 | 36 | 18 |
|* 41 | INDEX UNIQUE SCAN | S_ADDR_PER_P1 | 10 | 1 | 10 |00:00:00.04 | 26 | 8 |
| 42 | TABLE ACCESS BY INDEX ROWID | S_ORG_EXT | 10 | 1 | 0 |00:00:00.01 | 0 | 0 |
|* 43 | INDEX UNIQUE SCAN | S_ORG_EXT_U3 | 10 | 1 | 0 |00:00:00.01 | 0 | 0 |
| 44 | TABLE ACCESS BY INDEX ROWID | S_ORG_EXT | 10 | 1 | 0 |00:00:00.01 | 0 | 0 |
|* 45 | INDEX UNIQUE SCAN | S_ORG_EXT_U3 | 10 | 1 | 0 |00:00:00.01 | 0 | 0 |
| 46 | TABLE ACCESS BY INDEX ROWID | S_ORG_EXT | 10 | 1 | 0 |00:00:00.01 | 0 | 0 |
|* 47 | INDEX UNIQUE SCAN | S_ORG_EXT_U3 | 10 | 1 | 0 |00:00:00.01 | 0 | 0 |
| 48 | TABLE ACCESS BY INDEX ROWID | S_ORG_EXT | 10 | 1 | 10 |00:00:00.05 | 46 | 12 |
|* 49 | INDEX UNIQUE SCAN | S_ORG_EXT_U3 | 10 | 1 | 10 |00:00:00.03 | 26 | 6 |
| 50 | TABLE ACCESS BY INDEX ROWID | S_ORG_EXT | 10 | 1 | 10 |00:00:00.15 | 55 | 23 |
|* 51 | INDEX UNIQUE SCAN | S_ORG_EXT_U3 | 10 | 1 | 10 |00:00:00.04 | 26 | 6 |
| 52 | TABLE ACCESS BY INDEX ROWID | S_ORG_EXT_X | 10 | 1 | 10 |00:00:00.10 | 40 | 12 |
|* 53 | INDEX RANGE SCAN | S_ORG_EXT_X_U1 | 10 | 1 | 10 |00:00:00.05 | 30 | 6 |
|* 54 | INDEX UNIQUE SCAN | S_PARTY_P1 | 10 | 1 | 0 |00:00:00.01 | 5 | 0 |
| 55 | TABLE ACCESS BY INDEX ROWID | S_ASSET_BU | 10 | 1 | 10 |00:00:00.22 | 50 | 29 |
|* 56 | INDEX RANGE SCAN | S_ASSET_BU_U1 | 10 | 1 | 10 |00:00:00.15 | 40 | 19 |
| 57 | TABLE ACCESS BY INDEX ROWID | S_ORG_EXT | 10 | 1 | 10 |00:00:00.01 | 36 | 0 |
|* 58 | INDEX UNIQUE SCAN | S_ORG_EXT_U3 | 10 | 1 | 10 |00:00:00.01 | 26 | 0 |
|* 59 | INDEX UNIQUE SCAN | S_PARTY_P1 | 10 | 1 | 10 |00:00:00.01 | 26 | 0 |
| 60 | TABLE ACCESS BY INDEX ROWID | S_ASSET_X | 10 | 1 | 10 |00:00:00.16 | 50 | 20 |
|* 61 | INDEX RANGE SCAN | S_ASSET_X_U1 | 10 | 1 | 10 |00:00:00.09 | 40 | 10 |
| 62 | TABLE ACCESS BY INDEX ROWID | S_ASSET | 10 | 1 | 10 |00:00:00.14 | 46 | 19 |
|* 63 | INDEX UNIQUE SCAN | S_ASSET_P1 | 10 | 1 | 10 |00:00:00.04 | 36 | 9 |
| 64 | TABLE ACCESS BY INDEX ROWID | S_PROD_INT | 10 | 1 | 10 |00:00:00.01 | 26 | 0 |
|* 65 | INDEX UNIQUE SCAN | S_PROD_INT_P1 | 10 | 1 | 10 |00:00:00.01 | 16 | 0 |
Predicate Information (identified by operation id):
23 - filter("T9"."VER_NUM"=:1)
25 - access("T3"."ROW_ID"="T9"."VOD_ID")
27 - access("T14"."CFG_MODEL_ID"="T3"."OBJECT_NUM")
29 - access("T14"."PR_PROD_LN_ID"="T7"."ROW_ID")
31 - access("T14"."CG_PR_CTLG_CAT_ID"="T16"."ROW_ID")
33 - access("T16"."PAR_CAT_ID"="T10"."ROW_ID")
34 - filter((("T23"."PAR_ASSET_ID" IS NULL AND "T23"."SERIAL_NUM" IS NOT NULL) OR ("T23"."X_PHONE_NUMBER" IS NOT NULL AND
"T23"."PAR_ASSET_ID" IS NOT NULL)))
35 - access("T23"."PROD_ID"="T14"."ROW_ID")
37 - access("T23"."ROW_ID"="T8"."PAR_ROW_ID")
39 - access("T23"."OWNER_CON_ID"="T11"."ROW_ID")
41 - access("T23"."PER_ADDR_ID"="T20"."ROW_ID")
43 - access("T23"."RTNG_DLR_ID"="T1"."PAR_ROW_ID")
45 - access("T23"."DLR_ID"="T4"."PAR_ROW_ID")
47 - access("T23"."PREF_SRV_DLR_ID"="T17"."PAR_ROW_ID")
49 - access("T23"."BILL_ACCNT_ID"="T18"."PAR_ROW_ID")
51 - access("T23"."OWNER_ACCNT_ID"="T21"."PAR_ROW_ID")
53 - access("T23"."OWNER_ACCNT_ID"="T6"."PAR_ROW_ID")
54 - access("T23"."PR_CON_ID"="T12"."ROW_ID")
56 - access("T23"."ROW_ID"="T15"."ASSET_ID" AND "T23"."BU_ID"="T15"."BU_ID")
58 - access("T15"."BU_ID"="T5"."PAR_ROW_ID")
59 - access("T15"."BU_ID"="T13"."ROW_ID")
61 - access("T23"."ROW_ID"="T22"."PAR_ROW_ID")
63 - access("T23"."ROOT_ASSET_ID"="T19"."ROW_ID")
65 - access("T19"."PROD_ID"="T2"."ROW_ID")
SQL_ID xxxxxxxxxxxxxx, child number 1
SELECT T23.CONFLICT_ID, T23.LAST_UPD, T23.CREATED, T23.LAST_UPD_BY, T23.CREATED_BY,
T23.MODIFICATION_NUM, T23.ROW_ID, T23.ASSET_NUM, T21.LOC, T21.NAME, T23.INSTALL_DT,
T23.INVLOC_ID, T23.NAME, T23.OU_ADDR_ID, T23.OWNER_ACCNT_ID, T23.PAR_ASSET_ID, T23.PER_ADDR_ID,
T20.STATE, T23.PR_CON_ID, T23.PR_EMP_ID, T14.DESC_TEXT, T23.PROD_ID, T14.NAME,
T21.INTEGRATION_ID, T23.COST_LST_ID, T14.SERIALIZED_FLG, T23.REGISTERED_DT, T23.SERIAL_NUM,
T23.VERSION, T23.STATUS_CD, T14.PR_PROD_LN_ID, T7.NAME, T23.QTY, T23.ASSET_COND_CD,
T23.PR_ACCNT_ID, T23.OWNERSHIP_TYPE_CD, T23.XA_CLASS_ID, T23.OPER_STATUS_CD, T23.SP_NUM,
T23.BILL_ACCNT_ID, T23.SERV_ACCT_ID, T9.RELEASED_FLG, T23.CFG_TYPE_CD, T9.VER_NUM, T23.END_DT,
T23.ASSEMBLY_PORT_ID,
Plan hash value: xxxxxxxxxxxxxx
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | Reads |
| 1 | NESTED LOOPS OUTER | | 1 | 10 | 10 |00:28:15.04 | 1237K| 512K|
| 2 | NESTED LOOPS OUTER | | 1 | 10 | 10 |00:28:15.04 | 1237K| 512K|
| 3 | NESTED LOOPS OUTER | | 1 | 10 | 10 |00:28:14.92 | 1237K| 512K|
| 4 | NESTED LOOPS OUTER | | 1 | 10 | 10 |00:28:14.82 | 1237K| 512K|
| 5 | NESTED LOOPS OUTER | | 1 | 10 | 10 |00:28:14.82 | 1237K| 512K|
| 6 | NESTED LOOPS OUTER | | 1 | 10 | 10 |00:28:14.82 | 1237K| 512K|
| 7 | NESTED LOOPS OUTER | | 1 | 11 | 10 |00:28:14.64 | 1237K| 512K|
| 8 | NESTED LOOPS OUTER | | 1 | 11 | 10 |00:28:14.63 | 1237K| 512K|
| 9 | NESTED LOOPS OUTER | | 1 | 11 | 10 |00:28:14.51 | 1237K| 512K|
| 10 | NESTED LOOPS OUTER | | 1 | 11 | 10 |00:28:14.42 | 1237K| 512K|
| 11 | NESTED LOOPS OUTER | | 1 | 11 | 10 |00:28:14.33 | 1236K| 512K|
| 12 | NESTED LOOPS OUTER | | 1 | 11 | 10 |00:28:14.33 | 1236K| 512K|
| 13 | NESTED LOOPS OUTER | | 1 | 11 | 10 |00:28:14.33 | 1236K| 512K|
| 14 | NESTED LOOPS OUTER | | 1 | 11 | 10 |00:28:14.33 | 1236K| 512K|
| 15 | NESTED LOOPS OUTER | | 1 | 11 | 10 |00:28:14.23 | 1236K| 512K|
| 16 | NESTED LOOPS OUTER | | 1 | 11 | 10 |00:28:14.12 | 1236K| 512K|
| 17 | NESTED LOOPS | | 1 | 11 | 10 |00:28:14.12 | 1236K| 512K|
| 18 | NESTED LOOPS OUTER | | 1 | 1 | 57 |00:00:00.02 | 828 | 0 |
| 19 | NESTED LOOPS OUTER | | 1 | 1 | 57 |00:00:00.02 | 828 | 0 |
| 20 | NESTED LOOPS OUTER | | 1 | 1 | 57 |00:00:00.01 | 828 | 0 |
| 21 | NESTED LOOPS | | 1 | 1 | 57 |00:00:00.01 | 786 | 0 |
| 22 | NESTED LOOPS | | 1 | 2 | 232 |00:00:00.01 | 493 | 0 |
|* 23 | TABLE ACCESS FULL | S_VOD_VER | 1 | 74 | 246 |00:00:00.01 | 12 | 0 |
| 24 | TABLE ACCESS BY INDEX ROWID| S_VOD | 246 | 1 | 232 |00:00:00.01 | 481 | 0 |
|* 25 | INDEX UNIQUE SCAN | S_VOD_P1 | 246 | 1 | 232 |00:00:00.01 | 249 | 0 |
| 26 | TABLE ACCESS BY INDEX ROWID | S_PROD_INT | 232 | 1 | 57 |00:00:00.01 | 293 | 0 |
|* 27 | INDEX RANGE SCAN | S_PROD_INT_F9 | 232 | 1 | 57 |00:00:00.01 | 236 | 0 |
| 28 | TABLE ACCESS BY INDEX ROWID | S_PROD_LN | 57 | 1 | 39 |00:00:00.01 | 42 | 0 |
|* 29 | INDEX UNIQUE SCAN | S_PROD_LN_P1 | 57 | 1 | 39 |00:00:00.01 | 3 | 0 |
| 30 | TABLE ACCESS BY INDEX ROWID | S_CTLG_CAT | 57 | 1 | 0 |00:00:00.01 | 0 | 0 |
|* 31 | INDEX UNIQUE SCAN | S_CTLG_CAT_P1 | 57 | 1 | 0 |00:00:00.01 | 0 | 0 |
| 32 | TABLE ACCESS BY INDEX ROWID | S_CTLG_CAT | 57 | 1 | 0 |00:00:00.01 | 0 | 0 |
|* 33 | INDEX UNIQUE SCAN | S_CTLG_CAT_P1 | 57 | 1 | 0 |00:00:00.01 | 0 | 0 |
|* 34 | TABLE ACCESS BY INDEX ROWID | S_ASSET | 57 | 10 | 10 |00:28:14.10 | 1236K| 512K|
|* 35 | INDEX RANGE SCAN | S_ASSET_U2 | 57 | 734 | 627K|00:00:01.26 | 4299 | 3327 |
| 36 | TABLE ACCESS BY INDEX ROWID | S_ASSET_OM | 10 | 1 | 0 |00:00:00.01 | 26 | 2 |
|* 37 | INDEX RANGE SCAN | S_ASSET_OM_U1 | 10 | 1 | 0 |00:00:00.01 | 26 | 2 |
| 38 | TABLE ACCESS BY INDEX ROWID | S_CONTACT | 10 | 1 | 10 |00:00:00.10 | 36 | 18 |
|* 39 | INDEX UNIQUE SCAN | S_CONTACT_P1 | 10 | 1 | 10 |00:00:00.04 | 26 | 9 |
| 40 | TABLE ACCESS BY INDEX ROWID | S_ADDR_PER | 10 | 1 | 10 |00:00:00.11 | 36 | 20 |
|* 41 | INDEX UNIQUE SCAN | S_ADDR_PER_P1 | 10 | 1 | 10 |00:00:00.04 | 26 | 10 |
| 42 | TABLE ACCESS BY INDEX ROWID | S_ORG_EXT | 10 | 1 | 0 |00:00:00.01 | 0 | 0 |
|* 43 | INDEX UNIQUE SCAN | S_ORG_EXT_U3 | 10 | 1 | 0 |00:00:00.01 | 0 | 0 |
| 44 | TABLE ACCESS BY INDEX ROWID | S_ORG_EXT | 10 | 1 | 0 |00:00:00.01 | 0 | 0 |
|* 45 | INDEX UNIQUE SCAN | S_ORG_EXT_U3 | 10 | 1 | 0 |00:00:00.01 | 0 | 0 |
| 46 | TABLE ACCESS BY INDEX ROWID | S_ORG_EXT | 10 | 1 | 0 |00:00:00.01 | 0 | 0 |
|* 47 | INDEX UNIQUE SCAN | S_ORG_EXT_U3 | 10 | 1 | 0 |00:00:00.01 | 0 | 0 |
| 48 | TABLE ACCESS BY INDEX ROWID | S_ORG_EXT | 10 | 1 | 10 |00:00:00.09 | 46 | 18 |
|* 49 | INDEX UNIQUE SCAN | S_ORG_EXT_U3 | 10 | 1 | 10 |00:00:00.05 | 26 | 9 |
| 50 | TABLE ACCESS BY INDEX ROWID | S_ORG_EXT | 10 | 1 | 10 |00:00:00.09 | 55 | 32 |
|* 51 | INDEX UNIQUE SCAN | S_ORG_EXT_U3 | 10 | 1 | 10 |00:00:00.02 | 26 | 8 |
| 52 | TABLE ACCESS BY INDEX ROWID | S_ORG_EXT_X | 10 | 1 | 10 |00:00:00.13 | 40 | 18 |
|* 53 | INDEX RANGE SCAN | S_ORG_EXT_X_U1 | 10 | 1 | 10 |00:00:00.06 | 30 | 9 |
|* 54 | INDEX UNIQUE SCAN | S_PARTY_P1 | 10 | 1 | 0 |00:00:00.01 | 5 | 0 |
| 55 | TABLE ACCESS BY INDEX ROWID | S_ASSET_BU | 10 | 1 | 10 |00:00:00.18 | 50 | 29 |
|* 56 | INDEX RANGE SCAN | S_ASSET_BU_U1 | 10 | 1 | 10 |00:00:00.11 | 40 | 19 |
| 57 | TABLE ACCESS BY INDEX ROWID | S_ORG_EXT | 10 | 1 | 10 |00:00:00.01 | 36 | 0 |
|* 58 | INDEX UNIQUE SCAN | S_ORG_EXT_U3 | 10 | 1 | 10 |00:00:00.01 | 26 | 0 |
|* 59 | INDEX UNIQUE SCAN | S_PARTY_P1 | 10 | 1 | 10 |00:00:00.01 | 26 | 0 |
| 60 | TABLE ACCESS BY INDEX ROWID | S_ASSET_X | 10 | 1 | 10 |00:00:00.10 | 50 | 20 |
|* 61 | INDEX RANGE SCAN | S_ASSET_X_U1 | 10 | 1 | 10 |00:00:00.03 | 40 | 10 |
| 62 | TABLE ACCESS BY INDEX ROWID | S_ASSET | 10 | 1 | 10 |00:00:00.12 | 46 | 20 |
|* 63 | INDEX UNIQUE SCAN | S_ASSET_P1 | 10 | 1 | 10 |00:00:00.06 | 36 | 10 |
| 64 | TABLE ACCESS BY INDEX ROWID | S_PROD_INT | 10 | 1 | 10 |00:00:00.01 | 26 | 0 |
|* 65 | INDEX UNIQUE SCAN | S_PROD_INT_P1 | 10 | 1 | 10 |00:00:00.01 | 16 | 0 |
Predicate Information (identified by operation id):
23 - filter("T9"."VER_NUM"=:1)
25 - access("T3"."ROW_ID"="T9"."VOD_ID")
27 - access("T14"."CFG_MODEL_ID"="T3"."OBJECT_NUM")
29 - access("T14"."PR_PROD_LN_ID"="T7"."ROW_ID")
31 - access("T14"."CG_PR_CTLG_CAT_ID"="T16"."ROW_ID")
33 - access("T16"."PAR_CAT_ID"="T10"."ROW_ID")
34 - filter((("T23"."PAR_ASSET_ID" IS NULL AND "T23"."SERIAL_NUM" IS NOT NULL) OR ("T23"."X_PHONE_NUMBER" IS NOT NULL AND
"T23"."PAR_ASSET_ID" IS NOT NULL)))
35 - access("T23"."PROD_ID"="T14"."ROW_ID")
37 - access("T23"."ROW_ID"="T8"."PAR_ROW_ID")
39 - access("T23"."OWNER_CON_ID"="T11"."ROW_ID")
41 - access("T23"."PER_ADDR_ID"="T20"."ROW_ID")
43 - access("T23"."RTNG_DLR_ID"="T1"."PAR_ROW_ID")
45 - access("T23"."DLR_ID"="T4"."PAR_ROW_ID")
47 - access("T23"."PREF_SRV_DLR_ID"="T17"."PAR_ROW_ID")
49 - access("T23"."BILL_ACCNT_ID"="T18"."PAR_ROW_ID")
51 - access("T23"."OWNER_ACCNT_ID"="T21"."PAR_ROW_ID")
53 - access("T23"."OWNER_ACCNT_ID"="T6"."PAR_ROW_ID")
54 - access("T23"."PR_CON_ID"="T12"."ROW_ID")
56 - access("T23"."ROW_ID"="T15"."ASSET_ID" AND "T23"."BU_ID"="T15"."BU_ID")
58 - access("T15"."BU_ID"="T5"."PAR_ROW_ID")
59 - access("T15"."BU_ID"="T13"."ROW_ID")
61 - access("T23"."ROW_ID"="T22"."PAR_ROW_ID")
63 - access("T23"."ROOT_ASSET_ID"="T19"."ROW_ID")
65 - access("T19"."PROD_ID"="T2"."ROW_ID")
226 rows selected.
SQL > -
Migrating SQL Plus Scripts to APEX
Hi, all:
I am trying to migrate some sql scripts which generates spool files as reports from sqlplus.
I am trying to use APEX 4.2.1 interactive report pages to provide similar but much powerful functions.
Database version 10.2.0.5.
Seems Apex IR only accept SELECT .... queries for the region source.
But the original scripts used in sqlplus do other things such as create a temporary table,
then query based on this table and generate spool files.
I would like to know is there way to simulate this table creation in APEX before handover
the process to region source query to continue?
I saw APEX sql workshop can create / save / run scripts, I guess somehow I need to call
saved scripts to create temp tables before handover to IR page to do query.
Any suggestions?
Thanks,
JohnYou can indeed not use a temporary table. If you create and fill one in one process, there is no guarantee that the data you inserted will still be there at the moment the IR is rendered (the select against the temp table, in another process/region) due to the connection pooling apex uses. A collection would indeed be the only way. (A normal table does work of course)
-
How to use bind vars in SQL*Plus Script?
I am trying to use a bind var in my script ... does not seem to work ... something along these lines.
variable v_id number;
select max(user_id) into :v_id
from user_id_tbl;
exec trace_user(:v_id);
This is in a UNIX Script - I don't get any errors but the binding is not working - not passing a valid v_id ... Any ideas?For the record a solution is:
variable v_id number;
begin
select max(user_id) into :v_id from user_id_tbl;
end;
exec trace_user(:v_id);
-- CJ -
Hi,
Can you please provide a query which gives top 5 SQLs ordered by Execution time ( i.e Elapsed Time/No of Executions), for one day.
Appreciate your help.
Thanks
SravanHi,
welcome to the forum!
Here is the query:
select sql_id, sum(elapsed_time_delta)/1e6 total_elapsed_seconds, sum(executions_delta) total_executions
from dba_hist_sqlstat st,
dba_hist_snapshot sn
where st.snap_id = sn.snap_id
and sn.begin_interval_time between sysdate-1 and sysdate
group by sql_id
order by 2 desc;Keep in mind that in order to use it you need the diagnostic pack license.
Best regards,
Nikolay
Edited by: Nikolay Savvinov on Aug 24, 2012 8:40 AM (changed from microseconds to seconds) -
I have used fnd_file.put_line(FND_FILE.OUTPUT and fnd_file.put_line(FND_FILE.LOG many times for programs registered as PL/SQL Stored Procedure or used in DB Packages to write to the concurrent manager output and log files. No problem doing that. I have a simple program that I was going to register in Oracle Apps as a SQL*Plus script (instead of creating a DB procedure) that contains a PL/SQL block and will use fnd_file.put_line to write the output so it can be seen from the Concurrent Mgr View Requests. When the script runs the fnd_file.put_line(FND_FILE.OUTPUT... doesn't write to the output (or log) file. I am guessing fnd_file.put_line(FND_FILE.OUTPUT is not available to programs registered as SQL*PLUS.
Is that correct? Am I missing something simple that would allow it to run without creating a DB procedure/package.
I am testing this with a very simple script just to see if I can get something written to the output and log files.
SET SERVEROUTPUT ON
declare
x varchar2(20);
Begin
select 'test'
into x
from dual;
fnd_file.put_line(FND_FILE.LOG,'In the log file');
fnd_file.put_line(FND_FILE.OUTPUT,'In the output file');
end;
Thanks for taking the time to read this and any offers to helpI think you should post it in the relevant Oracle Apps forum and not here. It seems that - you may have some problem regarding any privileges or missing some property which needs to be configure.
Regards.
Satyaki De.
Maybe you are looking for
-
Is it possible to duplicate an item in the project panel with scripts?
Hey all, I'm trying to make a script that will duplicate an item in the project panel. I know you can duplicate an item in a comp, but I'd like to duplicate a project Item...app.project.item(2).duplicate(); Something like that, is it possible with s
-
Query in SQL to display count of all records but where condition is present
Hi All, I have situation where I need to display count of all records all particular period but in where condition type condition has to be present : Please find the below sample data : PERIOD_ID TYPE MV_COUNT IS_FLAG 20110401 AM
-
Hi: This post is for those that have the below listed Atheros adapters, and recently upgraded their routers (usually from a Wireless G to a Wireless N router from 2009 or newer), only to find they cannot connect to the internet anymore. Atheros AR500
-
60D Solved! Go to Solution.
-
How to keep minimized files docked in the place you put them and not at bottom of screen?
I'm using CS3 on Windows. When I minimize a file it automatically goes to the bottom of the screen. How do I get a minimized file to stay where I place it on the screen so that everytime I close the file it will go to the designated place I put it?