Tracing of sql statements
in the debug level normally we can trace the step by step. but how can we trace the sql statements.
In Debug mode
Go to menu Break Poiunts-> Break Point At -> Statement
Give the Break Point At Statement As SELECT
Now you will stop for each and every select in the Debug mode.
In general we use Sql trace.
Similar Messages
-
Tracing / Profiling SQL statements in Sybase
Hi Guys, I would like to capture the SQL statements that have been fired from a web app (bit like SQL Server's profiler). Is there such a tool / facility?Please note that I cannot use dbcc commands like traceon as DBA's wont grant me sa rights (in dev...crazy eh).
Is there any easy way of doing this?
ThanksGeneral comment about MDA monitoring (tools) ...
If the local DBAs don't have any tools for monitoring MDA tables there are a few 3rd party tools that can provide MDA monitoring (ie, little/no programming required by the local DBAs).
Most of these 3rd party tools cost $$ to purchase, and each one has its strengths and weaknesses.
There is one 3rd party tool (that I know of) that is free, highly configurable, and IMHO does a very good job at collecting/presenting MDA data (especially from a historical perspective): ASEMON
I personally:
- use ASEMON for P&T work
- install/configure ASEMON at my clients when a) they don't already have a MDA monitoring capability or b) they want to free up the $$ they're paying for some other 3rd party tool
NOTE: As Mike has pointed out, MDA collections can grow quite large and rather quickly. This is true with ASEMON, too. -
Missingf SQL Statements in v$sqlarea
Hi,
i´m tracing some sql statements and from time to time they disapear very quickly from the shared pool.
i´m looking into v$sqlarea and the funny thing is, i thought "all" historical statments will be copied to dba_hist_sqltext. But thery are missing there too.
Some statments are away after a couple of minutes, but the shared pool is quit large enough.
I had the same problem inside the em (10g) many (historical) statements can´t be seen after a couple of minutes.
Are some other views for that ?
Thanks
Marcoselect * from v$sgastat where name like '%free%'
shared pool ksuloi: long op free list 16
shared pool message pool freequeue 700592
shared pool kghx free lists 19008
shared pool free memory 129955780 <=========== !!!!
shared pool kglsim free obj list 204
shared pool sim kghx free lists 4
shared pool kglsim free heap list 204
large pool free memory 3458568
java pool free memory 4194304
streams pool free memory 8388608 -
I have an application that sends SQL statements to an oracle engine using odbc. Is there a way to trace the SQL statements from the unix server that the oracle engine resides on? I do not want to use the trace function in the ODBC data source administrator.
Thanks,
-AlIdebtified your connect and then set trace for session using
exec dbms_system.SET_EV(SID,SERIAL#,10046,12,'');
10046 is event name and 12 is level.
SID and serial# you will get from v$session
Cheer,
Virag Sharma
http://virag.sharma.googlepages.com/ -
Find start and end execution time of a sql statement?
I am have databases with 10.2.0.3 and 9.2.0.8 on HP UNIX 11i and Windows 200x.
I am not in a position to turn on sql tracing in production environment. Yet, I want to find when a sql statement started executing and when it ended. When I look at v$sql, it has information such FIRST_LOAD_TIME, LAST_LOAD_TIME etc. No where it has information last time statement began execution and when it ended execution.. It shows no of executions, elapsed time etc, but they are cumulative. Is there a way to find individual times (time information each time a sql statement was executed. – its start time, its end time ….)? If I were to write my own program how will I do it?
Along the same line, when an AWR snapshot is shown, does it only include statements executed during that snapshot or it can have statements from the past if they have not been flushed from shared memory. If it only has statements executed in the snapshot period, how does it know when statement began execution?Hi,
For oracle 10g you can use below query to find start and end time, you can see data for last seven days.
select min(to_char(a.sample_time,'DD-MON-YY HH24:MI:SS')) "Start time", max(to_char(a.sample_time,'DD-MON-YY HH24:MI:SS')) "End Time", b.sql_text
from dba_HIST_ACTIVE_SESS_HISTORY a,DBA_HIST_SQLTEXT b where
a.sql_id=b.sql_id
order by 1;
Regards
Jafar -
How to trace the SQL statements executed in a database
I am using Oracle9i Enterprise Edition Release 9.2.0.7.0 - 64bit Production on a sun server and I am not familiar with Oracle but with MS SQL there is a tool called profiler, it allows you to monitor and see what is going on in a specific databases whether it is SQL statement executins or anything else. I have installed the oracle enterpise manager console at my windows client and I tried to look for a tool similar to the profiler in the MS SQL. I tried the TRACE DATA VIEWER and I inputed the login credentials but I don' t actually know the service name and I am getting an error ORA-12514 The TSN listener can not resolve the service name given in the connect descriptor. Therefore, am I on the right road so i have to look for the service name or are there any other ways i can trace the currently executing SQL statement in a specific database. I am really stuck there. I would appreciate if somebody help me out. Thanks
Abdel MoalimAbdel Moalim wrote:
I am using Oracle9i Enterprise Edition Release 9.2.0.7.0 - 64bit Production on a sun server and I am not familiar with Oracle but with MS SQL there is a tool called profiler, it allows you to monitor and see what is going on in a specific databases whether it is SQL statement executins or anything else. I have installed the oracle enterpise manager console at my windows client and I tried to look for a tool similar to the profiler in the MS SQL. I tried the TRACE DATA VIEWER and I inputed the login credentials but I don' t actually know the service name and I am getting an error ORA-12514 The TSN listener can not resolve the service name given in the connect descriptor. Therefore, am I on the right road so i have to look for the service name or are there any other ways i can trace the currently executing SQL statement in a specific database. I am really stuck there. I would appreciate if somebody help me out. Thanks
Abdel MoalimHi
I see others have answered the network connectivity issues, I'll try and address the tracing issue. Your best bet is to review http://www.petefinnigan.com/ramblings/how_to_set_trace.htm for the many ways in which a sessions SQL and indeed other activity can be traced. In version 7 (which I'm guessing is yours from the sid) the only profiler available was tkprof (Trace Kernel Profiler) which will do a good job of analysing your trace file. The trace files themselves are generated on the server in a protected directory so you may need to ask your dba for access to them. There are other profilers around now (I have one which runs in v9 and higher database at http://www.niall.litchfield.dial.pipex.com/SimpleProfiler/SimpleProfiler.html which will analyse your files for example) but tkprof is the start point - or else just reading the trace file in a text editor. There is also a utility written by the Oracle Apps guys trcanalyzer that will do a good job for you. In general the interface is poor compared with the ms utility but the information is deeper and more helpful
Niall Litchfield
http://www.orawin.info/ -
Please help to tune the below query. I have provided following information
1. Query To be tuned
2. Parameter Relevant to Optimizer
3. Explain Plan and AutoTrace Ouput
4. Query traced at Level 8 and Its Tkprof Ouput
5. EXPLAIN PLAN output of DBMS_XPLAN.DISPLAY
INFORMATION 1. SQL QUERY TO BE TUNED
SELECT DISTINCT C.MAN_WIP_T_IN_TS,
C.RCP_NO,
C.WRK_CTR_ID,
C.WTR_FREE_TST_FLG,
A.COMPANY_ID,
A.PROD_ORDER,
A.PART_NO,
A.CARRIER_QTY,
B.PHY_CARID,
C.WIP_SEQ,
A.RCP_NO "CARRIER_RCP"
FROM dbadmintest.PF2_PROD_ORDER_CARRIER A,
PF2_PHYSICAL_CARRIER B,
WORK_IN_PROCESS C
WHERE C.UNIT_TYPE_CD = RTRIM('TL7')
AND C.UNIT_NM = RTRIM('T41')
AND C.WIP_TYPE_CD = 'HANDHELD'
AND C.PHY_CARRIER_SEQ = A.PHY_CARRIER_SEQ
AND A.PHY_CARRIER_SEQ = B.PHY_CARRIER_SEQ
AND ((A.CARRIER_LD_TS <= C.MAN_WIP_T_IN_TS
AND A.CARRIER_UNLD_TS >= C.MAN_WIP_T_IN_TS)
OR ( A.CARRIER_LD_TS <= C.MAN_WIP_T_IN_TS
AND A.CARRIER_UNLD_TS IS NULL))
AND ((A.CARRIER_UNLD_TS >= TO_DATE('2012-01-12 08:03:00', 'YYYY-MM-DD HH24:MI:SS')
AND A.CARRIER_UNLD_TS <= TO_DATE('2012-01-12 10:03:00', 'YYYY-MM-DD HH24:MI:SS'))
OR (A.CARRIER_LD_TS >= TO_DATE('2012-01-12 08:03:00', 'YYYY-MM-DD HH24:MI:SS')
AND A.CARRIER_LD_TS <= TO_DATE('2012-01-12 08:03:00', 'YYYY-MM-DD HH24:MI:SS'))
OR (A.CARRIER_LD_TS <= TO_DATE('2012-01-12 08:03:00', 'YYYY-MM-DD HH24:MI:SS')
AND A.CARRIER_UNLD_TS IS NULL)
OR (A.CARRIER_LD_TS <= TO_DATE('2012-01-12 08:03:00', 'YYYY-MM-DD HH24:MI:SS')
AND A.CARRIER_UNLD_TS >= TO_DATE('2012-01-12 08:03:00', 'YYYY-MM-DD HH24:MI:SS')))
ORDER BY 6,5,1
INFORMATION 2. PARAMETER RELEVANT TO OPTIMIZER
NAME TYPE VALUE
optimizer_dynamic_sampling integer 2
optimizer_features_enable string 10.2.0.4
optimizer_index_caching integer 0
optimizer_index_cost_adj integer 100
optimizer_mode string ALL_ROWS
optimizer_secure_view_merging boolean TRUE
db_file_multiblock_read_count integer 16
cursor_sharing string EXACT
SQL> column sname format a20
column pname format a20
column pval2 format a20
select
sname
, pname
, pval1
, pval2
from sys.aux_stats$;SQL>
SNAME PNAME PVAL1 PVAL2
SYSSTATS_INFO STATUS COMPLETED
SYSSTATS_INFO DSTART 08-25-2009 07:27
SYSSTATS_INFO DSTOP 08-25-2009 07:27
SYSSTATS_INFO FLAGS 1
SYSSTATS_MAIN CPUSPEEDNW 1592.87183
SYSSTATS_MAIN IOSEEKTIM 10
SYSSTATS_MAIN IOTFRSPEED 4096
SYSSTATS_MAIN SREADTIM
SYSSTATS_MAIN MREADTIM
SYSSTATS_MAIN CPUSPEED
SYSSTATS_MAIN MBRC
SYSSTATS_MAIN MAXTHR
SYSSTATS_MAIN SLAVETHR
INFORMATION 3. EXPLAIN PLAN AND AUTOTRACE OUTPUT
Execution Plan
Plan hash value: 850402268
| Id | Operation | Name | Rows | Bytes | Cost (%CPU) | Time |
| 0 | SELECT STATEMENT | | 11 | 1100 | 1568 (1) | 00:00:19 |
| 1 | SORT UNIQUE | | 11 | 1100 | 1567 (1) | 00:00:19 |
|* 2 | HASH JOIN | | 11 | 1100 | 1566 (1) | 00:00:19 |
|* 3 | TABLE ACCESS BY INDEX ROWID | PF2_PROD_ORDER_CARRIER | 5 | 270 | 763 (0) | 00:00:10 |
| 4 | NESTED LOOPS | | 11 | 1001 | 1562 (1) | 00:00:19 |
|* 5 | TABLE ACCESS BY INDEX ROWID | WORK_IN_PROCESS | 2 | 74 | 35 (0) | 00:00:01 |
|* 6 | INDEX RANGE SCAN | WORK_IN_PROCESS_IX2 | 56 | | 3 (0) | 00:00:01 |
|* 7 | INDEX RANGE SCAN | PF2_PROD_ORDER_CARRIER_IX3 | 2361 | | 6 (0) | 00:00:01 |
| 8 | TABLE ACCESS FULL | PF2_PHYSICAL_CARRIER | 1736 | 15624 | 4 (0) | 00:00:01 |
Predicate Information (identified by operation id):
2 - access("A"."PHY_CARRIER_SEQ"="B"."PHY_CARRIER_SEQ")
3 - filter(("A"."CARRIER_UNLD_TS" IS NULL AND "A"."CARRIER_LD_TS"<=TO_DATE(' 2012-01-12 08:03:00',
'syyyy-mm-dd hh24:mi:ss') OR "A"."CARRIER_UNLD_TS">=TO_DATE(' 2012-01-12 08:03:00', 'syyyy-mm-dd
hh24:mi:ss') AND "A"."CARRIER_LD_TS"<=TO_DATE(' 2012-01-12 08:03:00', 'syyyy-mm-dd hh24:mi:ss') OR
"A"."CARRIER_UNLD_TS">=TO_DATE(' 2012-01-12 08:03:00', 'syyyy-mm-dd hh24:mi:ss') AND
"A"."CARRIER_UNLD_TS"<=TO_DATE(' 2012-01-12 10:03:00', 'syyyy-mm-dd hh24:mi:ss') OR
"A"."CARRIER_LD_TS"=TO_DATE(' 2012-01-12 08:03:00', 'syyyy-mm-dd hh24:mi:ss')) AND
("A"."CARRIER_LD_TS"<="C"."MAN_WIP_T_IN_TS" AND "A"."CARRIER_UNLD_TS">="C"."MAN_WIP_T_IN_TS" OR
"A"."CARRIER_UNLD_TS" IS NULL AND "A"."CARRIER_LD_TS"<="C"."MAN_WIP_T_IN_TS"))
5 - filter("C"."WIP_TYPE_CD"='HANDHELD' AND "C"."PHY_CARRIER_SEQ" IS NOT NULL)
6 - access("C"."UNIT_TYPE_CD"='TL7' AND "C"."UNIT_NM"='T41')
7 - access("C"."PHY_CARRIER_SEQ"="A"."PHY_CARRIER_SEQ")
filter("A"."PHY_CARRIER_SEQ" IS NOT NULL)
Statistics
1 recursive calls
0 db block gets
13525998 consistent gets
7024 physical reads
0 redo size
1758 bytes sent via SQL*Net to client
492 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
14 rows processed
INFORMATION 4. QUERY TRACES AT LEVEL 8 AND TKPROF OUTPUT
TKPROF: Release 10.2.0.4.0 - Production on Wed Jan 18 01:48:53 2012
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Trace file: ././ppf2_ora_5439924.trc
Sort options: default
count = number of times OCI procedure was executed
cpu = cpu time in seconds executing
elapsed = elapsed time in seconds executing
disk = number of physical reads of buffers from disk
query = number of buffers gotten for consistent read
current = number of buffers gotten in current mode (usually for update)
rows = number of rows processed by the fetch or execute call
SELECT DISTINCT C.MAN_WIP_T_IN_TS,
C.RCP_NO,
C.WRK_CTR_ID,
C.WTR_FREE_TST_FLG,
A.COMPANY_ID,
A.PROD_ORDER,
A.PART_NO,
A.CARRIER_QTY,
B.PHY_CARID,
C.WIP_SEQ,
A.RCP_NO "CARRIER_RCP"
FROM PF2_PROD_ORDER_CARRIER A,
PF2_PHYSICAL_CARRIER B,
WORK_IN_PROCESS C
WHERE C.UNIT_TYPE_CD = RTRIM('TL7')
AND C.UNIT_NM = RTRIM('T41')
AND C.WIP_TYPE_CD = 'HANDHELD'
AND C.PHY_CARRIER_SEQ = A.PHY_CARRIER_SEQ
AND A.PHY_CARRIER_SEQ = B.PHY_CARRIER_SEQ
AND ((A.CARRIER_LD_TS <= C.MAN_WIP_T_IN_TS
AND A.CARRIER_UNLD_TS >= C.MAN_WIP_T_IN_TS)
OR ( A.CARRIER_LD_TS <= C.MAN_WIP_T_IN_TS
AND A.CARRIER_UNLD_TS IS NULL))
AND ((A.CARRIER_UNLD_TS >= TO_DATE('2012-01-12 08:03:00', 'YYYY-MM-DD HH24:MI:SS')
AND A.CARRIER_UNLD_TS <= TO_DATE('2012-01-12 10:03:00', 'YYYY-MM-DD HH24:MI:SS'))
OR (A.CARRIER_LD_TS >= TO_DATE('2012-01-12 08:03:00', 'YYYY-MM-DD HH24:MI:SS')
AND A.CARRIER_LD_TS <= TO_DATE('2012-01-12 08:03:00', 'YYYY-MM-DD HH24:MI:SS'))
OR (A.CARRIER_LD_TS <= TO_DATE('2012-01-12 08:03:00', 'YYYY-MM-DD HH24:MI:SS')
AND A.CARRIER_UNLD_TS IS NULL)
OR (A.CARRIER_LD_TS <= TO_DATE('2012-01-12 08:03:00', 'YYYY-MM-DD HH24:MI:SS')
AND A.CARRIER_UNLD_TS >= TO_DATE('2012-01-12 08:03:00', 'YYYY-MM-DD HH24:MI:SS')))
ORDER BY 6,5,1
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 219.55 294.41 14030 13523455 0 14
total 4 219.55 294.41 14030 13523455 0 14
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: SYS
Rows Row Source Operation
14 SORT UNIQUE (cr=13523455 pr=14030 pw=0 time=294417731 us)
14 HASH JOIN (cr=13523455 pr=14030 pw=0 time=294416444 us)
14 TABLE ACCESS BY INDEX ROWID PF2_PROD_ORDER_CARRIER (cr=13523440 pr=14030 pw=0 time=292675360 us)
98184018 NESTED LOOPS (cr=270067 pr=9028 pw=0 time=294901120 us)
12128 TABLE ACCESS BY INDEX ROWID WORK_IN_PROCESS (cr=9842 pr=8788 pw=0 time=20479883 us)
15241 INDEX RANGE SCAN WORK_IN_PROCESS_IX2 (cr=49 pr=48 pw=0 time=54577 us)(object id 65980)
98171889 INDEX RANGE SCAN PF2_PROD_ORDER_CARRIER_IX3 (cr=260225 pr=240 pw=0 time=808956 us)(object id 65990)
1736 TABLE ACCESS FULL PF2_PHYSICAL_CARRIER (cr=15 pr=0 pw=0 time=83 us)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to client 3 0.00 0.00
SQL*Net message from client 3 0.00 0.00
db file sequential read 14030 0.47 43.56
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
total 2 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0
Parsing user id: SYS
OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
Parse 2 0.00 0.00 0 0 0 0
Execute 2 0.00 0.00 0 0 0 0
Fetch 2 219.55 294.41 14030 13523455 0 14
total 6 219.55 294.41 14030 13523455 0 14
Misses in library cache during parse: 0
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to client 3 0.00 0.00
SQL*Net message from client 3 0.00 0.00
db file sequential read 14030 0.47 43.56
OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
Parse 0 0.00 0.00 0 0 0 0
Execute 0 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
total 0 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0
2 user SQL statements in session.
0 internal SQL statements in session.
2 SQL statements in session.
Trace file: ././ppf2_ora_5439924.trc
Trace file compatibility: 10.01.00
Sort options: default
1 session in tracefile.
2 user SQL statements in trace file.
0 internal SQL statements in trace file.
2 SQL statements in trace file.
2 unique SQL statements in trace file.
14137 lines in trace file.
294 elapsed seconds in trace file.
INFORMATION 5. EXPLAIN PLAN OUTPUT OF DBMS_XPLAN.DISPLAY
SQL> select * from table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST'));
PLAN_TABLE_OUTPUT
SQL_ID 1z1cccq5kxt11, child number 0
SELECT /*+ gather_plan_statistics */ DISTINCT C.MAN_WIP_T_IN_TS, C.RCP_NO, C.WRK_CTR_ID, C.WTR_FREE_TST_FLG,
A.COMPANY_ID, A.PROD_ORDER, A.PART_NO, A.CARRIER_QTY, B.PHY_CARID, C.WIP_SEQ, A.RCP_NO "CARRIER_RCP"
FROM PF2_PROD_ORDER_CARRIER A, PF2_PHYSICAL_CARRIER B, WORK_IN_PROCESS C
WHERE C.UNIT_TYPE_CD = RTRIM('TL7') AND C.UNIT_NM = RTRIM('T41') AND C.WIP_TYPE_CD ='HANDHELD'
AND C.PHY_CARRIER_SEQ = A.PHY_CARRIER_SEQ AND A.PHY_CARRIER_SEQ = B.PHY_CARRIER_SEQ
AND ((A.CARRIER_LD_TS <=C.MAN_WIP_T_IN_TS AND A.CARRIER_UNLD_TS >= C.MAN_WIP_T_IN_TS) OR
( A.CARRIER_LD_TS <= C.MAN_WIP_T_IN_TS AND A.CARRIER_UNLD_TS IS NULL)) AND ((A.CARRIER_UNLD_TS >= TO_DATE('2012-01-12
08:03:00', 'YYYY-MM-DD HH24:MI:SS') AND A.CARRIER_UNLD_TS<= TO
Plan hash value: 850402268
| Id | Operation | Name | Starts |E-Rows | A-Rows |A-Time | Buffers | Reads |OMem |1Mem | Used-Mem |
| 1 | SORT UNIQUE | | 1 | 11 | 14 |00:05:41.48 | 13M | 6571 | 2048 | 2048 | 2048 (0) |
|* 2 | HASH JOIN | | 1 | 11 | 14 |00:05:41.48 | 13M | 6571 | 807K | 807K | 614K (0) |
|* 3 | TABLE ACCESS BY INDEX ROWID | PF2_PROD_ORDER_CARRIER | 1 | 5 | 14 |00:05:39.89 | 13M | 6571 | | | |
| 4 | NESTED LOOPS | | 1 | 11 | 98M |00:04:55.08 | 270K | 6569 | | | |
|* 5 | TABLE ACCESS BY INDEX ROWID | WORK_IN_PROCESS | 1 | 2 | 12130 |00:00:13.15 | 9845 | 6569 | | | |
|* 6 | INDEX RANGE SCAN | WORK_IN_PROCESS_IX2 | 1 | 56 | 15244 |00:00:00.06 | 49 | 45 | | | |
|* 7 | INDEX RANGE SCAN | PF2_PROD_ORDER_CARRIER_IX3 | 12130 | 2361 | 98M |00:00:00.92 | 260K | 0 | | | |
| 8 | TABLE ACCESS FULL | PF2_PHYSICAL_CARRIER | 1 | 1736 | 1736 |00:00:00.01 | 15 | 0 | | | |
Predicate Information (identified by operation id):
2 - access("A"."PHY_CARRIER_SEQ"="B"."PHY_CARRIER_SEQ")
3 - filter(((("A"."CARRIER_UNLD_TS" IS NULL AND "A"."CARRIER_LD_TS"<=TO_DATE(' 2012-01-12 08:03:00', 'syyyy-mm-dd hh24:mi:ss')) OR
("A"."CARRIER_UNLD_TS">=TO_DATE(' 2012-01-12 08:03:00', 'syyyy-mm-dd hh24:mi:ss') AND "A"."CARRIER_LD_TS"<=TO_DATE(' 2012-01-12 08:03:00',
'syyyy-mm-dd hh24:mi:ss')) OR ("A"."CARRIER_UNLD_TS">=TO_DATE(' 2012-01-12 08:03:00', 'syyyy-mm-dd hh24:mi:ss') AND
"A"."CARRIER_UNLD_TS"<=TO_DATE(' 2012-01-12 10:03:00', 'syyyy-mm-dd hh24:mi:ss')) OR "A"."CARRIER_LD_TS"=TO_DATE(' 2012-01-12 08:03:00',
'syyyy-mm-dd hh24:mi:ss')) AND (("A"."CARRIER_LD_TS"<="C"."MAN_WIP_T_IN_TS" AND "A"."CARRIER_UNLD_TS">="C"."MAN_WIP_T_IN_TS") OR
("A"."CARRIER_UNLD_TS" IS NULL AND "A"."CARRIER_LD_TS"<="C"."MAN_WIP_T_IN_TS"))))
5 - filter(("C"."WIP_TYPE_CD"='HANDHELD' AND "C"."PHY_CARRIER_SEQ" IS NOT NULL))
6 - access("C"."UNIT_TYPE_CD"='TL7' AND "C"."UNIT_NM"='T41')
7 - access("C"."PHY_CARRIER_SEQ"="A"."PHY_CARRIER_SEQ")
filter("A"."PHY_CARRIER_SEQ" IS NOT NULL)
41 rows selected.
Regards
RahulRahul, post your question on the SQL and PL/SQL forum PL/SQL. This forum is for Oracle Berkeley DB not Oracle Database.
Thanks,
Andrei -
This SQL statement always in Top Activity, with PX Deq Credit: send blkd
Hi gurus,
The following SQL statement is always among the Top Activity. I can see the details in Enerprise manager that it suffers from PX Deq Credit: send blkd
This is the statement:
SELECT S.Product, S.WH_CODE, S.RACK, S.BATCH, S.EXP_DATE, FLOOR(Qty_Beg) QtyBeg_B,
ROUND(f_convert_qty(S.PRODUCT, Qty_Beg-FLOOR(Qty_Beg), P.UOM_K ), 0) QtyBeg_K,
FLOOR(Qty_In) QtyIn_B, ROUND(f_convert_qty(S.PRODUCT, Qty_In-FLOOR(Qty_In), P.UOM_K), 0) QtyIn_K,
FLOOR(Qty_Out) QtyOut_B, ROUND(f_convert_qty(S.PRODUCT, Qty_Out-FLOOR(Qty_Out), P.UOM_K ), 0) QtyOut_K,
FLOOR(Qty_Adj) QtyAdj_B, ROUND(f_convert_qty(S.PRODUCT, Qty_Adj-FLOOR(Qty_Adj), P.UOM_K ), 0) QtyAdj_K,
FLOOR(Qty_End) QtyEnd_B, ROUND(f_convert_qty(S.PRODUCT, Qty_End-FLOOR(Qty_End), P.UOM_K ), 0) QtyEnd_K,
S.LOC_CODE
FROM V_STOCK_DETAIL S
JOIN PRODUCTS P ON P.PRODUCT = S.PRODUCT
WHERE S.Product = :pProduct AND S.WH_CODE = :pWhCode AND S.LOC_CODE = :pLocCode;The statement is invoked by our front end (web based app) for a browse table displayed on a web page. The result can be 10 to 8000. It is used to display the current stock availability for a particular product in a particular warehouse. The stock availability it self is kept in a View : V_Stock_Detail
These are the parameters relevant to the optimizer:
SQL> show parameter user_dump_dest
user_dump_dest string /u01/app/oracle/admin/ITTDB/udump
SQL> show parameter optimizer
_optimizer_cost_based_transformation string OFF
optimizer_dynamic_sampling integer 2
optimizer_features_enable string 10.2.0.3
optimizer_index_caching integer 0
optimizer_index_cost_adj integer 100
optimizer_mode string ALL_ROWS
optimizer_secure_view_merging boolean TRUE
SQL> show parameter db_file_multi
db_file_multiblock_read_count integer 16
SQL> show parameter db_block_size column sname format a20 column pname format a20
db_block_size integer 8192Here is the output of EXPLAIN PLAN:
SQL> explain plan for
SELECT S.Product, S.WH_CODE, S.RACK, S.BATCH, S.EXP_DATE, FLOOR(Qty_Beg) QtyBeg_B,
ROUND(f_convert_qty(S.PRODUCT, Qty_Beg-FLOOR(Qty_Beg), P.UOM_K ), 0) QtyBeg_K,
FLOOR(Qty_In) QtyIn_B, ROUND(f_convert_qty(S.PRODUCT, Qty_In-FLOOR(Qty_In), P.UOM_K), 0) QtyIn_K,
FLOOR(Qty_Out) QtyOut_B, ROUND(f_convert_qty(S.PRODUCT, Qty_Out-FLOOR(Qty_Out), P.UOM_K ), 0) QtyOut_K,
FLOOR(Qty_Adj) QtyAdj_B, ROUND(f_convert_qty(S.PRODUCT, Qty_Adj-FLOOR(Qty_Adj), P.UOM_K ), 0) QtyAdj_K,
FLOOR(Qty_End) QtyEnd_B, ROUND(f_convert_qty(S.PRODUCT, Qty_End-FLOOR(Qty_End), P.UOM_K ), 0) QtyEnd_K,
S.LOC_CODE
FROM V_STOCK_DETAIL S
JOIN PRODUCTS P ON P.PRODUCT = S.PRODUCT
WHERE S.Product = :pProduct AND S.WH_CODE = :pWhCode AND S.LOC_CODE = :pLocCode
Explain complete.
Elapsed: 00:00:00:31
SQL> select * from table(dbms_xplan.display)
PLAN_TABLE_OUTPUT
Plan hash value: 3252950027
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | TQ |IN-OUT| PQ
Distrib |
| 0 | SELECT STATEMENT | | 1 | 169 | 6 (17)| 00:00:01 | | |
|
| 1 | PX COORDINATOR | | | | | | | |
|
| 2 | PX SEND QC (RANDOM) | :TQ10003 | 1 | 169 | 6 (17)| 00:00:01 | Q1,03 | P->S | QC
(RAND) |
| 3 | HASH GROUP BY | | 1 | 169 | 6 (17)| 00:00:01 | Q1,03 | PCWP |
|
| 4 | PX RECEIVE | | 1 | 169 | 6 (17)| 00:00:01 | Q1,03 | PCWP |
|
| 5 | PX SEND HASH | :TQ10002 | 1 | 169 | 6 (17)| 00:00:01 | Q1,02 | P->P | HA
SH |
| 6 | HASH GROUP BY | | 1 | 169 | 6 (17)| 00:00:01 | Q1,02 | PCWP |
|
| 7 | NESTED LOOPS OUTER | | 1 | 169 | 5 (0)| 00:00:01 | Q1,02 | PCWP |
|
| 8 | MERGE JOIN CARTESIAN | | 1 | 119 | 4 (0)| 00:00:01 | Q1,02 | PCWP |
|
| 9 | SORT JOIN | | | | | | Q1,02 | PCWP |
|
| 10 | NESTED LOOPS | | 1 | 49 | 4 (0)| 00:00:01 | Q1,02 | PCWP |
|
| 11 | BUFFER SORT | | | | | | Q1,02 | PCWC |
|
| 12 | PX RECEIVE | | | | | | Q1,02 | PCWP |
|
| 13 | PX SEND BROADCAST | :TQ10000 | | | | | | S->P | BR
OADCAST |
|* 14 | INDEX RANGE SCAN | PRODUCTS_IDX2 | 1 | 25 | 2 (0)| 00:00:01 | | |
|
| 15 | PX BLOCK ITERATOR | | 1 | 24 | 2 (0)| 00:00:01 | Q1,02 | PCWC |
|
|* 16 | MAT_VIEW ACCESS FULL | MV_CONVERT_UOM | 1 | 24 | 2 (0)| 00:00:01 | Q1,02 | PCWP |
|
| 17 | BUFFER SORT | | 1 | 70 | 2 (0)| 00:00:01 | Q1,02 | PCWP |
|
| 18 | BUFFER SORT | | | | | | Q1,02 | PCWC |
|
| 19 | PX RECEIVE | | 1 | 70 | 4 (0)| 00:00:01 | Q1,02 | PCWP |
|
| 20 | PX SEND BROADCAST | :TQ10001 | 1 | 70 | 4 (0)| 00:00:01 | | S->P | BR
OADCAST |
|* 21 | TABLE ACCESS BY INDEX ROWID| STOCK | 1 | 70 | 4 (0)| 00:00:01 | | |
|
|* 22 | INDEX RANGE SCAN | STOCK_PK | 1 | | 2 (0)| 00:00:01 | | |
|
|* 23 | TABLE ACCESS BY INDEX ROWID | MV_TRANS_STOCK | 1 | 50 | 3 (0)| 00:00:01 | Q1,02 | PCWP |
|
|* 24 | INDEX RANGE SCAN | MV_TRANS_STOCK_IDX1 | 1 | | 2 (0)| 00:00:01 | Q1,02 | PCWP |
|
Predicate Information (identified by operation id):
14 - access("P"."PRODUCT"=:PPRODUCT)
16 - filter("CON"."PRODUCT"=:PPRODUCT)
21 - filter("STOCK"."LOC_CODE"=:PLOCCODE)
22 - access("STOCK"."PRODUCT"=:PPRODUCT AND "STOCK"."WH_CODE"=:PWHCODE)
23 - filter("STS"(+)='N')
24 - access("PRODUCT"(+)=:PPRODUCT AND "WH_CODE"(+)=:PWHCODE AND "LOC_CODE"(+)=:PLOCCODE AND "RACK"(+)="STOCK"."RACK" AND
"BATCH"(+)="STOCK"."BATCH" AND "EXP_DATE"(+)="STOCK"."EXP_DATE")
42 rows selected.
Elapsed: 00:00:00:06Here is the output of SQL*Plus AUTOTRACE including the TIMING information:
SQL> SELECT S.Product, S.WH_CODE, S.RACK, S.BATCH, S.EXP_DATE, FLOOR(Qty_Beg) QtyBeg_B,
ROUND(f_convert_qty(S.PRODUCT, Qty_Beg-FLOOR(Qty_Beg), P.UOM_K ), 0) QtyBeg_K,
FLOOR(Qty_In) QtyIn_B, ROUND(f_convert_qty(S.PRODUCT, Qty_In-FLOOR(Qty_In), P.UOM_K), 0) QtyIn_K,
FLOOR(Qty_Out) QtyOut_B, ROUND(f_convert_qty(S.PRODUCT, Qty_Out-FLOOR(Qty_Out), P.UOM_K ), 0) QtyOut_K,
FLOOR(Qty_Adj) QtyAdj_B, ROUND(f_convert_qty(S.PRODUCT, Qty_Adj-FLOOR(Qty_Adj), P.UOM_K ), 0) QtyAdj_K,
FLOOR(Qty_End) QtyEnd_B, ROUND(f_convert_qty(S.PRODUCT, Qty_End-FLOOR(Qty_End), P.UOM_K ), 0) QtyEnd_K,
S.LOC_CODE
FROM V_STOCK_DETAIL S
JOIN PRODUCTS P ON P.PRODUCT = S.PRODUCT
WHERE S.Product = :pProduct AND S.WH_CODE = :pWhCode AND S.LOC_CODE = :pLocCode
Execution Plan
0 SELECT STATEMENT Optimizer Mode=ALL_ROWS 1 169 6
1 0 PX COORDINATOR
2 1 PX SEND QC (RANDOM) SYS.:TQ10003 1 169 6 :Q1003 P->S QC (RANDOM)
3 2 HASH GROUP BY 1 169 6 :Q1003 PCWP
4 3 PX RECEIVE 1 169 6 :Q1003 PCWP
5 4 PX SEND HASH SYS.:TQ10002 1 169 6 :Q1002 P->P HASH
6 5 HASH GROUP BY 1 169 6 :Q1002 PCWP
7 6 NESTED LOOPS OUTER 1 169 5 :Q1002 PCWP
8 7 MERGE JOIN CARTESIAN 1 119 4 :Q1002 PCWP
9 8 SORT JOIN :Q1002 PCWP
10 9 NESTED LOOPS 1 49 4 :Q1002 PCWP
11 10 BUFFER SORT :Q1002 PCWC
12 11 PX RECEIVE :Q1002 PCWP
13 12 PX SEND BROADCAST SYS.:TQ10000 S->P BROADCAST
14 13 INDEX RANGE SCAN ITT_NEW.PRODUCTS_IDX2 1 25 2
15 10 PX BLOCK ITERATOR 1 24 2 :Q1002 PCWC
16 15 MAT_VIEW ACCESS FULL ITT_NEW.MV_CONVERT_UOM 1 24 2 :Q1002 PCWP
17 8 BUFFER SORT 1 70 2 :Q1002 PCWP
18 17 BUFFER SORT :Q1002 PCWC
19 18 PX RECEIVE 1 70 4 :Q1002 PCWP
20 19 PX SEND BROADCAST SYS.:TQ10001 1 70 4 S->P BROADCAST
21 20 TABLE ACCESS BY INDEX ROWID ITT_NEW.STOCK 1 70 4
22 21 INDEX RANGE SCAN ITT_NEW.STOCK_PK 1 2
23 7 TABLE ACCESS BY INDEX ROWID ITT_NEW.MV_TRANS_STOCK 1 50 3 :Q1002 PCWP
24 23 INDEX RANGE SCAN ITT_NEW.MV_TRANS_STOCK_IDX1 1 2 :Q1002 PCWP
Statistics
570 recursive calls
0 physical write total IO requests
0 physical write total multi block requests
0 physical write total bytes
0 physical writes direct temporary tablespace
0 java session heap live size max
0 java session heap object count
0 java session heap object count max
0 java session heap collected count
0 java session heap collected bytes
83 rows processed
Elapsed: 00:00:03:24
SQL> disconnect
Commit complete
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, OLAP and Data Mining optionsThe TKPROF output for this statement looks like the following:
TKPROF: Release 10.2.0.3.0 - Production on Thu Apr 23 12:39:29 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Trace file: ittdb_ora_9566_mytrace1.trc
Sort options: default
count = number of times OCI procedure was executed
cpu = cpu time in seconds executing
elapsed = elapsed time in seconds executing
disk = number of physical reads of buffers from disk
query = number of buffers gotten for consistent read
current = number of buffers gotten in current mode (usually for update)
rows = number of rows processed by the fetch or execute call
SELECT S.Product, S.WH_CODE, S.RACK, S.BATCH, S.EXP_DATE, FLOOR(Qty_Beg) QtyBeg_B,
ROUND(f_convert_qty(S.PRODUCT, Qty_Beg-FLOOR(Qty_Beg), P.UOM_K ), 0) QtyBeg_K,
FLOOR(Qty_In) QtyIn_B, ROUND(f_convert_qty(S.PRODUCT, Qty_In-FLOOR(Qty_In), P.UOM_K), 0) QtyIn_K,
FLOOR(Qty_Out) QtyOut_B, ROUND(f_convert_qty(S.PRODUCT, Qty_Out-FLOOR(Qty_Out), P.UOM_K ), 0) QtyOut_K,
FLOOR(Qty_Adj) QtyAdj_B, ROUND(f_convert_qty(S.PRODUCT, Qty_Adj-FLOOR(Qty_Adj), P.UOM_K ), 0) QtyAdj_K,
FLOOR(Qty_End) QtyEnd_B, ROUND(f_convert_qty(S.PRODUCT, Qty_End-FLOOR(Qty_End), P.UOM_K ), 0) QtyEnd_K,
S.LOC_CODE
FROM V_STOCK_DETAIL S
JOIN PRODUCTS P ON P.PRODUCT = S.PRODUCT
WHERE S.Product = :pProduct AND S.WH_CODE = :pWhCode AND S.LOC_CODE = :pLocCode
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.04 0.12 0 10 4 0
Fetch 43 0.05 2.02 0 73 0 83
total 45 0.10 2.15 0 83 4 83
Misses in library cache during parse: 1
Misses in library cache during execute: 1
Optimizer mode: ALL_ROWS
Parsing user id: 164
Rows Row Source Operation
83 PX COORDINATOR (cr=83 pr=0 pw=0 time=2086576 us)
0 PX SEND QC (RANDOM) :TQ10003 (cr=0 pr=0 pw=0 time=0 us)
0 HASH GROUP BY (cr=0 pr=0 pw=0 time=0 us)
0 PX RECEIVE (cr=0 pr=0 pw=0 time=0 us)
0 PX SEND HASH :TQ10002 (cr=0 pr=0 pw=0 time=0 us)
0 HASH GROUP BY (cr=0 pr=0 pw=0 time=0 us)
0 NESTED LOOPS OUTER (cr=0 pr=0 pw=0 time=0 us)
0 MERGE JOIN CARTESIAN (cr=0 pr=0 pw=0 time=0 us)
0 SORT JOIN (cr=0 pr=0 pw=0 time=0 us)
0 NESTED LOOPS (cr=0 pr=0 pw=0 time=0 us)
0 BUFFER SORT (cr=0 pr=0 pw=0 time=0 us)
0 PX RECEIVE (cr=0 pr=0 pw=0 time=0 us)
0 PX SEND BROADCAST :TQ10000 (cr=0 pr=0 pw=0 time=0 us)
1 INDEX RANGE SCAN PRODUCTS_IDX2 (cr=2 pr=0 pw=0 time=62 us)(object id 135097)
0 PX BLOCK ITERATOR (cr=0 pr=0 pw=0 time=0 us)
0 MAT_VIEW ACCESS FULL MV_CONVERT_UOM (cr=0 pr=0 pw=0 time=0 us)
0 BUFFER SORT (cr=0 pr=0 pw=0 time=0 us)
0 BUFFER SORT (cr=0 pr=0 pw=0 time=0 us)
0 PX RECEIVE (cr=0 pr=0 pw=0 time=0 us)
0 PX SEND BROADCAST :TQ10001 (cr=0 pr=0 pw=0 time=0 us)
83 TABLE ACCESS BY INDEX ROWID STOCK (cr=78 pr=0 pw=0 time=1635 us)
83 INDEX RANGE SCAN STOCK_PK (cr=4 pr=0 pw=0 time=458 us)(object id 135252)
0 TABLE ACCESS BY INDEX ROWID MV_TRANS_STOCK (cr=0 pr=0 pw=0 time=0 us)
0 INDEX RANGE SCAN MV_TRANS_STOCK_IDX1 (cr=0 pr=0 pw=0 time=0 us)(object id 143537)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
PX Deq: Join ACK 17 0.00 0.00
PX qref latch 2 0.00 0.00
PX Deq Credit: send blkd 72 1.95 2.00
PX Deq: Parse Reply 26 0.01 0.01
SQL*Net message to client 43 0.00 0.00
PX Deq: Execute Reply 19 0.00 0.01
SQL*Net message from client 43 0.00 0.04
PX Deq: Signal ACK 12 0.00 0.00
enq: PS - contention 1 0.00 0.00
********************************************************************************The DBMS_XPLAN.DISPLAY_CURSOR output:
SQL> select * from table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST'))
PLAN_TABLE_OUTPUT
SQL_ID 402b8st7vt6ku, child number 2
SELECT /*+ gather_plan_statistics */ S.Product, S.WH_CODE, S.RACK, S.BATCH, S.EXP_DATE, FLOOR(Qty_Beg) QtyBeg_B,
ROUND(f_convert_qty(S.PRODUCT, Qty_Beg-FLOOR(Qty_Beg), P.UOM_K ), 0) QtyBeg_K, FLOOR(Qty_In) QtyIn_B, ROUND(f_convert_qty(S.P
RODUCT,
Qty_In-FLOOR(Qty_In), P.UOM_K), 0) QtyIn_K, FLOOR(Qty_Out) QtyOut_B, ROUND(f_convert_qty(S.PRODUCT, Qty_Out-FLOOR(Qty_Out), P
.UOM_K ),
0) QtyOut_K, FLOOR(Qty_Adj) QtyAdj_B, ROUND(f_convert_qty(S.PRODUCT, Qty_Adj-FLOOR(Qty_Adj), P.UOM_K ), 0) QtyAdj_K,
FLOOR(Qty_End) QtyEnd_B, ROUND(f_convert_qty(S.PRODUCT, Qty_End-FLOOR(Qty_End), P.UOM_K ), 0) QtyEnd_K, S.LOC_CODE FROM
V_STOCK_DETAIL S JOIN PRODUCTS P ON P.PRODUCT = S.PRODUCT WHERE S.Product = :pProduct AND S.WH_CODE = :pWhCode AND S.LOC
_CODE =
:pLocCode
Plan hash value: 3252950027
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | OMem |
1Mem | Used-Mem |
| 1 | PX COORDINATOR | | 1 | | 83 |00:00:02.25 | 83 | |
| |
| 2 | PX SEND QC (RANDOM) | :TQ10003 | 0 | 21 | 0 |00:00:00.01 | 0 | |
| |
| 3 | HASH GROUP BY | | 0 | 21 | 0 |00:00:00.01 | 0 | |
| |
| 4 | PX RECEIVE | | 0 | 21 | 0 |00:00:00.01 | 0 | |
| |
| 5 | PX SEND HASH | :TQ10002 | 0 | 21 | 0 |00:00:00.01 | 0 | |
| |
| 6 | HASH GROUP BY | | 0 | 21 | 0 |00:00:00.01 | 0 | |
| |
| 7 | NESTED LOOPS OUTER | | 0 | 21 | 0 |00:00:00.01 | 0 | |
| |
| 8 | MERGE JOIN CARTESIAN | | 0 | 21 | 0 |00:00:00.01 | 0 | |
| |
| 9 | SORT JOIN | | 0 | | 0 |00:00:00.01 | 0 | 73728 |
73728 | |
| 10 | NESTED LOOPS | | 0 | 1 | 0 |00:00:00.01 | 0 | |
| |
| 11 | BUFFER SORT | | 0 | | 0 |00:00:00.01 | 0 | 73728 |
73728 | |
| 12 | PX RECEIVE | | 0 | | 0 |00:00:00.01 | 0 | |
| |
| 13 | PX SEND BROADCAST | :TQ10000 | 0 | | 0 |00:00:00.01 | 0 | |
| |
|* 14 | INDEX RANGE SCAN | PRODUCTS_IDX2 | 1 | 1 | 1 |00:00:00.01 | 2 | |
| |
| 15 | PX BLOCK ITERATOR | | 0 | 1 | 0 |00:00:00.01 | 0 | |
| |
|* 16 | MAT_VIEW ACCESS FULL | MV_CONVERT_UOM | 0 | 1 | 0 |00:00:00.01 | 0 | |
| |
| 17 | BUFFER SORT | | 0 | 21 | 0 |00:00:00.01 | 0 | 73728 |
73728 | |
| 18 | BUFFER SORT | | 0 | | 0 |00:00:00.01 | 0 | 73728 |
73728 | |
| 19 | PX RECEIVE | | 0 | 21 | 0 |00:00:00.01 | 0 | |
| |
| 20 | PX SEND BROADCAST | :TQ10001 | 0 | 21 | 0 |00:00:00.01 | 0 | |
| |
|* 21 | TABLE ACCESS BY INDEX ROWID| STOCK | 1 | 21 | 83 |00:00:00.01 | 78 | |
| |
|* 22 | INDEX RANGE SCAN | STOCK_PK | 1 | 91 | 83 |00:00:00.01 | 4 | |
| |
|* 23 | TABLE ACCESS BY INDEX ROWID | MV_TRANS_STOCK | 0 | 1 | 0 |00:00:00.01 | 0 | |
| |
|* 24 | INDEX RANGE SCAN | MV_TRANS_STOCK_IDX1 | 0 | 1 | 0 |00:00:00.01 | 0 | |
| |
Predicate Information (identified by operation id):
14 - access("P"."PRODUCT"=:PPRODUCT)
16 - access(:Z>=:Z AND :Z<=:Z)
filter("CON"."PRODUCT"=:PPRODUCT)
21 - filter("STOCK"."LOC_CODE"=:PLOCCODE)
22 - access("STOCK"."PRODUCT"=:PPRODUCT AND "STOCK"."WH_CODE"=:PWHCODE)
23 - filter("STS"='N')
24 - access("PRODUCT"=:PPRODUCT AND "WH_CODE"=:PWHCODE AND "LOC_CODE"=:PLOCCODE AND "RACK"="STOCK"."RACK" AND "BATCH"="STOCK"."B
ATCH" AND
"EXP_DATE"="STOCK"."EXP_DATE")
53 rows selected.
Elapsed: 00:00:00:12I'm looking forward for suggestions how to improve the performance of this statement.
Thank you very much,
xtantoxtanto wrote:
Hi sir,
How to prevent the query from doing parallel query ?
Because as you see actually I am not issuing any Parallel hints in the query.
Thank you,
xtantoKristanto,
there are a couple of points to consider:
1. Your SQL*Plus version seems to be outdated. Please use a SQL*Plus version that corresponds to your database version. E.g. the AUTOTRACE output is odd.
2. I would suggest to repeat your exercise using serial execution (the plan, the autotrace, the tracing). You can disable parallel queries by issuing this in your session:
ALTER SESSION DISABLE PARALLEL QUERY;
This way the output of the tools is much more meaningful, however you might get a different execution plan, therefore the results might not be representative for your parallel execution.
3. The function calls might pose a problem. If they are, one possible damage limitation has been provided by hoek. Even better would be then to replace the PL/SQL function with equivalent plain SQL. However since you say that it generates not too many rows it might not harm here too much. You can check the impact of the functions by running a similar query but omitting the function calls.
4. The parallel execution plan contains a MERGE JOIN CARTESIAN operation which could be an issue if the estimates of the optimizer are incorrect. If the serial execution still uses this operation the TKPROF and DBMS_XPLAN.DISPLAY_CURSOR output will reveal whether this is a problem or not.
5. The execution of the statement seems to take on 2-3 seconds in your tests. Is this in the right ballpark? If yes, why should this statement then be problematic? How often does it get executed?
6. The statement uses bind variables, so you might have executions that use different execution plans depending on the bind values passed when the statement got optimized. You can use DBMS_XPLAN.DISPLAY_CURSOR using NULL as "child_number" parameter or DBMS_XPLAN.DISPLAY_AWR (if you have a AWR license) to check if you have multiple execution plans for the statement. Please note that older versions might have already been aged out of the shared pool, so the AWR repository might be a more reliable source (but only if the statement has been sampled).
7. You have disabled cost based transformations: "_optimizer_cost_based_transformation" = OFF. Why?
Regards,
Randolf
Oracle related stuff blog:
http://oracle-randolf.blogspot.com/
SQLTools++ for Oracle (Open source Oracle GUI for Windows):
http://www.sqltools-plusplus.org:7676/
http://sourceforge.net/projects/sqlt-pp/ -
How to get the real SQL statement from a preparedstatement?
Hi,
I am trying to log the actual SQL sent to database by the preparedStatement. Since the original SQL I used to prepare the statement has a lot of "?" in it, after setting all the parameters in the preparedStatement, I want to get the final SQL statement executed. Is there a way to get it? Probably the SQL will depend on different drivers.
Thanks in advance.Thanks, changhsu. I tried the tracing technique. But it only prints out the original SQL statement sent to the preparedStatement. The following is part of the log file:
======================================================================
--------NetDirect JSQLConnect Version:2.2708--------
2002-04-10 14:23:54.818 (1) Connection attempt number 1 Connection ID:1 for host:perseus
2002-04-10 14:23:55.429 (1) JSQLConnect(2.2708) Trial license - expires on:Thu Apr 25 17:47:32 CDT 2002, unlimited connections
2002-04-10 14:23:55.449 (2) Connection allocated from pool ID:2
2002-04-10 14:23:55.72 (2) [Thread[Thread-6,5,main], IO:88cb4, Dbc:1346]] SELECT SHARED_DRIVES FROM EPM_PREFS WHERE PRODUCT='PE'
2002-04-10 14:23:57.913 (2) Connection closed and returned to connection pool ID:2
2002-04-10 14:23:58.193 (3) Connection attempt number 2 Connection ID:3 for host:perseus database:epm20 SQL6.5:false
2002-04-10 14:23:58.203 (3) [Thread[Thread-6,5,main], IO:88cb3, Dbc:1347]] use epm20 set quoted_identifier,ansi_null_dflt_on,ansi_padding on set textsize 2147483647 set transaction isolation level read committed set implicit_transactions off
2002-04-10 14:24:00.356 (4) Connection allocated from pool ID:4
2002-04-10 14:24:01.168 (4) [Not Loged In@localhost, IO:88cb2, Dbc:1347]] PreparedStatement::prepare stmt:SELECT PASSWD FROM RESOURCE_INFO WHERE USER_ID=? AND DELETE_FLG IS NULL
2002-04-10 14:24:01.448 (4) [Not Loged In@localhost, IO:88cb2, Dbc:1347]] RPC:sp_prepare
2002-04-10 14:24:01.488 (4) [Not Loged In@localhost, IO:88cb2, Dbc:1347]] RPC:sp_execute
=======================================================================
I did not try to trace in SQL Server 7. I will have to find out how to do that first.
Thanks again. -
Executing multiple SQL statements fails using ODBC
Executing multiple SQL statements will fail with error 'ORA-00911 invalid character' when connecting to an Oracle database using ODBC driver version 8.01.07.00.
When I use either my application or the Oracle ODBC Test client utility connecting using ODBC driver version 8.01.07.00 I can only get a single CALL statement (as shown below) to execute:
CALL BHInsert (TO_DATE('2003.07.23 10:04:28','YYYY.MM.DD HH24:MI:SS'),'BATCH_ID','1:CLS_FRENCHVANILLA-1','
','Event File
Name','\\KILLIANS\BATCHCTL\SampleDemo1\JOURNALS\1.evt','','AREA1','','','','','','1','','','','','',' ','');
When I try to execute the following string with multiple CALL statements (as shown below) it fails with the following error being returned - ORA-00911: invalid character
CALL BHInsert (TO_DATE('2003.07.23 10:04:28','YYYY.MM.DD HH24:MI:SS'),'BATCH_ID','1:CLS_FRENCHVANILLA-1','
','Event File
Name','\\KILLIANS\BATCHCTL\SampleDemo1\JOURNALS\1.evt','','AREA1','','','','','','1','','','','','',' ','');
CALL BHInsert (TO_DATE('2003.07.23 10:04:28','YYYY.MM.DD
HH24:MI:SS'),'BATCH_ID','1:CLS_FRENCHVANILLA-1','Version','Recipe Header','1.0','','AREA1',' ','
','','','','1','','','','','',' ','');
CALL BHInsert (TO_DATE('2003.07.23 10:04:28','YYYY.MM.DD
HH24:MI:SS'),'BATCH_ID','1:CLS_FRENCHVANILLA-1','Version Date','Recipe Header','5/18/2001 1:28:32
PM','','AREA1',' ',' ','','','','1','','','','','',' ','');
CALL BHInsert (TO_DATE('2003.07.23
10:04:28','YYYY.MM.DD HH24:MI:SS'),'BATCH_ID','1:CLS_FRENCHVANILLA-1','Author','Recipe Header','Mark
Shepard','','AREA1',' ',' ','','','','1','','','','','',' ','');
I've tried adding a line feed in addition to the space at the end of each call but that doesn't seem to help. Also have tried unsuccessfully to change the seperator used between each call using various valid continuation characters.
Executing multiple CALL statements from within Oracle's SQL Worksheet connecting as the same user and password, as my application executes successfully. However when I try this from within the Oracle ODBC test client, it fails with the same ORA-00911 error that I'm seeing in my application.
I'm currently trying the more recent ODBC drivers, however any ideas or suggestions would be greatly appreciated.Can you take the begin ... end block and run it using SQL*Plus?
I can't think of any documentation that would specifically answer this question. I'm sure if you read & absorbed the ODBC Programmers Reference (2000+ pages) you'd be able to find out, but I don't know of a quick way to find out.
You can enable SQL*Net tracing. There are a fair number of options for enabling this tracing-- http://tahiti.oracle.com has all the Oracle manuals online, which should give you enough info to configure exactly what you want.
I would suggest, however, that you look into more performant/ scalable alternatives rather than going too far down this path. A block with lots of SQL statements with literals isn't going to make your database happy even if you get it to work.
Justin -
Info abt rolled back sql statements
hi friends,
Is there any way to check / get the rolled back sql statements in oracle for a specific time frame.
eg: say at 10AM i have issued an insert statement and i have rolled it back. Now at 11AM if i want the list of rolled back statements, is there any way to check it ?
What to do if tracing is also not enabled ?
Thanks
Ramyatry logminer.
-
How can i use one SQL statement to solve problem?
How can i use one SQL statement to solve the question below?
For a Table named A, there is a column named F(char type).
Now select all the records where F like '%00' and update their F value to '%01'
Just one SQL statement.Do not use PL/SQL block.
How to do that?
Thanks.What is the data volume for this table?
Do you expect lots of rows to have '%00' as their value?
Following two statements come to mind. Other experts would be able to provide better alternatives:
If you have index on SUBSTR(f, 2):
UPDATE A
SET f = SUBSTR(f,
1,
length(f) - 2) || '01'
WHERE substr(f,
-2) = '00';If most of the rows have pattern '%00':
UPDATE A
SET f = SUBSTR(f,
1,
length(f) - 2) ||
DECODE(SUBSTR(f,
-2),
'00',
'01',
SUBSTR(f,
-2)); -
How do I use SQL statements to perform calculations with form fields????
Please help!!! I don't know how to use a SQL statement within my APEX form......
My form is below. The user will enter the values in the form. Click on Submit. Then we need to run a SQL select statement with those values.
Our form looks like this:
Start_Date ____________
Per_Period ____________
Period ____________
[Submit Button]
The user will enter these 3 values in the form.
This is an example of an user providing the values:
Start_Date 03/14/08_______
Per_Period $200.00________
Period 4____________
[Submit Button]
Then they will click the Submit Button.
The SQL statement (BELOW) returns output based on the users selections:
START_DATE PER_PERIOD PERIOD
14-MAR-2008 00:00 200 Week 1 of 4
21-MAR-2008 00:00 200 Week 2 of 4
28-MAR-2008 00:00 200 Week 3 of 4
04-APR-2008 00:00 200 Week 4 of 4
Total 800
This is the full text of the SQL that makes the output above:
with criteria as (select to_date('03/14/08', 'mm/dd/rr') as start_date,
4 as periods,
'Week' as period,
200 per_period from dual),
periods as (select 'Week' period, 7 days, 0 months from dual
union all select 'BiWeek', 14, 0 from dual
union all select 'Month', 0, 1 from dual
union all select 'ByMonth', 0, 2 from dual
union all select 'Quarter', 0, 3 from dual
union all select 'Year', 0 , 12 from dual
t1 as (
select add_months(start_date,months*(level-1))+days*(level-1) start_date,
per_period,
c.period||' '||level||' of '||c.periods period
from criteria c join periods p on c.period = p.period
connect by level <= periods)
select case grouping(start_date)
when 1 then 'Total'
else to_char(start_date)
end start_date,
sum(per_period) per_period,
period
from t1
group by rollup ((start_date, period))
THANKS VERY MUCH!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!You're just doing a parameterized report, where the input fields are your parameters.
Check out the Advanced Tutorial titled Parameterized Report here:
http://download.oracle.com/docs/cd/E10513_01/doc/appdev.310/e10497/rprt_query.htm#BGBEEBJA
Good luck,
Stew -
HOW TO: Post a SQL statement tuning request - template posting
This post is not a question, but similar to Rob van Wijk's "When your query takes too long ..." post should help to improve the quality of the requests for SQL statement tuning here on OTN.
On the OTN forum very often tuning requests about single SQL statements are posted, but the information provided is rather limited, and therefore it's not that simple to provide a meaningful advice. Instead of writing the same requests for additional information over and over again I thought I put together a post that describes how a "useful" post for such a request should look like and what information it should cover.
I've also prepared very detailed step-by-step instructions how to obtain that information on my blog, which can be used to easily gather the required information. It also covers again the details how to post the information properly here, in particular how to use the \ tag to preserve formatting and get a fixed font output:
http://oracle-randolf.blogspot.com/2009/02/basic-sql-statement-performance.html
So again: This post here describes how a "useful" post should look like and what information it ideally covers. The blog post explains in detail how to obtain that information.
In the future, rather than requesting the same additional information and explaining how to obtain it, I'll simply refer to this HOW TO post and the corresponding blog post which describes in detail how to get that information.
*Very important:*
Use the \ tag to enclose any output that should have its formatting preserved as shown below.
So if you want to use fixed font formatting that preserves the spaces etc., do the following:
\ This preserves formatting
\And it will look like this:
This preserves formatting
. . .Your post should cover the following information:
1. The SQL and a short description of its purpose
2. The version of your database with 4-digits (e.g. 10.2.0.4)
3. Optimizer related parameters
4. The TIMING and AUTOTRACE output
5. The EXPLAIN PLAN output
6. The TKPROF output snippet that corresponds to your statement
7. If you're on 10g or later, the DBMS_XPLAN.DISPLAY_CURSOR output
The above mentioned blog post describes in detail how to obtain that information.
Your post should have a meaningful subject, e.g. "SQL statement tuning request", and the message body should look similar to the following:
*-- Start of template body --*
The following SQL statement has been identified to perform poorly. It currently takes up to 10 seconds to execute, but it's supposed to take a second at most.
This is the statement:
select
from
t_demo
where
type = 'VIEW'
order by
id;It should return data from a table in a specific order.
The version of the database is 11.1.0.7.
These are the parameters relevant to the optimizer:
SQL>
SQL> show parameter optimizer
NAME TYPE VALUE
optimizer_capture_sql_plan_baselines boolean FALSE
optimizer_dynamic_sampling integer 2
optimizer_features_enable string 11.1.0.7
optimizer_index_caching integer 0
optimizer_index_cost_adj integer 100
optimizer_mode string ALL_ROWS
optimizer_secure_view_merging boolean TRUE
optimizer_use_invisible_indexes boolean FALSE
optimizer_use_pending_statistics boolean FALSE
optimizer_use_sql_plan_baselines boolean TRUE
SQL>
SQL> show parameter db_file_multi
NAME TYPE VALUE
db_file_multiblock_read_count integer 8
SQL>
SQL> show parameter db_block_size
NAME TYPE VALUE
db_block_size integer 8192
SQL>
SQL> show parameter cursor_sharing
NAME TYPE VALUE
cursor_sharing string EXACT
SQL>
SQL> column sname format a20
SQL> column pname format a20
SQL> column pval2 format a20
SQL>
SQL> select
2 sname
3 , pname
4 , pval1
5 , pval2
6 from
7 sys.aux_stats$;
SNAME PNAME PVAL1 PVAL2
SYSSTATS_INFO STATUS COMPLETED
SYSSTATS_INFO DSTART 01-30-2009 16:25
SYSSTATS_INFO DSTOP 01-30-2009 16:25
SYSSTATS_INFO FLAGS 0
SYSSTATS_MAIN CPUSPEEDNW 494,397
SYSSTATS_MAIN IOSEEKTIM 10
SYSSTATS_MAIN IOTFRSPEED 4096
SYSSTATS_MAIN SREADTIM
SYSSTATS_MAIN MREADTIM
SYSSTATS_MAIN CPUSPEED
SYSSTATS_MAIN MBRC
SYSSTATS_MAIN MAXTHR
SYSSTATS_MAIN SLAVETHR
13 rows selected.Here is the output of EXPLAIN PLAN:
SQL> explain plan for
2 -- put your statement here
3 select
4 *
5 from
6 t_demo
7 where
8 type = 'VIEW'
9 order by
10 id;
Explained.
Elapsed: 00:00:00.01
SQL>
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 1390505571
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 60 | 0 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| T_DEMO | 1 | 60 | 0 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | IDX_DEMO | 1 | | 0 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - access("TYPE"='VIEW')
14 rows selected.Here is the output of SQL*Plus AUTOTRACE including the TIMING information:
SQL> rem Set the ARRAYSIZE according to your application
SQL> set autotrace traceonly arraysize 100
SQL> select
2 *
3 from
4 t_demo
5 where
6 type = 'VIEW'
7 order by
8 id;
149938 rows selected.
Elapsed: 00:00:02.21
Execution Plan
Plan hash value: 1390505571
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 60 | 0 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| T_DEMO | 1 | 60 | 0 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | IDX_DEMO | 1 | | 0 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - access("TYPE"='VIEW')
Statistics
0 recursive calls
0 db block gets
149101 consistent gets
800 physical reads
196 redo size
1077830 bytes sent via SQL*Net to client
16905 bytes received via SQL*Net from client
1501 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
149938 rows processed
SQL>
SQL> disconnect
Disconnected from Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing optionsThe TKPROF output for this statement looks like the following:
TKPROF: Release 11.1.0.7.0 - Production on Mo Feb 23 10:23:08 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Trace file: orcl11_ora_3376_mytrace1.trc
Sort options: default
count = number of times OCI procedure was executed
cpu = cpu time in seconds executing
elapsed = elapsed time in seconds executing
disk = number of physical reads of buffers from disk
query = number of buffers gotten for consistent read
current = number of buffers gotten in current mode (usually for update)
rows = number of rows processed by the fetch or execute call
select
from
t_demo
where
type = 'VIEW'
order by
id
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 1501 0.53 1.36 800 149101 0 149938
total 1503 0.53 1.36 800 149101 0 149938
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 88
Rows Row Source Operation
149938 TABLE ACCESS BY INDEX ROWID T_DEMO (cr=149101 pr=800 pw=0 time=60042 us cost=0 size=60 card=1)
149938 INDEX RANGE SCAN IDX_DEMO (cr=1881 pr=1 pw=0 time=0 us cost=0 size=0 card=1)(object id 74895)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to client 1501 0.00 0.00
db file sequential read 800 0.05 0.80
SQL*Net message from client 1501 0.00 0.69
********************************************************************************The DBMS_XPLAN.DISPLAY_CURSOR output:
SQL> -- put your statement here
SQL> -- use the GATHER_PLAN_STATISTICS hint
SQL> -- if you're not using STATISTICS_LEVEL = ALL
SQL> select /*+ gather_plan_statistics */
2 *
3 from
4 t_demo
5 where
6 type = 'VIEW'
7 order by
8 id;
149938 rows selected.
Elapsed: 00:00:02.21
SQL>
SQL> select * from table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST'));
PLAN_TABLE_OUTPUT
SQL_ID d4k5acu783vu8, child number 0
select /*+ gather_plan_statistics */ * from t_demo
where type = 'VIEW' order by id
Plan hash value: 1390505571
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | Reads |
| 0 | SELECT STATEMENT | | 1 | | 149K|00:00:00.02 | 149K| 1183 |
| 1 | TABLE ACCESS BY INDEX ROWID| T_DEMO | 1 | 1 | 149K|00:00:00.02 | 149K| 1183 |
|* 2 | INDEX RANGE SCAN | IDX_DEMO | 1 | 1 | 149K|00:00:00.02 | 1880 | 383 |
Predicate Information (identified by operation id):
2 - access("TYPE"='VIEW')
20 rows selected.I'm looking forward for suggestions how to improve the performance of this statement.
*-- End of template body --*
I'm sure that if you follow these instructions and obtain the information described, post them using a proper formatting (don't forget about the \ tag) you'll receive meaningful advice very soon.
So, just to make sure you didn't miss this point:Use proper formatting!
If you think I missed something important in this sample post let me know so that I can improve it.
Regards,
Randolf
Oracle related stuff blog:
http://oracle-randolf.blogspot.com/
SQLTools++ for Oracle (Open source Oracle GUI for Windows):
http://www.sqltools-plusplus.org:7676/
http://sourceforge.net/projects/sqlt-pp/Alex Nuijten wrote:
...you missed the proper formatting of the Autotrace section ;-)Alex,
can't reproduce, does it still look unformatted? Or are you simply kidding? :-)
Randolf
PS: Just noticed that it actually sometimes doesn't show the proper formatting although the code tags are there. Changing to the \ tag helped in this case, but it seems to be odd.
Edited by: Randolf Geist on Feb 23, 2009 11:28 AM
Odd behaviour of forum software -
SQl statement cause extreme Portal log growth
Our Portal server log file is growing very fast (30 - 50 Mb per minute). When examining the log file we see that the log file does contain only the error messages:
#1.5#00096BF521750058005A9CA900001E480003E80BD8A2C263#1099562506968#/System/Database/sql/jdbc/common#sap.com/irj#com.sap.sql.jdbc.common.StatementAnalyzerImpl#Guest#18####655e44612e4811d9b41300096bf52175#Thread[ThreadPool-Dispatcher,5,SAPEngine_Application_Thread[impl:3]_Group]##0#0#Error#1#com.sap.sql.jdbc.common.StatementAnalyzerImpl#Java#com.sap.sql.jdbc.common_1123#com.sap.sql.log.OpenSQLResourceBundle#The SQL statement "" contains the semantics error[s]: #2#SELECT MIN("ID"),"PRIORITY" FROM "KMC_TQ_QUEUE" WHERE "NAMESPACE_HASH" = ? AND "NAMESPACE" = ? AND "TASK_STATE" = 1 GROUP BY "PRIORITY" ORDER BY 2 DESC#type check error: the expression >>"NAMESPACE"<< (LONGVARCHAR) is not comparable and must not be used with "="
This message occurs more than 500 times per log file. It has something to do with Knowledge management, but we cannot find anything that triggers this sql statement.
Any ideas?
Noel Hendrikx & Pascal RijnartSAP tells us in reaction to our customer message:
"The table's definition is correct. What has to be changed is the
computed type for field NAMESPACE and the generated file for the table.
As I wrote before, if you make any change in the field NAMESPACE the
new computation is started (so change the description which has no
effect on the table's version on the database). Make the change and
save the table in the SapNetWeaver Developer Studio. You will then
see that the field's JDBC-type changes to VARCHAR.
Choose 'Create archive' for Dictionary Project the table belongs to
and deploy the sda on the database. Both can be done in the studio."
Can anyone tell us what to do now?
Noel Hendrikx
Maybe you are looking for
-
I-tunes says 'The ipod "*****" is synced with another i-tunes library
I just downloaded itunes 7.3.1.3. I plugged in my ipod nano (software 1.3.1) and first of all, my library had vanished (I managed to get that back) but now when I click on my ipod in itunes I get the above message (subject line), and the next bit of
-
[solved] transferring (migrate) my install to a new hard drive
I did some googling, but could not find a howto which replicated my situation... I bought a new SSD for my netbook and I am wondering what the best way to go about transferring my arch install to it without going thru an install-from-scratch would be
-
Won't play in home audio system
My wife's 5th generation Nano will not play through my home audio system connected with a monster rca cable at the system end and connects to the ipod through the ipod connector (no sound comes through my system, only sound is from the nano speaker).
-
Video problems in DVD SP burned DVDs - FCP frame rate issue?
Please help! We have a 99 minute feature project that we shot in 24p (NOT 24pa) on a DVX100, imported the footage into FCP in 29.97fps, and edited in a 24fps sequence timeline. When we exported the sequence through compressor (DVD High Quality 120min
-
When safari kills your machine memory
Hi I would like to know how can i AVOID all the "background" operations that safari does when i start safari and even other times Is the top sites cache? Can i disable top sites? The only plugin i have is clicktoflash Unfortunately i dont see any opt