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?
Thanks
General 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.
Similar Messages
-
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. -
How to use a Sybase table in Oracle SQL statement?
How to use a Sybase table in Oracle SQL statement?
Sybase version : 11.9.2.4
Oracle version : 10.2.05
Thanks.user12088323 wrote:
How to use a Sybase table in Oracle SQL statement?
Sybase version : 11.9.2.4
Oracle version : 10.2.05
Thanks.Any Oracle client connected to the Oracle database can access Sybase data through the <font style="background-color: #FFFFCC">Database Gateway for Sybase</font> (it requires an additional license) or the <font style="background-color: #FFFFCC">Database gateway for ODBC</font> (it's free).
The Oracle client and the Oracle database can reside on different machines. The gateway accepts connections only from the Oracle database.
A connection to the gateway is established through a database link when it is first used in an Oracle session. In this context, a connection refers to the connection between the Oracle database and the gateway. The connection remains established until the Oracle session ends. Another session or user can access the same database link and get a distinct connection to the gateway and Sybase database.
Database links are active for the duration of a gateway session. If you want to close a database link during a session, you can do so with the ALTER SESSION statement.
To access the Sybase server, you must create a <font style="background-color: #FFFFCC">database link</font>. A public database link is the most common of database links.
SQL> CREATE PUBLIC DATABASE LINK dblink CONNECT TO
2 "user" IDENTIFIED BY "password" USING 'tns_name_entry';
--dblink is the complete database link name.
--tns_name_entry specifies the Oracle Net connect descriptor specified in the tnsnames.ora file that identifies the gatewayAfter the database link is created you can verify the connection to the Sybase database, as follows:
SQL> SELECT * FROM DUAL@dblink;
Configuring Oracle Database Gateway for Sybase
<font style="background-color: #FFFFCC">{message:id=10649126}</font> -
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 -
Hi All,
we have a problem with profile option "Initialization SQL Statement - Custom". we have set this at user level. after some time, we have cleared the profile option value for this user.
But we can still see the generated trace files are getting updated. we did checked this trc files from path returned from below query.
select name, value
from v$parameter
where name like 'user_dump_dest';
Please help us on how to resolve this issue. we are using Oracle Apps R 12.1.2 version.
Thanks in advance
RaghavaBefore logging out we suspect that he closed the browser instead of logout link.
What if you make the user logout, can you reproduce the issue then?
We have verified the profile options for this user and found that value is cleared for profile Initialization SQL Statement - Custom.
How do you know that the files were generated for this user and because of this profile option? Have you verified profile options for all users at all level?
Thanks,
Hussein -
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/ -
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/ -
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 -
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/ -
SQL STATEMENT , PLEASE HELP
Hi,
I want some help in writing a SQL Query .Its besically a hierarchical query. Let me lay down the table structure first to explain my requirements better.
PORP_TABLE(NODE_LEVEL int, WBS_ID int, WBS_NUMBER varchar(60), LFT int,RGT int)
SELECT NODE_LEVEL, WBS_ID, LFT,RGT FROM PROPOSAL_WBS PW WHERE PROPOSAL_REV_ID = 7000
(SAMPLE DATA)
NODE WBS
LEVEL WBS_ID NUMBER LFT RGT
0 7055 ROOT 1 24
1 7056 1 2 5
1 7088 2 6 9
2 7057 1.1 3 4
2 7089 2.1 7 8
2 7091 3.1 11 14
2 7103 3.2 15 16
2 7105 4.1 19 20
1 7090 3 10 17
3 7092 3.1.1 12 13
1 7104 4 18 23
2 7106 4.2 21 22
ALLOCATION_DETAIL( WBS_ID int, COST_ID int, PERIOD Date, AMOUNT Float)
sample data
WBS_ID , COST_ID , PERIOD , AMOUNT
7057 100 01-jan-2005 5000
7057 100 01-feb-2005 2000
7057 100 01-mar-2005 1000
7057 100 01-apr-2005 6000
7057 100 01-may-2005 3000
7057 100 01-jun-2005 45000
7106 100 01-mar-2005 8000
7106 100 01-apr-2005 7000
7106 100 01-may-2005 9000
Now the PORP_TABLE has got the parents and childs. Only the leaf nodes in the hierarchy has the values stored in the ALLOCATION_DETAIL table. Now here is the scenario
In the example 7055 is the root WBS . The Leaf WBS are the one with max extension in the wbs number ( in this case it is 1.1, 2.1, 3.1.1, 3.2, 4.1 and 4.2)
Now the Starting period for each leaf node in the ALLOCATION_TABLE could be differrent . What that means is WBS 1.1 could start in Jan -2003 and WBS 3.1 Could be Jul-2005 . So the ending perios are also differrent for differrent WBS . Some can span 2 years some can 5 years.
So how to write a query so it retrieves the value for all the Wbs starting from the MIN ( PERIOD ) upto the MAX(PERIOD), and it should roll up also. Now there is No connect by Prior or any analytic functions available for this . THIS NEEDS TO BE DONE ONLY THROUGH TRADITIONAL SQL STATEMENT . And NO DB FUNCTIONS CAN BE USED .
Now if the WBS is a parent node then it should have the sum of all its child nodes for the COST category.
SO THE RESULT SET SHOULD BRING LIKE THIS
WBS_NUMBER, PERIOD_NUMER, COST_CATEGORY , AMOUNT
ROOT
1
1.1
2
2.1
3
3.1
3.1.1
3.2
4
4.1
4.2
......Thanks for all your thoughtfull replies and feedbacks. Yes it is in Sybase platform . Though I have been woking all along in Oracle , Unfortunately this one is in Sybase, and no the customer cant and wont move to Oracle. So I have to work with it . And if you want to see the table structure . Here are they :
CREATE TABLE PROPOSAL_WBS (
BURDEN_CENTER_ID numeric(18,0) NULL,
START_DATE datetime NULL,
END_DATE datetime NULL,
WBS_ID int NOT NULL,
MODIFIED_DATE datetime NULL,
CREATED_DATE datetime NULL,
MODIFIED_BY varchar(127) NULL,
CREATED_BY varchar(127) NULL,
FEE_PERCENT float NULL,
PROPOSAL_REV_ID int NOT NULL,
PARENT_WBS_ID int NULL,
NAME varchar(127) NULL,
COMMENT varchar(255) NULL,
TARGET_COST float NULL,
MONTHS_REMAINING int NULL,
DEFAULT_STAFF_FTE float NULL,
ANNUAL_GRA_SALARY float NULL,
NUMBER_OF_GRA int NULL,
MANAGEMENT_ADJUSTMENT_TOTAL float NULL,
MA_UNALLOCATED_FUNDS float NULL,
FEE_TOTAL float NULL,
FEE_UNALLOCATED_FUNDS float NULL,
TRAVEL_COMMENTS varchar(255) NULL,
ODC_COMMENTS varchar(255) NULL,
SORT_ORDER int NULL,
LFT int NULL,
RGT int NULL,
NODE_LEVEL int NULL,
WBS_NUMBER varchar(50) NOT NULL,
TOTAL_COST float NULL,
TOTAL_COST_PLUS_FEE float NULL,
PER_MILE_COST float NULL,
PER_DIEM float NULL,
TAX_RATE float NULL,
RENTAL_CAR_PER_DAY_COST float NULL,
TAXI_PER_TRIP_COST float NULL,
CONSTRAINT PK_PROPOSAL_WBS PRIMARY KEY(WBS_ID)
CREATE TABLE PROPOSAL_WBS_ALLOC_DETAIL (
WBS_ID int NOT NULL,
OBJECT_CODE_ID numeric(18,0) NOT NULL,
PERIOD_NUMBER int NOT NULL,
ALLOCATION_AMOUNT float NULL,
PERIOD_YEAR datetime NULL,
CONSTRAINT PK_PROPOSAL_WBS_AD PRIMARY KEY(WBS_ID,OBJECT_CODE_ID,PERIOD_NUMBER)
CREATE TABLE WBS_PERIOD (
PERIOD_NUMBER int NOT NULL
CREATE VIEW WBS_COST_CAT AS
SELECT PROPOSAL_WBS.PROPOSAL_REV_ID,
PROPOSAL_WBS.WBS_ID,
PROPOSAL_WBS.NAME, PROPOSAL_WBS.SORT_ORDER,
PROPOSAL_WBS.NODE_LEVEL, PROPOSAL_WBS.WBS_NUMBER,
CODES.CODE_ID COST_CATEGORY, CODES.CODE_NAME COST_CAT_NAME
FROM PROPOSAL_WBS, CODES
CREATE TABLE CODES (
CODE_ID numeric(18,0) NOT NULL,
CODE_VALUE varchar(254) NULL,
CODE_NAME varchar(254) NULL,
CODE_TYPE numeric(18,0) NULL,
CODE_PARENT_ID numeric(18,0) NULL,
CONSTRAINT PK_CODE_ID PRIMARY KEY(CODE_ID)
So let me explain little bit more . The WBSs are categorized into two differrent types. One as INPUT and the second one as NON INPUT. Now assme the the WBS in a tree structure . So only the LEAF WBSs will have the AMOUNT and they are the INPUT WBSs and all non leaf WBSs are NON INPUT. Now lets say there are 5 LEAF WBSs. Each LEAF WBS will have differrent start period ex: WBS 1.1 starts in January 2003 and goes for 48 periods . WBS 2.1 starts in November 2003 and goes for 35 periods . WBS 3.1 starts in March 2004 and goes for 52 periods. and so on .
Now as there is no Allocation Amount entry for all other WBSs except the LEAF WBSs. So how do I get the roll up . For example if you imagine the parent of WBS 1.1 is WBS 1 , and the parent of WBS 2.1 is WBS 2 and the Parent of WBS 3.1 is WBS 3 , and the parent for WBS 1, WBS 2, WBS 3 is "ROOT WBS". As I said there is no entry for WBS 1, WBS 2 , WBS 3 and the "ROOT WBS". So how do I have a roll up of the Leaf WBS data for their parent WBSs.
Now if u think of the data in a matrix report, the WBSs and the COST CATEGORY will be the row values, the Period Numbers will the column values and the Allocation Amount will be the cross values. so lets say the WBS 1 has got two leaf nodes, WBS 1.1 and WBS 1.2 then WBS 1 will have the summed amount for each period starting the minumum period of the two of its leaf nodes and for all the cost categories of both the leaf nodes. and the "ROOT WBS" will have all the cost categories of al the Leaf nodes . for all the periods , period wise. -
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. -
I am using Sybase as my back end database. I need help on my SQL statement regarding datetime. The datetime is store as a 9 digit integer in the database (...I believe it is a Decimal(30,6) format, let me know if I am wrong).
If I do this, "select * from mytable;" It works out fine (except I don't know what the date means e.g. 998919534)
If I do this, "select * from mytable where datetime_col < '9/5/2002' ; I got an error. I even tried '9/5/02 11:00 000 am' but it didn't help.
How do I specify a date or datetime in my query?
Thanks in advance.I execute the sql statement
select * from mytable where datetim_col < convert(datetime, '3/4/2002', 101) ;
I got mix result. I got an error message "cannot convert 10375584 to a date.
Yet, he statistics window of the I-sql says
"estimated 493 rows in query (I/O estimate 87)
PLan> mytable (seq)"
It looks like I my the SQL statement is correct and then the system can't display it in the Data window.
Any thought ? -
How to monitor worst performing sql statements
Hi,
I am new to oracle 9i release 2. I come from the Windows world, where we used sql server.
When we performanced tested our product, we always monitor the worst performaning sql statement using the sql profiler. At the end of a 24 hour test, the profiler will list the sql statement with the longest execution time. What is the equivalent Oracle 9i tools that will allow me to monitor the worst performaning sql during a test that lasts between 10 to 24 hours?
Thanks,
Paul0alBesides statspack and OEM you have a few other options.
If an SQL statement had been identified as performing poorly or a job that you can extract the SQL from then you have the option of explaining all the SQL statements and just reviewing the plans for reasonableness. You can also trace actual execution of the task or individual statemnts (alter session set sql_trace = true for basic 10046 event).
When the SQL has not been identified in advance you can query the shared pool SQL areas for SQL statements that have relatively high physical, logical, or combined IO counts. Then you can perform tuning activities for these statements.
HTH -- Mark D Powell -- -
Alternate for oracle statement in sybase
What is the alternate for the following oracle statement in sybase:
insert /*+ APPEND */ into MYTABLE nologging
I need to bulk insert into MYTABLE (in sybase) reading from a CSV file or another database. More than 0.4 million records.
I am using Java as a programming language.let me get this straight:
1) you're asking a SYBASE question
2) and using Java as your language
And this is
1) Oracle forum
2) SQL and PL/SQL is the language here
I think you're asking your question in the wrong place.
Maybe you are looking for
-
Tds report generation showing error
hi experts , in printing of tds certificate showing error . "no data selected for printing " mess no:8i 000 the problem is comming when i maintained tds certifate no configaration . without that tds form printing is working ? please help me in this i
-
Connect String for the front end app to access Lite Database in the Client
Hi, I have been using an app developed in VB.net for accessing the Oracle Lite Database from the client machine. Can anyone please help me out how to set the Connect String in the config file of my front end app to access the Oracle Lite Database fro
-
Broadband novice needs help & advice
Hi, I am new to this forum and looking for help. I have a BT Home Hub (plugged into master bt socket) and connect to it via my laptop wirelessly. Our printer also connects in wirelessly. We have slow broadband speeds generally (130mbps top). Our phon
-
Move license to new computer Acrobat 7
We have a licence that was on a pc that has died. I need to install the application on a new pc. The SN for the Acrobat 7 product is: [REMOVED] Do I need to do anything special or will the install just work when I enter the entire SN
-
Special function in output type
Hi Sap Gurus, I am using special function ( 8 ) as medium of sending in my output which is defined for delivery. If i try to process this output with dispatch time 3 ( Send application with own transaction ) its getting processed. But if i try with o