Query started taking longer time with SQL*Net message from dblink
Hi,
Since Yesterday we started see one query which normally used to take 3 min but now it started taking 70 min after a small change do the query instead of accessing view we started accessing directly table.
Both Schema's are on same DB.
Oracle version=11.2.0.2
OS=Solaris 10
Existing Query
WITH ot_symbol_data_v AS
(SELECT dat.symbol, dat.startdate, dat.enddate, oi.currencycode,
dat.primarymarket, primsymb.symbol primarysymbol, dat.mic,
dat.universeid, dat.symbology
FROM onetick_symbol_data@refdata_link dat
LEFT JOIN
(SELECT symbology, universeid, mic, MAX (enddate) enddate
FROM onetick_symbol_data@refdata_link
GROUP BY symbology, universeid, mic) prim
ON prim.symbology = dat.symbology
AND prim.universeid = dat.universeid
AND prim.mic = dat.primarymarket
LEFT JOIN onetick_symbol_data@refdata_link primsymb
ON prim.symbology = primsymb.symbology
AND prim.universeid = primsymb.universeid
AND prim.mic = primsymb.mic
AND prim.enddate = primsymb.enddate
JOIN onetick_isincur_data@refdata_link oi
ON dat.universeid = oi.universeid
JOIN
(SELECT universeid, MAX (enddate) AS enddate
FROM onetick_isincur_data@refdata_link
GROUP BY universeid) oilatest
ON oi.universeid = oilatest.universeid
AND oi.enddate = oilatest.enddate
ORDER BY dat.universeid, dat.mic, dat.symbology, dat.enddate)
SELECT i.instrumentid
|| '||'
|| i.firsttradingdate
|| '000000|'
|| NVL (i.delisteddate, '30001231')
|| '000000|'
|| i.home_market
|| '|'
|| DECODE (imfm.feedid, 0, 'FIXN_RFA', 1, 'ALGO', 2, 'FIXNETIX')
|| '::'
|| osdv.primarysymbol
FROM tibex_meinstrumentview i JOIN tibex_instrumentmicfeedmapview imfm
ON i.isin = imfm.isin
AND i.currencycode = imfm.currencycode
AND i.home_market = imfm.mic
JOIN rd_universeview@refdata_link u
ON i.instrumentid = u.instrumentid AND i.instrumentstatus != 3
and active='Y'
JOIN
(SELECT universeid, DECODE (symbology, 1, 0, 2, 2, -1) feedid,
primarysymbol
FROM ot_symbol_data_v
GROUP BY universeid, symbology, primarysymbol) osdv
ON u.universeid = osdv.universeid
WHERE osdv.feedid = imfm.feedid
ORDER BY i.isin, i.currencycode, i.instrumentid;
New Query
WITH ot_symbol_data_v AS
(SELECT dat.symbol, dat.startdate, dat.enddate, oi.currencycode,
dat.primarymarket, primsymb.symbol primarysymbol, dat.mic,
dat.universeid, dat.symbology
FROM onetick_symbol_data@refdata_link dat
LEFT JOIN
(SELECT symbology, universeid, mic, MAX (enddate) enddate
FROM onetick_symbol_data@refdata_link
GROUP BY symbology, universeid, mic) prim
ON prim.symbology = dat.symbology
AND prim.universeid = dat.universeid
AND prim.mic = dat.primarymarket
LEFT JOIN onetick_symbol_data@refdata_link primsymb
ON prim.symbology = primsymb.symbology
AND prim.universeid = primsymb.universeid
AND prim.mic = primsymb.mic
AND prim.enddate = primsymb.enddate
JOIN onetick_isincur_data@refdata_link oi
ON dat.universeid = oi.universeid
JOIN
(SELECT universeid, MAX (enddate) AS enddate
FROM onetick_isincur_data@refdata_link
GROUP BY universeid) oilatest
ON oi.universeid = oilatest.universeid
AND oi.enddate = oilatest.enddate
ORDER BY dat.universeid, dat.mic, dat.symbology, dat.enddate)
SELECT i.instrumentid
|| '||'
|| i.firsttradingdate
|| '000000|'
|| NVL (i.delisteddate, '30001231')
|| '000000|'
|| i.home_market
|| '|'
|| DECODE (imfm.feedid, 0, 'FIXN_RFA', 1, 'ALGO', 2, 'FIXNETIX')
|| '::'
|| osdv.primarysymbol
FROM tibex_meinstrumentview i JOIN tibex_instrumentmicfeedmapview imfm
ON i.isin = imfm.isin
AND i.currencycode = imfm.currencycode
AND i.home_market = imfm.mic
JOIN universe@refdata_link u
ON i.instrumentid = u.instrumentid AND i.instrumentstatus != 3
and active='Y'
JOIN
(SELECT universeid, DECODE (symbology, 1, 0, 2, 2, -1) feedid,
primarysymbol
FROM ot_symbol_data_v
GROUP BY universeid, symbology, primarysymbol) osdv
ON u.universeid = osdv.universeid
WHERE osdv.feedid = imfm.feedid
ORDER BY i.isin, i.currencycode, i.instrumentid;Most of the wait event is
SQL*Net message from dblink
SQL*Net message to dblink
Regards
NM
Hi Kim,
uat_trd_owner@UAT001> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 741667790
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Inst |IN-OUT|
| 0 | SELECT STATEMENT | | 1 | 137 | 21981 (2)| 00:04:24 | | |
| 1 | SORT ORDER BY | | 1 | 137 | 21981 (2)| 00:04:24 | | |
|* 2 | HASH JOIN OUTER | | 1 | 137 | 21980 (2)| 00:04:24 | | |
|* 3 | HASH JOIN OUTER | | 1 | 131 | 422 (4)| 00:00:06 | | |
| 4 | NESTED LOOPS | | | | | | | |
| 5 | NESTED LOOPS | | 1 | 125 | 107 (9)| 00:00:02 | | |
| 6 | NESTED LOOPS | | 20 | 1680 | 87 (11)| 00:00:02 | | |
|* 7 | HASH JOIN | | 1 | 64 | 86 (11)| 00:00:02 | | |
| 8 | VIEW | TIBEX_INSTRUMENTMICFEEDMAPVIEW | 1 | 34 | 84 (9)| 00:00:02 | | |
| 9 | HASH GROUP BY | | 1 | 166 | 84 (9)| 00:00:02 | | |
|* 10 | HASH JOIN RIGHT OUTER | | 267 | 44322 | 83 (8)| 00:00:01 | | |
| 11 | TABLE ACCESS FULL | TIBEX_BOARDFEEDMAP | 1 | 20 | 3 (0)| 00:00:01 | | |
| 12 | NESTED LOOPS OUTER | | 267 | 38982 | 80 (8)| 00:00:01 | | |
| 13 | NESTED LOOPS OUTER | | 267 | 21627 | 80 (8)| 00:00:01 | | |
|* 14 | HASH JOIN | | 267 | 17088 | 80 (8)| 00:00:01 | | |
| 15 | MERGE JOIN CARTESIAN | | 2004 | 88176 | 37 (0)| 00:00:01 | | |
| 16 | INDEX FULL SCAN | TIBEX_EDPDEFAULTFEED_PK | 1 | 3 | 1 (0)| 00:00:01 | | |
| 17 | BUFFER SORT | | 2004 | 82164 | 36 (0)| 00:00:01 | | |
|* 18 | TABLE ACCESS FULL | TIBEX_INSTRUMENT | 2004 | 82164 | 36 (0)| 00:00:01 | | |
| 19 | VIEW | TIBEX_EDPINSTRUMENTMARKETSVIEW | 22040 | 430K| 42 (12)| 00:00:01 | | |
| 20 | HASH GROUP BY | | 22040 | 430K| 42 (12)| 00:00:01 | | |
| 21 | VIEW | | 22040 | 430K| 41 (10)| 00:00:01 | | |
| 22 | SORT UNIQUE | | 22040 | 544K| 41 (57)| 00:00:01 | | |
| 23 | UNION-ALL | | | | | | | |
| 24 | INDEX FAST FULL SCAN| TIBEX_EDPFIXNETIXL1_R01 | 7578 | 162K| 18 (0)| 00:00:01 | | |
| 25 | TABLE ACCESS FULL | TIBEX_EDPIXSYMBOLS | 7494 | 197K| 12 (0)| 00:00:01 | | |
| 26 | TABLE ACCESS FULL | TIBEX_EDPRFALGOSUBSCRIPTION | 6968 | 183K| 7 (0)| 00:00:01 | | |
|* 27 | INDEX RANGE SCAN | TIBEX_MICFEEDMAP_PK | 1 | 17 | 0 (0)| 00:00:01 | | |
| 28 | TABLE ACCESS BY INDEX ROWID| TIBEX_INSTRUMENTFEEDMAP | 1 | 65 | 0 (0)| 00:00:01 | | |
|* 29 | INDEX UNIQUE SCAN | TIBEX_INSTRUMENTFEEDMAP_PK | 1 | | 0 (0)| 00:00:01 | | |
| 30 | VIEW | | 100 | 3000 | 1 (100)| 00:00:01 | | |
| 31 | REMOTE | | | | | | REFDA~ | R->S |
| 32 | REMOTE | UNIVERSE | 20 | 400 | 1 (0)| 00:00:01 | REFDA~ | R->S |
|* 33 | INDEX UNIQUE SCAN | XPKTIBEX_INSTRUMENT | 1 | | 0 (0)| 00:00:01 | | |
|* 34 | TABLE ACCESS BY INDEX ROWID | TIBEX_INSTRUMENT | 1 | 41 | 1 (0)| 00:00:01 | | |
| 35 | VIEW | TIBEX_MELASTEXPRICEINTVIEW | 36 | 216 | 314 (2)| 00:00:04 | | |
| 36 | HASH UNIQUE | | 36 | 1656 | 314 (2)| 00:00:04 | | |
|* 37 | HASH JOIN | | 36 | 1656 | 313 (1)| 00:00:04 | | |
| 38 | VIEW | VW_SQ_1 | 304 | 5776 | 157 (2)| 00:00:02 | | |
| 39 | HASH GROUP BY | | 304 | 7296 | 157 (2)| 00:00:02 | | |
|* 40 | TABLE ACCESS FULL | TIBEX_EXECUTION | 17462 | 409K| 156 (1)| 00:00:02 | | |
| 41 | TABLE ACCESS FULL | TIBEX_EXECUTION | 17463 | 460K| 156 (1)| 00:00:02 | | |
| 42 | VIEW | TIBEX_MSGSEQBYINSTRUMENT | 3908 | 23448 | 21558 (2)| 00:04:19 | | |
| 43 | HASH GROUP BY | | 3908 | 74252 | 21558 (2)| 00:04:19 | | |
| 44 | VIEW | | 11626 | 215K| 21556 (2)| 00:04:19 | | |
| 45 | UNION-ALL | | | | | | | |
| 46 | HASH GROUP BY | | 1460 | 26280 | 8906 (1)| 00:01:47 | | |
| 47 | TABLE ACCESS FULL | TIBEX_QUOTE | 1362K| 23M| 8866 (1)| 00:01:47 | | |
| 48 | HASH GROUP BY | | 677 | 12186 | 11750 (2)| 00:02:21 | | |
| 49 | TABLE ACCESS FULL | TIBEX_ORDER | 1790K| 30M| 11696 (1)| 00:02:21 | | |
| 50 | HASH GROUP BY | | 304 | 5472 | 157 (2)| 00:00:02 | | |
|* 51 | TABLE ACCESS FULL | TIBEX_EXECUTION | 17463 | 306K| 156 (1)| 00:00:02 | | |
| 52 | HASH GROUP BY | | 1 | 40 | 3 (34)| 00:00:01 | | |
|* 53 | TABLE ACCESS FULL | TIBEX_TSTRADE | 1 | 40 | 2 (0)| 00:00:01 | | |
| 54 | HASH GROUP BY | | 717 | 11472 | 229 (1)| 00:00:03 | | |
| 55 | INDEX FAST FULL SCAN | IX_BESTEXREL | 7323 | 114K| 228 (0)| 00:00:03 | | |
| 56 | HASH GROUP BY | | 1911 | 34398 | 13 (8)| 00:00:01 | | |
|* 57 | TABLE ACCESS FULL | TIBEX_MERESUMEPRDTRANSITION | 5216 | 93888 | 12 (0)| 00:00:01 | | |
PLAN_TABLE_OUTPUT
| 58 | HASH GROUP BY | | 3 | 51 | 5 (20)| 00:00:01 | | |
| 59 | TABLE ACCESS FULL | TIBEX_EDPUPDATEREJECT | 48 | 816 | 4 (0)| 00:00:01 | | |
| 60 | HASH GROUP BY | | 1587 | 46023 | 215 (2)| 00:00:03 | | |
|* 61 | HASH JOIN | | 35166 | 995K| 213 (1)| 00:00:03 | | |
| 62 | INDEX FULL SCAN | XPKTIBEX_CONFIGMEGROUP | 4 | 16 | 1 (0)| 00:00:01 | | |
| 63 | TABLE ACCESS FULL | TIBEX_INSTRUMENTADMIN | 87915 | 2146K| 212 (1)| 00:00:03 | | |
| 64 | HASH GROUP BY | | 6 | 102 | 5 (20)| 00:00:01 | | |
| 65 | TABLE ACCESS FULL | TIBEX_BESTEXECPRICELOG | 793 | 13481 | 4 (0)| 00:00:01 | | |
| 66 | HASH GROUP BY | | 1 | 40 | 3 (34)| 00:00:01 | | |
|* 67 | TABLE ACCESS FULL | TIBEX_AUCTIONPRICE | 1 | 40 | 2 (0)| 00:00:01 | | |
| 68 | HASH GROUP BY | | 1587 | 28566 | 236 (2)| 00:00:03 | | |
|* 69 | TABLE ACCESS FULL | TIBEX_ADMINACK | 87915 | 1545K| 233 (1)| 00:00:03 | | |
| 70 | HASH GROUP BY | | 1914 | 34452 | 26 (8)| 00:00:01 | | |
| 71 | INDEX FAST FULL SCAN | INSTRUMENTSTATEMSGSEQ | 23705 | 416K| 24 (0)| 00:00:01 | | |
| 72 | HASH GROUP BY | | 1458 | 26244 | 8 (13)| 00:00:01 | | |
| 73 | INDEX FAST FULL SCAN | TIBEX_FREEZEEOTPK | 5890 | 103K| 7 (0)| 00:00:01 | | |
Predicate Information (identified by operation id):
2 - access("A"."INSTRUMENTID"="C"."INSTRUMENTID"(+))
3 - access("A"."INSTRUMENTID"="B"."INSTRUMENTID"(+))
7 - access("OSDV"."FEEDID"="IMFM"."FEEDID")
10 - access("I"."PRIMARYSTATUSBOARDID"="BOARDFM"."BOARDID"(+))
14 - access("SUBSC"."ISIN"="I"."ISIN" AND "SUBSC"."CURRENCYCODE"="I"."CURRENCYCODE")
filter("SUBSC"."HOMEMARKET" IS NULL OR "SUBSC"."HOMEMARKET"="I"."HOME_MARKET")
18 - filter("I"."INSTRUMENTSTATUS"<>3)
27 - access("SUBSC"."MIC"="MICFM"."MIC"(+))
29 - access("I"."INSTRUMENTID"="INSTRFM"."INSTRUMENTID"(+))
33 - access("A"."INSTRUMENTID"="U"."INSTRUMENTID")
34 - filter("A"."INSTRUMENTSTATUS"<>3 AND TO_DATE("A"."FIRSTTRADINGDATE",'YYYYMMDD')<=SYSDATE@! AND "A"."ISIN"="IMFM"."ISIN"
AND "A"."CURRENCYCODE"="IMFM"."CURRENCYCODE" AND "A"."HOME_MARKET"="IMFM"."MIC")
37 - access("A"."MESSAGESEQUENCE"="MAX(B.MESSAGESEQUENCE)" AND "A"."INSTRUMENTID"="ITEM_0")
40 - filter(("B"."SELLENTITYTYPE"=0 OR "B"."SELLENTITYTYPE"=2) AND ("B"."BUYENTITYTYPE"=0 OR "B"."BUYENTITYTYPE"=2))
51 - filter("INSTRUMENTID" IS NOT NULL)
53 - filter("INSTRUMENTID" IS NOT NULL)
57 - filter("INSTRUMENTID" IS NOT NULL)
61 - access("ADMINUSER"="MEGROUPID")
67 - filter("INSTRUMENTID" IS NOT NULL)
69 - filter("INSTRUMENTID" IS NOT NULL)
Remote SQL Information (identified by operation id):
31 - EXPLAIN PLAN INTO PLAN_TABLE@! FOR SELECT "A1"."UNIVERSEID",DECODE("A1"."SYMBOLOGY",1,0,2,2,(-1)),"A1"."PRIMARYSYMBOL"
FROM (SELECT "A6"."SYMBOL" "SYMBOL","A6"."STARTDATE" "STARTDATE","A6"."ENDDATE" "ENDDATE","A3"."CURRENCYCODE"
"CURRENCYCODE","A6"."PRIMARYMARKET" "PRIMARYMARKET","A4"."SYMBOL" "PRIMARYSYMBOL","A6"."MIC" "MIC","A6"."UNIVERSEID"
"UNIVERSEID","A6"."SYMBOLOGY" "SYMBOLOGY" FROM "ONETICK_SYMBOL_DATA" "A6", (SELECT "A7"."SYMBOLOGY"
"SYMBOLOGY","A7"."UNIVERSEID" "UNIVERSEID","A7"."MIC" "MIC",MAX("A7"."ENDDATE") "ENDDATE" FROM "ONETICK_SYMBOL_DATA" "A7" GROUP
BY "A7"."SYMBOLOGY","A7"."UNIVERSEID","A7"."MIC") "A5","ONETICK_SYMBOL_DATA" "A4","ONETICK_ISINCUR_DATA" "A3", (SELECT
"A8"."UNIVERSEID" "UNIVERSEID",MAX("A8"."ENDDATE") "ENDDATE" FROM "ONETICK_ISINCUR_DATA" "A8" GROUP BY "A8"."UNIVERSEID") "A2"
WHERE "A3"."UNIVERSEID"="A2"."UNIVERSEID" AND "A3"."ENDDATE"="A2"."ENDDATE" AND "A6"."UNIVERSEID"="A3"."UNIVERSEID" AND
"A5"."ENDDATE"="A4"."ENDDATE"(+) AND "A5"."MIC"="A4"."MIC"(+) AND "A5"."UNIVERSEID"="A4"."UNIVERSEID"(+) AND
"A5"."SYMBOLOGY"="A4"."SYMBOLOGY"(+) AND "A5"."MIC"(+)="A6"."PRIMARYMARKET" AND "A5"."UNIVERSEID"(+)="A6"."UNIVERSEID" AND
"A5"."SYMBOLOGY"(+)="A6"."SYMBOLOGY" ORDER BY "A6"."UNIVERSEID","A6"."MIC","A6"."SYMBOLOGY","A6"."ENDDATE") "A1" GROUP BY
"A1"."UNIVERSEID","A1"."SYMBOLOGY","A1"."PRIMARYSYMBOL" (accessing 'REFDATA_LINK' )
32 - SELECT "INSTRUMENTID","UNIVERSEID" FROM "UNIVERSE" "U" WHERE "UNIVERSEID"=:1 (accessing 'REFDATA_LINK' )
127 rows selected.
For trace files
WAIT #18446741324892119016: nam='SQL*Net message to client' ela= 2 driver id=1413697536 #bytes=1 p3=0 obj#=-1 tim=42151855125079
WAIT #18446741324892119016: nam='SQL*Net message from client' ela= 182 driver id=1413697536 #bytes=1 p3=0 obj#=-1 tim=42151855125694
=====================
PARSING IN CURSOR #18446741324892117968 len=52 dep=0 uid=474 oct=47 lid=474 tim=42151855125777 hv=1029988163 ad='af4d0890' sqlid='9babjv8yq8ru3'
BEGIN DBMS_OUTPUT.GET_LINES(:LINES, :NUMLINES); END;
END OF STMT
PARSE #18446741324892117968:c=0,e=42,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,plh=0,tim=42151855125769
WAIT #18446741324892117968: nam='SQL*Net message to client' ela= 2 driver id=1413697536 #bytes=1 p3=0 obj#=-1 tim=42151855126145
EXEC #18446741324892117968:c=0,e=262,p=0,cr=0,cu=0,mis=0,r=1,dep=0,og=1,plh=0,tim=42151855126176
*** 2012-11-20 15:18:56.839
WAIT #18446741324892117968: nam='SQL*Net message from client' ela= 10252982 driver id=1413697536 #bytes=1 p3=0 obj#=-1 tim=42151865379208
CLOSE #18446741324892119016:c=0,e=13,dep=0,type=1,tim=42151865379327
CLOSE #18446741324892117968:c=0,e=28,dep=0,type=3,tim=42151865379370
WAIT #18446741324892082152: nam='single-task message' ela= 47849 p1=0 p2=0 p3=0 obj#=-1 tim=42151865429221
WAIT #18446741324892082152: nam='SQL*Net message from dblink' ela= 107 driver id=1413697536 #bytes=1 p3=0 obj#=-1 tim=42151865429886
WAIT #18446741324892082152: nam='SQL*Net message to dblink' ela= 2 driver id=1413697536 #bytes=1 p3=0 obj#=-1 tim=42151865429945
WAIT #18446741324892082152: nam='SQL*Net message from dblink' ela= 926 driver id=1413697536 #bytes=1 p3=0 obj#=-1 tim=42151865430901
WAIT #18446741324892082152: nam='SQL*Net message to dblink' ela= 2 driver id=1413697536 #bytes=1 p3=0 obj#=-1 tim=42151865431578
WAIT #18446741324892082152: nam='SQL*Net message from dblink' ela= 2525 driver id=1413697536 #bytes=1 p3=0 obj#=-1 tim=42151865434125
WAIT #18446741324892082152: nam='SQL*Net message to dblink' ela= 1 driver id=1413697536 #bytes=1 p3=0 obj#=-1 tim=42151894670108
WAIT #18446741324892082152: nam='SQL*Net message from dblink' ela= 58 driver id=1413697536 #bytes=1 p3=0 obj#=-1 tim=42151894670178
WAIT #18446741324892082152: nam='SQL*Net message to dblink' ela= 0 driver id=1413697536 #bytes=1 p3=0 obj#=-1 tim=42151894670235
WAIT #18446741324892082152: nam='SQL*Net message from dblink' ela= 60 driver id=1413697536 #bytes=1 p3=0 obj#=-1 tim=42151894670310
WAIT #18446741324892082152: nam='SQL*Net message to dblink' ela= 1 driver id=1413697536 #bytes=1 p3=0 obj#=-1 tim=42151894670337
WAIT #18446741324892082152: nam='SQL*Net message from dblink' ela= 59 driver id=1413697536 #bytes=1 p3=0 obj#=-1 tim=42151894670407
WAIT #18446741324892082152: nam='SQL*Net message to dblink' ela= 0 driver id=1413697536 #bytes=1 p3=0 obj#=-1 tim=42151894670464
WAIT #18446741324892082152: nam='SQL*Net message from dblink' ela= 60 driver id=1413697536 #bytes=1 p3=0 obj#=-1 tim=42151894670539
WAIT #18446741324892082152: nam='SQL*Net message to dblink' ela= 1 driver id=1413697536 #bytes=1 p3=0 obj#=-1 tim=42151894670566
WAIT #18446741324892082152: nam='SQL*Net message from dblink' ela= 59 driver id=1413697536 #bytes=1 p3=0 obj#=-1 tim=42151894670636
WAIT #18446741324892082152: nam='SQL*Net message to dblink' ela= 1 driver id=1413697536 #bytes=1 p3=0 obj#=-1 tim=42151894670693
WAIT #18446741324892082152: nam='SQL*Net message from dblink' ela= 60 driver id=1413697536 #bytes=1 p3=0 obj#=-1 tim=42151894670768Regards
NM
Similar Messages
-
Process wait SQL*Net message from dblink /SQL*Net message from client
Hi There,
We have an ETL process that we kindly need your help with. The process been running since Sun, where it transfers the data from one server (via remote query). The process was running ok till last night where it appeared
to have stopped working and/or the session is just idling doing nothing.
Here are some tests that we did to figure out what's going on:
1. when looking at the session IO, we noticed that it's not changing:
etl_user@datap> select sess_io.sid,
2 sess_io.block_gets,
3 sess_io.consistent_gets,
4 sess_io.physical_reads,
5 sess_io.block_changes,
6 sess_io.consistent_changes
7 from v$sess_io sess_io, v$session sesion
8 where sesion.sid = sess_io.sid
9 and sesion.username is not null
10 and sess_io.sid=301
11 order by 1;
logical physical
SID BLOCK_GETS reads reads BLOCK_CHANGES CONSISTENT_CHANGES
301 388131317 97721268 26687579 223052804 161334
Elapsed: 00:00:00.012. Check there is nothing blocking the session
etl_user@datap> select * from v$lock where sid=301;
ADDR KADDR SID TY ID1 ID2 LMODE REQUEST CTIME BLOCK
684703F0 6847041C 301 DX 35 0 1 0 45237 0
684714C4 684714F0 301 AE 199675 0 4 0 260148 0
619651EC 6196521C 301 TM 52733 0 3 0 45241 0
67F86ACC 67F86B0C 301 TX 458763 52730 6 0 45241 03. Check if the session is still valid:
etl_user@datap> select status from v$session where sid=301;
STATUS
ACTIVE4. Check if there is anything in long ops that has not completed:
etl_user@datap> SELECT SID, SERIAL#, opname, SOFAR, TOTALWORK,
2 ROUND(SOFAR/TOTALWORK*100,2) COMPLETE, TIME_REMAINING/60
3 FROM V$SESSION_LONGOPS
4 WHERE
5 TOTALWORK != 0
6 AND SOFAR != TOTALWORK
7 order by 1;
no rows selected
Elapsed: 00:00:00.005. Check if there is anything in long ops for the session:
etl_user@datap> r
1* select SID,SOFAR,TOTALWORK,START_TIME,LAST_UPDATE_TIME,TIME_REMAINING,MESSAGE from V$SESSION_LONGOPS where sid=301
SID SOFAR TOTALWORK START_TIM LAST_UPDA TIME_REMAINING MESSAGE
301 0 0 22-JUL-12 22-JUL-12 Gather Table's Index Statistics: Table address_etl : 0 out of 0 Indexes done
Elapsed: 00:00:00.00This is a bit odd!! This particular step have actually completed successfully on the 22nd of July, and we don't know why it's still showing in long opps!? any ideas?
6. Looking at the sql and what's it actually doing:
etl_user@datap> select a.sid, a.value session_cpu, c.physical_reads,
2 c.consistent_gets,d.event,
3 d.seconds_in_wait
4 from v$sesstat a,v$statname b, v$sess_io c, v$session_wait d
5 where a.sid= &p_sid_number
6 and b.name = 'CPU used by this session'
7 and a.statistic# = b.statistic#
8 and a.sid=c.sid
9 and a.sid=d.sid;
Enter value for p_sid_number: 301
old 5: where a.sid= &p_sid_number
new 5: where a.sid= 301
CPU physical logical seconds
SID used reads reads EVENT waiting
301 1966595 26687579 97721268 SQL*Net message from dblink 45792
Elapsed: 00:00:00.037. We looked at the remote DB where the data resides on, and we noticed that the remote session was also waiting on the db link:
SYS@destp> select a.sid, a.value session_cpu, c.physical_reads,
2 c.consistent_gets,d.event,
3 d.seconds_in_wait
4 from v$sesstat a,v$statname b, v$sess_io c, v$session_wait d
5 where a.sid= &p_sid_number
6 and b.name = 'CPU used by this session'
7 and a.statistic# = b.statistic#
8 and a.sid=c.sid
9 and a.sid=d.sid;
Enter value for p_sid_number: 388
old 5: where a.sid= &p_sid_number
new 5: where a.sid= 390
SID SESSION_CPU PHYSICAL_READS CONSISTENT_GETS EVENT SECONDS_IN_WAIT
390 136 0 7605 SQL*Net message from client 46101
SYS@destp>We have had an issue in the past where the connection was being dropped by the network when the process runs for few days, hence we have added the following to the sqlnet.ora and listener.ora files:
sqlnet.ora:
SQLNET.EXPIRE_TIME = 1
SQLNET.INBOUND_CONNECT_TIMEOUT = 6000
listener.ora:
INBOUND_CONNECT_TIMEOUT_LISTENER = 6000What else can we do and/or further investigate to work out the root cause of the problem, and may be help resolve this. We don't want to just stop and start the process again as it took few days already. We have
had a chat to the infrastructure team and they've assured us that there have been no network outages.
Also, the alert logs for both instances (local and remote) shows no errors what so ever!
Your input is highly appreciated.
Thanks
Edited by: rsar001 on Jul 25, 2012 10:22 AMRan the query on both local/remote db, and no rows returned:
etl_user@datap> SELECT DECODE(request,0,'Holder: ','Waiter: ')||vl.sid sess, status,
2 id1, id2, lmode, request, vl.type
3 FROM V$LOCK vl, v$session vs
4 WHERE (id1, id2, vl.type) IN
5 (SELECT id1, id2, type FROM V$LOCK WHERE request>0)
6 and vl.sid = vs.sid
7 ORDER BY id1, request
8 /
no rows selected
Elapsed: 00:00:00.21 -
Query Execution taking Longer Time
Hi BI Gurus,
There is one some ABC query which was built on multiprovider, when I am trying to execute it in BEx analyzer in production system it is taking long run and then giving short dump. I have checked data in the multiprovider it is not more than 1lac records. Can any one tell me what is the problem and how can I find the roote cause?
Thanks in advance,
VenkatHi,
Even I am facing the same problem above. I am trying to fetch results from a cursor which has subquery running over the db link and placing the results set in a csv file using client_io package. When I run the cursor directly from database (11G), it takes not more than 3-4 min to get the results back. But when I run the same cursor via oracle forms 10G, the query in local database keep on waiting for hours to get results from remote database with "SQL*Net message from dblink". Session on local database remains in active status with state as "Waiting" while the session on remote database goes inactive with state as waiting for event "SQL*Net message from client"
This is confusing me since the same query when ran directly from backend fetches results soon.
Please let me know if anyone can help here
Thanks
Garima -
Query execution taking longer time in Oracle form 10g !!
Hi,
I'm generating a report through Oracle form ( forms 10g) and its taking 3-4 hours to finish. But when I run the same report query in (Oracle 11g) database, it gets executed in less than 40 mins.
The form takes only from and to date as input.
I tried hardcoring the date in the Oracle Form and then the report takes only 40 mins to generate.
I tried various approaches like changing the datatypes of form variable and correspondingly changing the query, but met with no success.
When the report in run through the form , we can see the query getting run in backend for nearly 3 hrs !!! tats really confusing !!
Please let me know, if anybody got any idea on this problem??Hi,
Even I am facing the same problem above. I am trying to fetch results from a cursor which has subquery running over the db link and placing the results set in a csv file using client_io package. When I run the cursor directly from database (11G), it takes not more than 3-4 min to get the results back. But when I run the same cursor via oracle forms 10G, the query in local database keep on waiting for hours to get results from remote database with "SQL*Net message from dblink". Session on local database remains in active status with state as "Waiting" while the session on remote database goes inactive with state as waiting for event "SQL*Net message from client"
This is confusing me since the same query when ran directly from backend fetches results soon.
Please let me know if anyone can help here
Thanks
Garima -
Simple query is taking long time
Hi Experts,
The below query is taking long time.
[code]SELECT FS.*
FROM ORL.FAX_STAGE FS
INNER JOIN
ORL.FAX_SOURCE FSRC
INNER JOIN
GLOBAL_BU_MAPPING GBM
ON GBM.BU_ID = FSRC.BUID
ON UPPER (FSRC.FAX_NUMBER) = UPPER (FS.DESTINATION)
WHERE FSRC.IS_DELETED = 'N'
AND GBM.BU_ID IS NOT NULL
AND UPPER (FS.FAX_STATUS) ='COMPLETED';[/code]
this query is returning 1645457 records.
[code]PLAN_TABLE_OUTPUT
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)|
| 0 | SELECT STATEMENT | | 625K| 341M| 45113 (1)|
| 1 | HASH JOIN | | 625K| 341M| 45113 (1)|
| 2 | NESTED LOOPS | | 611 | 14664 | 22 (0)|
| 3 | TABLE ACCESS FULL| FAX_SOURCE | 2290 | 48090 | 22 (0)|
| 4 | INDEX RANGE SCAN | GLOBAL_BU_MAPPING_BUID | 1 | 3 | 0 (0)|
| 5 | TABLE ACCESS FULL | FAX_STAGE | 2324K| 1214M| 45076 (1)|
PLAN_TABLE_OUTPUT
Note
- 'PLAN_TABLE' is old version
15 rows selected.[/code]
The distinct number of records in each table.
[code]SELECT FAX_STATUS,count(*)
FROM fax_STAGE
GROUP BY FAX_STATUS;
FAX_STATUS COUNT(*)
BROKEN 10
Broken - New 9
Completed 2324493
New 20
SELECT is_deleted,COUNT(*)
FROM FAX_SOURCE
GROUP BY IS_DELETED;
IS_DELETED COUNT(*)
N 2290
Y 78[/code]
Total number of records in each table.
[code]SELECT COUNT(*) FROM ORL.FAX_SOURCE FSRC-- 2368
SELECT COUNT(*) FROM ORL.FAX_STAGE--2324532
SELECT COUNT(*) FROM APPS_GLOBAL.GLOBAL_BU_MAPPING--9
[/code]
To improve the performance of this query I have created the following indexes.
[code]Functional based index on UPPER (FSRC.FAX_NUMBER) ,UPPER (FS.DESTINATION) and UPPER (FS.FAX_STATUS).
Bitmap index on FSRC.IS_DELETED.
Normal Index on GBM.BU_ID and FSRC.BUID.
[/code]
But still the performance is bad for this query.
What can I do apart from this to improve the performance of this query.
Please help me .
Thanks in advance.<I have created the following indexes.
CREATE INDEX ORL.IDX_DESTINATION_RAM ON ORL.FAX_STAGE(UPPER("DESTINATION"))
CREATE INDEX ORL.IDX_FAX_STATUS_RAM ON ORL.FAX_STAGE(LOWER("FAX_STATUS"))
CREATE INDEX ORL.IDX_UPPER_FAX_STATUS_RAM ON ORL.FAX_STAGE(UPPER("FAX_STATUS"))
CREATE INDEX ORL.IDX_BUID_RAM ON ORL.FAX_SOURCE(BUID)
CREATE INDEX ORL.IDX_FAX_NUMBER_RAM ON ORL.FAX_SOURCE(UPPER("FAX_NUMBER"))
CREATE BITMAP INDEX ORL.IDX_IS_DELETED_RAM ON ORL.FAX_SOURCE(IS_DELETED)
After creating the following indexes performance got improved.
But our DBA said that new BITMAP index at FAX_SOURCE table (ORL.IDX_IS_DELETED_RAM) can cause locks
on multiple rows if IS_DELETED column is in use. Please proceed with detailed tests.
I am sending the explain plan before creating indexes and after indexes has been created.
SELECT FS.*
FROM ORL.FAX_STAGE FS
INNER JOIN
ORL.FAX_SOURCE FSRC
INNER JOIN
GLOBAL_BU_MAPPING GBM
ON GBM.BU_ID = FSRC.BUID
ON UPPER (FSRC.FAX_NUMBER) = UPPER (FS.DESTINATION)
WHERE FSRC.IS_DELETED = 'N'
AND GBM.BU_ID IS NOT NULL
AND UPPER (FS.FAX_STATUS) =:B1;
--OLD without indexes
PLAN_TABLE_OUTPUT
Plan hash value: 3076973749
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 141K| 85M| 45130 (1)| 00:09:02 |
|* 1 | HASH JOIN | | 141K| 85M| 45130 (1)| 00:09:02 |
| 2 | NESTED LOOPS | | 611 | 18330 | 22 (0)| 00:00:01 |
|* 3 | TABLE ACCESS FULL| FAX_SOURCE | 2290 | 59540 | 22 (0)| 00:00:01 |
|* 4 | INDEX RANGE SCAN | GLOBAL_BU_MAPPING_BUID | 1 | 4 | 0 (0)| 00:00:01 |
|* 5 | TABLE ACCESS FULL | FAX_STAGE | 23245 | 13M| 45106 (1)| 00:09:02 |
PLAN_TABLE_OUTPUT
Predicate Information (identified by operation id):
1 - access(UPPER("FSRC"."FAX_NUMBER")=UPPER("FS"."DESTINATION"))
3 - filter("FSRC"."IS_DELETED"='N')
4 - access("GBM"."BU_ID"="FSRC"."BUID")
filter("GBM"."BU_ID" IS NOT NULL)
5 - filter(UPPER("FS"."FAX_STATUS")=SYS_OP_C2C(:B1))
21 rows selected.
--NEW with indexes.
PLAN_TABLE_OUTPUT
Plan hash value: 665032407
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 5995 | 3986K| 3117 (1)| 00:00:38 |
|* 1 | HASH JOIN | | 5995 | 3986K| 3117 (1)| 00:00:38 |
| 2 | NESTED LOOPS | | 611 | 47658 | 20 (5)| 00:00:01 |
|* 3 | VIEW | index$_join$_002 | 2290 | 165K| 20 (5)| 00:00:01 |
|* 4 | HASH JOIN | | | | | |
|* 5 | HASH JOIN | | | | | |
PLAN_TABLE_OUTPUT
| 6 | BITMAP CONVERSION TO ROWIDS| | 2290 | 165K| 1 (0)| 00:00:01 |
|* 7 | BITMAP INDEX SINGLE VALUE | IDX_IS_DELETED_RAM | | | | |
| 8 | INDEX FAST FULL SCAN | IDX_BUID_RAM | 2290 | 165K| 8 (0)| 00:00:01 |
| 9 | INDEX FAST FULL SCAN | IDX_FAX_NUMBER_RAM | 2290 | 165K| 14 (0)| 00:00:01 |
|* 10 | INDEX RANGE SCAN | GLOBAL_BU_MAPPING_BUID | 1 | 4 | 0 (0)| 00:00:01 |
| 11 | TABLE ACCESS BY INDEX ROWID | FAX_STAGE | 23245 | 13M| 3096 (1)| 00:00:38 |
|* 12 | INDEX RANGE SCAN | IDX_UPPER_FAX_STATUS_RAM | 9298 | | 2434 (1)| 00:00:30 |
Predicate Information (identified by operation id):
PLAN_TABLE_OUTPUT
1 - access(UPPER("DESTINATION")="FSRC"."SYS_NC00035$")
3 - filter("FSRC"."IS_DELETED"='N')
4 - access(ROWID=ROWID)
5 - access(ROWID=ROWID)
7 - access("FSRC"."IS_DELETED"='N')
10 - access("GBM"."BU_ID"="FSRC"."BUID")
filter("GBM"."BU_ID" IS NOT NULL)
12 - access(UPPER("FAX_STATUS")=SYS_OP_C2C(:B1))
31 rows selected
Please confirm on the DBA comment.Is this bitmap index locks rows in my case.
Thanks.> -
SQL*Net message from client - huge wait in trace file
Dear All,
I am facing a performance issue in a particular operation ( which was completed in 21 Minutes earlier). Now the same operation takes more than 35 Minutes. I took a trace for those session ( 10046 level 12 trace ) and found Lot of waits in SQL*Net message from client.
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQLNet message from client 611927 10.00 1121.35*
I copied only the highest wait in the tkprof output.
And I found from the tkprof and even in raw trace file this event waits more time after excuting
SELECT sysdate AS SERVERDATE from dual;
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to client 115 0.00 0.00
SQLNet message from client 115 10.00 724.52*
Please help me to find out why this wait taking long time, especially on the above query..
Regards,
VinodhVinodh Kumar wrote:
Hi,
This is what available in the trace file
PARSING IN CURSOR #2 len=38 dep=0 uid=60 oct=3 lid=60 tim=7052598842 hv=3788189359 ad='7d844fa0'
*"SELECT sysdate AS SERVERDATE FROM dual"*
END OF STMT
PARSE #2:c=0,e=12,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,tim=7052598839
BINDS #2:
EXEC #2:c=0,e=42,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,tim=7052599002
WAIT #2: nam='SQL*Net message to client' ela= 1 driver id=1952673792 #bytes=1 p3=0 obj#=-1 tim=7052599058
FETCH #2:c=0,e=15,p=0,cr=0,cu=0,mis=0,r=1,dep=0,og=1,tim=7052599110
*** 2012-01-02 17:07:30.364
WAIT #2: nam='SQL*Net message from client' *" ela= 10007957"* driver id=1952673792 #bytes=1 p3=0 obj#=-1 tim=7062607120Please find the last line WAIT -- in the complete trace after executing this query
In awr report , this query taken less than a sec for more than 2000 executions.
Regards,
VinodhGood idea to check the raw trace file. It is important to notice that this particular wait event appears after the fetch of the result from the database. The client receives the SYSDATE from the database server, and then the client performs some sort of action for about 10 seconds before submitting its next request to the database. The SQL statement that immediately follows and immediately preceeds this section of the trace file might provide clues regarding what caused the delay, and where that delay resides in the client side code. Maybe a creative developer added a "sleep for 10 seconds" routine when intending to sleep for 10ms? Maybe the client CPU is close to 100% utilization?
Charles Hooper
http://hoopercharles.wordpress.com/
IT Manager/Oracle DBA
K&M Machine-Fabricating, Inc. -
Oracle - Informatica transfer speed fetch size and SQL*Net message from c
Hi,
I'm testing how fast informatica can take data from our 10.2.0.3 and using large (140GB 1 200 000 000 rows) table as source and doing simple
select * from large_table .
Here goes quite interesting wait time analyze :) .
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 186994 131.84 198.25 127545 314167 0 25431184
total 186994 131.84 198.25 127545 314167 0 25431184
Misses in library cache during parse: 0
Parsing user id: 400
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
db file scattered read 9122 0.33 64.71
SQL*Net more data to client 529327 0.00 8.34
SQL*Net message from client 186994 0.21 478.74
SQL*Net message to client 186994 0.00 0.30
db file sequential read 145 0.01 0.49
gc cr multi block request 6998 0.01 6.30
gc current grant 2-way 9 0.00 0.00
gc cr grant 2-way 67 0.00 0.03The interesting part is ' SQL*Net message from client 186994 0.21 478.74'
so looks like from Informaticka point of view (client side) is lagging 478 sec , so its lagging .
Doing some math 25431184/186994 = 136 .
Could You share with me Your experience in that matter ?
Looks like to speed up I need to :
1. increase fetch size (not sure how to do that).
2. increase SDU client and probably server side .
Network is 100Mbit ethernet so about 10MBytes per second .
Regards
GregGHave you solve your problem ?
If yes I'm strongly interest by the solution.
If you have a question of issue create your own thread and provide the particulars of your use case. This thread is year old.
OP likely did NOT have any problem. As OP stated the max throughput for a 100 Mbit network is about 10 MB per second. So do the math for moving 140 GB and you will see that the network itself will be the limiting factor. -
How to drill down the cause of "SQL*Net message from/to client"
Pretty frustrated with my tune up using suggestions from many papers for Oracle 10g R2 on AIX 5.3 L system. My users told me that the system (including Baan 5c) still responds slowly in some processes, some even worsen.
Using both queries such as
SELECT sid, schemaname, status FROM gv$session ORDER BY 2;
SELECT inst_id, seq#, event, p1, p2, p3, wait_time FROM v$session_wait_history WHERE sid=<sid from above>
INST_ID SEQ# EVENT P1 P2 P3 WAIT_TIME
1 1 SQL*Net message from client 1413697536 1 0 6419
1 2 SQL*Net message to client 1413697536 1 0 0
and others similar, I found very large numbers (almost 97%) of the sessions have events as “SQL*Net message to client” and “SQL*Net message from client” on their wait_time even the sids are in inactive status. After checking the meaning of those messages in Oracle Performance and Tuning document, the document states that mainly they are probably network problems. So How can I drill down to what status of network from my client (the users) to server by Oracle or AIX? In Baan, it has its own parameter sets in its db_resource file controlling the connectivity. In average, there are 4000 “opened cursor current”, but most of them inactives.
So my colleague asked me rollback all th changes I did on OS level such as minperm%=5
maxperm%=90
maxclient%=90,
lgpg_regions lgpg_size,
sys0 maxuproc=512,
aio0 maxservers='260'
and many ioo parameters to system defaults.
I even removed the mulitplex copy of the redo log.
I tried to proof them that there maybe the problem of the Baan/Oracle connectivity, ie due to message above,http://docs.oracle.com ... read them for configuration information.
http://tahiti.oracle.com ... read them for recommendations.
http://otn.oracle.com ... find the best practices docs.
http://metalink.oracle.com ... look for similar issues to yours.
People that change things, on production boxes, without first determining that metrics indicate they are a good idea, and then determining their impact on a test box, should be sold to zoos as leopard food.
PS: Slowly likely has absolutely nothing to do with anything you touched. First you tune the application. Then you tune the database. Then you tune the operating system. Get out of the way and make the DBAs do their job. -
------Load Dataset into Temp table---------------
SELECT
z.SYSTEMNAME
--,Case when ZXC.[Subsystem Name] <> 'NULL' Then zxc.[SubSystem Name]
--else NULL
--End AS SubSystemName
, CASE
WHEN z.PROV_TAX_ID IN
(SELECT DISTINCT zxc.TIN
FROM dbo.SQS_Provider_Tracking zxc
WHERE zxc.[SubSystem Name] <> 'NULL'
THEN
(SELECT DISTINCT [Subsystem Name]
FROM dbo.SQS_Provider_Tracking zxc
WHERE z.PROV_TAX_ID = zxc.TIN)
End As SubSYSTEMNAME
,z.PROVIDERNAME
,z.STATECODE
,z.PROV_TAX_ID
,z.SRC_PAR_CD
,SUM(z.SEQUEST_AMT) Actual_Sequestered_Amt
, CASE
WHEN z.SRC_PAR_CD IN ('E','O','S','W')
THEN 'Nonpar Waiver'
--**Amendment Mailed**
--WHEN z.PROV_TAX_ID IN
When EXISTS
(SELECT DISTINCT b.PROV_TIN
FROM dbo.SQS_Mailed_TINs_010614 b WITH (NOLOCK )
where not exists (select * from dbo.sqs_objector_TINs t where b.PROV_TIN = t.prov_tin))
THEN
(SELECT DISTINCT b.Mailing
FROM dbo.SQS_Mailed_TINs_010614 b WITH (NOLOCK )
WHERE z.PROV_TAX_ID = b.PROV_TIN
-- --**Amendment Mailed Wave 3 and 4**
--WHEN z.PROV_TAX_ID In
When EXISTS
(SELECT
qz.PROV_TIN
FROM
[SQS_Mailed_TINs] qz WITH (NOLOCK )
where qz.Mailing = 'Amendment Mailed (3rd Wave)'
and not exists (select * from dbo.sqs_objector_TINs t WITH (NOLOCK ) where qz.PROV_TIN = t.prov_tin))
THEN 'Amendment Mailed (3rd Wave)'
WHEN EXISTS
(SELECT
qz.PROV_TIN
FROM
[SQS_Mailed_TINs] qz WITH (NOLOCK )
where qz.Mailing = 'Amendment Mailed (4th Wave)'
and not exists (select * from dbo.sqs_objector_TINs t WITH (NOLOCK ) where qz.PROV_TIN = t.prov_tin))
THEN 'Amendment Mailed (4th Wave)'
-- --Is Puerto Rico of Lifesynch
WHEN EXISTS
(SELECT DISTINCT a.PROV_TAX_ID
FROM PACT.dbo.SQS_NonPar_PR_LS_TINs a WITH (NOLOCK )
WHERE a.Bucket <> 'Nonpar'
THEN
(SELECT DISTINCT a.Bucket
FROM PACT.dbo.SQS_NonPar_PR_LS_TINs a WITH (NOLOCK )
WHERE a.PROV_TAX_ID = z.PROV_TAX_ID)
-- --**Top Objecting Systems**
WHEN z.SYSTEMNAME IN
('ADVENTIST HEALTH SYSTEM','ASCENSION HEALTH ALLIANCE','AULTMAN HEALTH FOUNDATION','BANNER HEALTH SYSTEM','BERT FISH MEDICAL CENTER','BETHESDA MEMORIAL HOSPITAL','BJC HEALTHCARE','BLOUNT MEMORIAL HOSPITAL','BOCA RATON REGIONAL HOSPITAL','CAROMONT HEALTH SYSTEM','CATHOLIC HEALTH INITIATIVES','CATHOLIC HEALTHCARE PARTNERS','CHRISTUS HEALTH',/*'CLEVELAND CLINIC HEALTH SYSTEM',*/'COLUMBUS REGIONAL HEALTHCARE SYSTEM','COMMUNITY HEALTH SYSTEMS, INC','COXHEALTH','HCA','HEALTH MANAGEMENT ASSOCIATES','HUNTSVILLE HOSPITAL HEALTH SYSTEM','INTEGRIS HEALTH','JUPITER MEDICAL CENTER','LEE MEMORIAL HEALTH SYSTEM','MARTIN MEMORIAL HEALTH SYSTEM','MERCY','MT SINAI MEDICAL CENTER (MIAMI)','MUNROE REGIONAL MEDICAL CENTER','NORMAN REGIONAL HEALTH SYSTEM','NORTHSIDE HEALTH SYSTEM','SHANDS HEALTHCARE','SISTERS OF MERCY - SPRINGFIELD, MO','SSM HEALTH CARE','ST LUKES HEALTH SYSTEM','SUMMA HEALTH SYSTEM','SUSQUEHANNA HEALTH SYSTEM','TBD -- TRINITY HEALTH - CATHOLIC HEALTH EAST','UNIVERSITY OF MISSOURI HEALTH SYSTEM','UNIVERSITY OF NEW MEXICO HOSPITALS','UNIVERSITY OF UTAH HEALTH CARE')
THEN 'Top Objecting Systems'
WHEN EXISTS
(SELECT
h.PROV_TAX_ID
FROM
#HIHO_Records h
INNER JOIN SQS_Provider_Tracking obj WITH (NOLOCK )
ON h.PROV_TAX_ID = obj.TIN
AND obj.[Objector?] = 'Top Objector'
WHERE z.PROV_TAX_ID = h.PROV_TAX_ID
OR h.SMG_ID IS NOT NULL
)and z.LCLM_RSTMT_TREND_CAT_CD IN ('HO','HI')
THEN 'Top Objecting Systems'
-- --**Other Objecting Hospitals**
WHEN EXISTS
(SELECT
h.PROV_TAX_ID
FROM
#HIHO_Records h
INNER JOIN SQS_Provider_Tracking obj WITH (NOLOCK )
ON h.PROV_TAX_ID = obj.TIN
AND obj.[Objector?] = 'Objector'
WHERE z.PROV_TAX_ID = h.PROV_TAX_ID
OR h.SMG_ID IS NOT NULL
)and z.LCLM_RSTMT_TREND_CAT_CD IN ('HO','HI')
THEN 'Other Objecting Hospitals'
-- --**Objecting Physicians**
WHEN EXISTS
(SELECT z.PROV_TAX_ID
FROM SQS_EDW_Source z WITH (NOLOCK)
WHERE EXISTS
(SELECT DISTINCT
obj.TIN
FROM SQS_Provider_Tracking obj WITH (NOLOCK )
WHERE obj.[Objector?] in ('Objector','Top Objector')
and z.PROV_TAX_ID = obj.TIN
and z.LCLM_RSTMT_TREND_CAT_CD not IN ('HO','HI')
THEN 'Objecting Physicians'
--****Rejecting Hospitals****
WHEN EXISTS
(SELECT
h.PROV_TAX_ID
FROM
#HIHO_Records h
INNER JOIN SQS_Provider_Tracking obj WITH (NOLOCK )
ON h.PROV_TAX_ID = obj.TIN
AND obj.[Objector?] = 'Rejector'
WHERE z.PROV_TAX_ID = h.PROV_TAX_ID
OR h.SMG_ID IS NOT NULL
)and z.LCLM_RSTMT_TREND_CAT_CD IN ('HO','HI')
THEN 'Rejecting Hospitals'
--****Rejecting Physciains****
WHEN EXISTS
(SELECT obj.TIN
FROM SQS_Provider_Tracking obj WITH (NOLOCK )
WHERE z.PROV_TAX_ID = obj.TIN
AND obj.[Objector?] = 'Rejector')
and z.LCLM_RSTMT_TREND_CAT_CD NOT IN ('HO','HI')
THEN 'REjecting Physicians'
----**********ALL OBJECTORS SHOULD HAVE BEEN BUCKETED AT THIS POINT IN THE QUERY**********
-- --**Non-Objecting Hospitals**
WHEN EXISTS
(SELECT DISTINCT
h.PROV_TAX_ID
FROM
#HIHO_Records h WITH (NOLOCK )
WHERE
(z.PROV_TAX_ID = h.PROV_TAX_ID)
OR h.SMG_ID IS NOT NULL
)and z.LCLM_RSTMT_TREND_CAT_CD IN ('HO','HI')
THEN 'Non-Objecting Hospitals'
-- **Outstanding Contracts for Review**
WHEN EXISTS
(SELECT qz.PROV_TIN
FROM
[PACT].[HUMAD\ARS3766].[SQS_Mailed_TINs] qz WITH (NOLOCK )
where qz.Mailing = 'Non-Objecting Bilateral Physicians'
AND z.PROV_TAX_ID = qz.PROV_TIN)
Then 'Non-Objecting Bilateral Physicians'
When EXISTS
(select
p.prov_tax_id
from dbo.SQS_CoC_Potential_Mail_List p WITH (NOLOCK )
where p.amendmentrights <> 'Unilateral'
AND z.prov_tax_id = p.prov_tax_id)
THEN 'Non-Objecting Bilateral Physicians'
WHEN EXISTS
(SELECT
qz.PROV_TIN
FROM
[SQS_Mailed_TINs] qz WITH (NOLOCK )
where qz.Mailing = 'More Research Needed'
AND qz.PROV_TIN = z.PROV_TAX_ID)
THEN 'More Research Needed'
WHEN EXISTS (SELECT qz.PROV_TIN FROM [SQS_Mailed_TINs] qz WITH (NOLOCK ) where qz.Mailing = 'Objector' AND qz.PROV_TIN = z.PROV_TAX_ID)
THEN 'ERROR'
else 'Market Review/Preparing to Mail'
END AS [Updated Bucket]
,COALESCE(q.INDdesc, f.IND_desc) AS INDdesc
,f.Time_Period_for_Dispute
,f.Renew_Term_Ind
,f.Renewal_Date
,z.SMG_ID
,'' AS OrderedRank
INTO SQS_Bucketed_Details_SMG_on_SMGXXX
From #SQS_EDW_SOURCE_WithSMG z
left join #F f ON f.PROV_TAX_ID = z.PROV_TAX_ID
AND z.SYSTEMNAME = f.SYSTEM_NAME
AND z.PROVIDERNAME = f.Provider
Left join #Q q ON z.PROV_TAX_ID = q.TIN
GROUP BY z.SYSTEMNAME
--,Z.[SubsystemName]
,z.PROVIDERNAME
,z.STATECODE
,z.PROV_TAX_ID
,z.SRC_PAR_CD
,q.INDdesc
,f.IND_Desc
,f.Time_Period_for_Dispute
,f.Renew_Term_Ind
,f.Renewal_Date
,z.SMG_ID
,z.LCLM_RSTMT_TREND_CAT_CD
As I am a developer I do not have the access to Sql profiler or tuning agent to optimize my query, I have used some joins over the temp table #HIHO which indeed pulling the records from table EDW_Source which has 5 million records, I also added Non clustered
indexes on prov_ID, SMG_ID and Incurred month for this table, but still it is taking longer time. Need helpHi, It needs some more tweaks but pls try this one
USE
Go
--****Create sqs_objector_TINs (Objections and Rejections)****
--Drop table .dbo.sqs_objector_TINs
select distinct a.TIN as Prov_TIN
Into #sqs_objector_TINs
from .dbo.sqs_provider_tracking as a with (nolock)
where a.[Objector?] in ('Top Objector','Objector','Rejector')
/*********** Query for SQS_TINtoSyst***********/
--DROP TABLE .dbo.SQS_TINtoSystem
select distinct
b.SRC_PROV_ID
--,case
-- when a.SYSTEM_NAME is null
-- then
-- case
-- when a.CTRCT_GRP_NAME is null
-- then a.PROV_SMG_NAME
-- else a.CTRCT_GRP_NAME
-- end
-- else a.SYSTEM_NAME
--end as SYSTEM_NAME
,COALESCE(a.SYSTEM_NAME, a.CTRCT_GRP_NAME, a.PROV_SMG_NAME) AS SYSTEM_NAME
INTO #SQS_TINtoSystem
from
PARE.dbo.EDW_PROD_HOSPITAL_MASTER a with (nolock)
Inner Join PARE.dbo.EDW_PROD_HOSPITAL_ID_XREF b with (nolock)
on a.SMG_ID = b.SMG_ID
-- Inner Join .dbo.SQS_EDW_Source q
--on b.SRC_PROV_ID = q.PROV_TAX_ID
where b.SRC_PLATFORM_CD = 'TX'
and exists
select
SMG_ID
from PARE.dbo.EDW_PROD_HOSPITAL_ID_XREF as t1 with (nolock)
where SRC_PLATFORM_CD = 'TX'
and exists (select q.PROV_TAX_ID from .dbo.SQS_EDW_Source q with (nolock) where q.PROV_TAX_ID = b.SRC_PROV_ID)
and a.SMG_ID = t1.SMG_ID
/************** Query for SQS_Bucketed_Details_SMG*****************/
DROP TABLE .dbo.SQS_Bucketed_Details_SMG
--Create temp table
SELECT z.SYSTEMNAME
,Z.PROV_TAX_ID
,z.PROVIDERNAME
,z.STATECODE
,z.SRC_PAR_CD
,z.SEQUEST_AMT
,case when Z.LCLM_RSTMT_TREND_CAT_CD IN ('HI','HO') Then 'H' else 'P' end as Hosp_Ind
,Z.SMG_ID
INTO #SQS_EDW_SOURCE_WithSMG
FROM dbo.SQS_EDW_SOURCE_WithSMG z with (nolock)
WHERE (Z.Incurred_Mth >= convert(datetime,'01/01/2013')) and (Z.Incurred_Mth < convert(datetime, '1/1/2014'))
--between convert(datetime,'01/01/2013') and convert(datetime, '12/31/2013 23:59:59.996')
--YEAR(Z.Incurred_Mth)=2013
-- Create Temp table Q
select
x.TIN,
case when max(x.IND) = 'NYN'
then 'Standard'
when max(x.IND) = 'YNN'
then 'Express'
when max(x.IND) = 'NNY'
then 'Non_Standard' else 'Mixed'
end as INDdesc
Into #Q
FROM
(SELECT
a.tin,
MAX(a.express) + MAX(a.StandardInd) + MAX(NonstandardIND) as IND
from
(select r.TIN,
case when MAX(r.Express) like 'Y%' then 'Y' else 'N' end As Express,
case when MAX(r.Standard) = 'Y' then 'Y' else 'N' end As StandardInd,
case when MAX(r.[Non-Standard]) = 'Y' then 'Y' else 'N' end AS NonstandardIND
FROM DBO.SQS_Objectors_01032014 r with (nolock)
GROUP BY r.TIN) a
group by a.TIN) x
group by x.TIN
--Create Temp table F
Select *
INTO #F
FROM(
SELECT distinct g.prov_tax_id
,g.system_name
,g.provider
,case when g.reimburse_mixed = 'Y' then 'Mixed'
when g.reimburse_express = 'Y' then 'Express'
when g.reimburse_standard = 'Y' then 'Standard'
when g.reimburse_NonStandard = 'Y' then 'NonStandard'
end as IND_Desc
,g.Time_Period_for_Dispute
,case when g.Renewal_Date = 'N' and g.Expiration_Date = 'N'
then 'Unclear'
when g.Renewal_Date = 'N' and g.Expiration_Date <> 'N'
then 'Termination'
when g.Renewal_Date <> 'N' and g.Expiration_Date = 'N'
then 'Evergreen'
when g.Renewal_Date <> 'N' and g.Expiration_Date <> 'N'
then 'Termination'
else 'Unknown'
end as 'Renew_Term_Ind'
,g.Renewal_Date
FROM
(select distinct
bb.PROV_TAX_ID1 as prov_tax_id
,aa.*
from
[dbo].[Top_600_Hospitals3] aa with (nolock)
left join pare.dbo.EDW_PROD_HOSPITAL_MASTER bb with (nolock)
on --a.CTRCT_GRP_NAME = b.CTRCT_GRP_NAME
aa.Provider = bb.PROV_SMG_NAME
-- and (a.SYSTEM_NAME = b.SMG_SYS_NAME or a.SYSTEM_NAME = b.SYSTEM_NAME)
--and a.ADDR_LINE1 = b.ADDR_LINE1
and aa.STATE_CD = bb.STATE_CD
--and a.ZIP_CD = b.ZIP_CD
and aa.City1 = bb.CITY_NAME
where aa.SYSTEM_NAME <> 'SEE ABOVE') g
where g.system_name <> 'SEE ABOVE') h
where h.ind_Desc is not null
SELECT DISTINCT z.PROV_TAX_ID
, z.SMG_ID
INTO #HIHO_Records
FROM SQS_EDW_SOURCE_WithSMG z with (nolock)
WHERE z.LCLM_RSTMT_TREND_CAT_CD IN ('HO', 'HI')
AND Z.Incurred_Mth >=convert(datetime, '1/1/2013') and Z.Incurred_Mth <convert(datetime, '1/1/2014')
--YEAR(Z.Incurred_Mth)=2013
---------------------------------Load Dataset into Temp table---------------
SELECT
z.SYSTEMNAME
--,Case when ZXC.[Subsystem Name] <> 'NULL' Then zxc.[SubSystem Name]
--else NULL
--End AS SubSystemName
, CASE
WHEN z.PROV_TAX_ID IN
(SELECT zxc.TIN
FROM dbo.SQS_Provider_Tracking zxc with (nolock)
WHERE zxc.[SubSystem Name] <> 'NULL'
THEN
(SELECT top 1 [Subsystem Name]
FROM dbo.SQS_Provider_Tracking zxc with (nolock)
WHERE z.PROV_TAX_ID = zxc.TIN)
End As SubSYSTEMNAME
,z.PROVIDERNAME
,z.STATECODE
,z.PROV_TAX_ID
,z.SRC_PAR_CD
,SUM(z.SEQUEST_AMT) Actual_Sequestered_Amt
, CASE
WHEN z.SRC_PAR_CD IN ('E','O','S','W')
THEN 'Nonpar Waiver'
-- --Is Puerto Rico of Lifesynch
WHEN z.PROV_TAX_ID IN
(SELECT a.PROV_TAX_ID
FROM .dbo.SQS_NonPar_PR_LS_TINs a with (nolock)
WHERE a.Bucket <> 'Nonpar'
THEN
(SELECT top 1 a.Bucket
FROM .dbo.SQS_NonPar_PR_LS_TINs a with (nolock)
WHERE a.PROV_TAX_ID = z.PROV_TAX_ID)
--**Amendment Mailed**
WHEN z.PROV_TAX_ID IN
(SELECT b.PROV_TIN
FROM dbo.SQS_Mailed_TINs_010614 b WITH (NOLOCK )
where not exists (select * from dbo.sqs_objector_TINs t with (nolock) where b.PROV_TIN = t.prov_tin))
and z.Hosp_Ind = 'P'
THEN
(SELECT top 1 b.Mailing
FROM dbo.SQS_Mailed_TINs_010614 b with (nolock)
WHERE z.PROV_TAX_ID = b.PROV_TIN
-- --**Amendment Mailed Wave 3-5**
WHEN z.PROV_TAX_ID In
(SELECT
qz.PROV_TIN
FROM
[SQS_Mailed_TINs] qz
where qz.Mailing = 'Amendment Mailed (3rd Wave)'
and not exists (select * from dbo.sqs_objector_TINs t with (nolock) where qz.PROV_TIN = t.prov_tin))
and z.Hosp_Ind = 'P'
THEN 'Amendment Mailed (3rd Wave)'
WHEN z.PROV_TAX_ID IN
(SELECT
qz.PROV_TIN
FROM
[SQS_Mailed_TINs] qz
where qz.Mailing = 'Amendment Mailed (4th Wave)'
and not exists (select * from dbo.sqs_objector_TINs t with (nolock) where qz.PROV_TIN = t.prov_tin))
and z.Hosp_Ind = 'P'
THEN 'Amendment Mailed (4th Wave)'
WHEN z.PROV_TAX_ID IN
(SELECT
qz.PROV_TIN
FROM
[SQS_Mailed_TINs] qz
where qz.Mailing = 'Amendment Mailed (5th Wave)'
and not exists (select * from dbo.sqs_objector_TINs t with (nolock) where qz.PROV_TIN = t.prov_tin))
and z.Hosp_Ind = 'P'
THEN 'Amendment Mailed (5th Wave)'
-- --**Top Objecting Systems**
WHEN z.SYSTEMNAME IN
('ADVENTIST HEALTH SYSTEM','ASCENSION HEALTH ALLIANCE','AULTMAN HEALTH FOUNDATION')
THEN 'Top Objecting Systems'
WHEN z.PROV_TAX_ID IN
(SELECT
h.PROV_TAX_ID
FROM
#HIHO_Records h
INNER JOIN .dbo.SQS_Provider_Tracking obj with (nolock)
ON h.PROV_TAX_ID = obj.TIN
AND obj.[Objector?] = 'Top Objector'
WHERE z.PROV_TAX_ID = h.PROV_TAX_ID
OR h.SMG_ID IS NOT NULL
)and z.Hosp_Ind = 'H'
THEN 'Top Objecting Systems'
-- --**Other Objecting Hospitals**
WHEN (z.PROV_TAX_ID IN
(SELECT
h.PROV_TAX_ID
FROM
#HIHO_Records h
INNER JOIN .dbo.SQS_Provider_Tracking obj with (nolock)
ON h.PROV_TAX_ID = obj.TIN
AND obj.[Objector?] = 'Objector'
WHERE z.PROV_TAX_ID = h.PROV_TAX_ID
OR h.SMG_ID IS NOT NULL
)and z.Hosp_Ind = 'H')
THEN 'Other Objecting Hospitals'
-- --**Objecting Physicians**
WHEN (z.PROV_TAX_ID IN
(SELECT
obj.TIN
FROM .dbo.SQS_Provider_Tracking obj with (nolock)
WHERE obj.[Objector?] in ('Objector','Top Objector')
and z.PROV_TAX_ID = obj.TIN
and z.Hosp_Ind = 'P')
THEN 'Objecting Physicians'
--****Rejecting Hospitals****
WHEN (z.PROV_TAX_ID IN
(SELECT
h.PROV_TAX_ID
FROM
#HIHO_Records h
INNER JOIN .dbo.SQS_Provider_Tracking obj with (nolock)
ON h.PROV_TAX_ID = obj.TIN
AND obj.[Objector?] = 'Rejector'
WHERE z.PROV_TAX_ID = h.PROV_TAX_ID
OR h.SMG_ID IS NOT NULL
)and z.Hosp_Ind = 'H')
THEN 'Rejecting Hospitals'
--****Rejecting Physciains****
WHEN
(z.PROV_TAX_ID IN
(SELECT
obj.TIN
FROM .dbo.SQS_Provider_Tracking obj with (nolock)
WHERE z.PROV_TAX_ID = obj.TIN
AND obj.[Objector?] = 'Rejector')
and z.Hosp_Ind = 'P')
THEN 'REjecting Physicians'
----**********ALL OBJECTORS SHOULD HAVE BEEN BUCKETED AT THIS POINT IN THE QUERY**********
-- --**Non-Objecting Hospitals**
WHEN z.PROV_TAX_ID IN
(SELECT
h.PROV_TAX_ID
FROM
#HIHO_Records h
WHERE
(z.PROV_TAX_ID = h.PROV_TAX_ID)
OR h.SMG_ID IS NOT NULL)
and z.Hosp_Ind = 'H'
THEN 'Non-Objecting Hospitals'
-- **Outstanding Contracts for Review**
WHEN z.PROV_TAX_ID IN
(SELECT
qz.PROV_TIN
FROM
[SQS_Mailed_TINs] qz with (nolock)
where qz.Mailing = 'Non-Objecting Bilateral Physicians'
AND z.PROV_TAX_ID = qz.PROV_TIN)
Then 'Non-Objecting Bilateral Physicians'
When z.prov_tax_id in
(select
p.prov_tax_id
from dbo.SQS_CoC_Potential_Mail_List p with (nolock)
where p.amendmentrights <> 'Unilateral'
AND z.prov_tax_id = p.prov_tax_id)
THEN 'Non-Objecting Bilateral Physicians'
WHEN z.PROV_TAX_ID IN
(SELECT
qz.PROV_TIN
FROM
[SQS_Mailed_TINs] qz
where qz.Mailing = 'More Research Needed'
AND qz.PROV_TIN = z.PROV_TAX_ID)
THEN 'More Research Needed'
WHEN z.PROV_TAX_ID IN (SELECT qz.PROV_TIN FROM [SQS_Mailed_TINs] qz with (nolock) where qz.Mailing = 'Objector' AND qz.PROV_TIN = z.PROV_TAX_ID)
THEN 'ERROR'
else 'Market Review/Preparing to Mail'
END AS [Updated Bucket]
,COALESCE(q.INDdesc, f.IND_desc) AS INDdesc
,f.Time_Period_for_Dispute
,f.Renew_Term_Ind
,f.Renewal_Date
,z.SMG_ID
,'' AS OrderedRank
INTO dbo.SQS_Bucketed_Details_SMG with (nolock)
From #SQS_EDW_SOURCE_WithSMG z
left join #F f ON f.PROV_TAX_ID = z.PROV_TAX_ID
AND z.SYSTEMNAME = f.SYSTEM_NAME
AND z.PROVIDERNAME = f.Provider
Left join #Q q ON z.PROV_TAX_ID = q.TIN
GROUP BY z.SYSTEMNAME
--,Z.[SubsystemName]
,z.PROVIDERNAME
,z.STATECODE
,z.PROV_TAX_ID
,z.SRC_PAR_CD
,q.INDdesc
,f.IND_Desc
,f.Time_Period_for_Dispute
,f.Renew_Term_Ind
,f.Renewal_Date
,z.SMG_ID
,z.Hosp_Ind
/************************** Drop temp tables*********************/
--DROP TABLE #SQS_EDW_SOURCE_WithSMG
--DROP TABLE #Q
--DROP TABLE #F
--DROP TABLE #HIHO_Records
--DROP TABLE #SQS_TINtoSystem
--DROP TABLE #SQS_EDW_SOURCE_WithSMG
--DROP TABLE #sqs_objector_TINs -
Query optimization - Query is taking long time even there is no table scan in execution plan
Hi All,
The below query execution is taking very long time even there are all required indexes present.
Also in execution plan there is no table scan. I did a lot of research but i am unable to find a solution.
Please help, this is required very urgently. Thanks in advance. :)
WITH cte
AS (
SELECT Acc_ex1_3
FROM Acc_ex1
INNER JOIN Acc_ex5 ON (
Acc_ex1.Acc_ex1_Id = Acc_ex5.Acc_ex5_Id
AND Acc_ex1.OwnerID = Acc_ex5.OwnerID
WHERE (
cast(Acc_ex5.Acc_ex5_92 AS DATETIME) >= '12/31/2010 18:30:00'
AND cast(Acc_ex5.Acc_ex5_92 AS DATETIME) < '01/31/2014 18:30:00'
SELECT DISTINCT R.ReportsTo AS directReportingUserId
,UC.UserName AS EmpName
,UC.EmployeeCode AS EmpCode
,UEx1.Use_ex1_1 AS PortfolioCode
SELECT TOP 1 TerritoryName
FROM UserTerritoryLevelView
WHERE displayOrder = 6
AND UserId = R.ReportsTo
) AS BranchName
,GroupsNotContacted AS groupLastContact
,GroupCount AS groupTotal
FROM ReportingMembers R
INNER JOIN TeamMembers T ON (
T.OwnerID = R.OwnerID
AND T.MemberID = R.ReportsTo
AND T.ReportsTo = 1
INNER JOIN UserContact UC ON (
UC.CompanyID = R.OwnerID
AND UC.UserID = R.ReportsTo
INNER JOIN Use_ex1 UEx1 ON (
UEx1.OwnerId = R.OwnerID
AND UEx1.Use_ex1_Id = R.ReportsTo
INNER JOIN (
SELECT Accounts.AssignedTo
,count(DISTINCT Acc_ex1_3) AS GroupCount
FROM Accounts
INNER JOIN Acc_ex1 ON (
Accounts.AccountID = Acc_ex1.Acc_ex1_Id
AND Acc_ex1.Acc_ex1_3 > '0'
AND Accounts.OwnerID = 109
GROUP BY Accounts.AssignedTo
) TotalGroups ON (TotalGroups.AssignedTo = R.ReportsTo)
INNER JOIN (
SELECT Accounts.AssignedTo
,count(DISTINCT Acc_ex1_3) AS GroupsNotContacted
FROM Accounts
INNER JOIN Acc_ex1 ON (
Accounts.AccountID = Acc_ex1.Acc_ex1_Id
AND Acc_ex1.OwnerID = Accounts.OwnerID
AND Acc_ex1.Acc_ex1_3 > '0'
INNER JOIN Acc_ex5 ON (
Accounts.AccountID = Acc_ex5.Acc_ex5_Id
AND Acc_ex5.OwnerID = Accounts.OwnerID
WHERE Accounts.OwnerID = 109
AND Acc_ex1.Acc_ex1_3 NOT IN (
SELECT Acc_ex1_3
FROM cte
GROUP BY Accounts.AssignedTo
) TotalGroupsNotContacted ON (TotalGroupsNotContacted.AssignedTo = R.ReportsTo)
WHERE R.OwnerID = 109
Please mark it as an answer/helpful if you find it as useful. Thanks, Satya Prakash JugranHi All,
Thanks for the replies.
I have optimized that query to make it run in few seconds.
Here is my final query.
select ReportsTo as directReportingUserId,
UserName AS EmpName,
EmployeeCode AS EmpCode,
Use_ex1_1 AS PortfolioCode,
BranchName,
GroupInfo.groupTotal,
GroupInfo.groupLastContact,
case when exists
(select 1 from ReportingMembers RM
where RM.ReportsTo = UserInfo.ReportsTo
and RM.MemberID <> UserInfo.ReportsTo
) then 0 else UserInfo.ReportsTo end as memberid1,
(select code from Regions where ownerid=109 and name=UserInfo.BranchName) as BranchCode,
ROW_NUMBER() OVER (ORDER BY directReportingUserId) AS ROWNUMBER
FROM
(select distinct R.ReportsTo, UC.UserName, UC.EmployeeCode,UEx1.Use_ex1_1,
(select top 1 TerritoryName
from UserTerritoryLevelView
where displayOrder = 6
and UserId = R.ReportsTo) as BranchName,
Case when R.ReportsTo = Accounts.AssignedTo then Accounts.AssignedTo else 0 end as memberid1
from ReportingMembers R
INNER JOIN TeamMembers T ON (T.OwnerID = R.OwnerID AND T.MemberID = R.ReportsTo AND T.ReportsTo = 1)
inner join UserContact UC on (UC.CompanyID = R.OwnerID and UC.UserID = R.ReportsTo )
inner join Use_ex1 UEx1 on (UEx1.OwnerId = R.OwnerID and UEx1.Use_ex1_Id = R.ReportsTo)
inner join Accounts on (Accounts.OwnerID = 109 and Accounts.AssignedTo = R.ReportsTo)
union
select distinct R.ReportsTo, UC.UserName, UC.EmployeeCode,UEx1.Use_ex1_1,
(select top 1 TerritoryName
from UserTerritoryLevelView
where displayOrder = 6
and UserId = R.ReportsTo) as BranchName,
Case when R.ReportsTo = Accounts.AssignedTo then Accounts.AssignedTo else 0 end as memberid1
from ReportingMembers R
--INNER JOIN TeamMembers T ON (T.OwnerID = R.OwnerID AND T.MemberID = R.ReportsTo)
inner join UserContact UC on (UC.CompanyID = R.OwnerID and UC.UserID = R.ReportsTo)
inner join Use_ex1 UEx1 on (UEx1.OwnerId = R.OwnerID and UEx1.Use_ex1_Id = R.ReportsTo)
inner join Accounts on (Accounts.OwnerID = 109 and Accounts.AssignedTo = R.ReportsTo)
where R.MemberID = 1
) UserInfo
inner join
select directReportingUserId, sum(Groups) as groupTotal, SUM(GroupsNotContacted) as groupLastContact
from
select distinct R.ReportsTo as directReportingUserId, Acc_ex1_3 as GroupName, 1 as Groups,
case when Acc_ex5.Acc_ex5_92 between GETDATE()-365*10 and GETDATE() then 1 else 0 end as GroupsNotContacted
FROM ReportingMembers R
INNER JOIN TeamMembers T
ON (T.OwnerID = R.OwnerID AND T.MemberID = R.ReportsTo AND T.ReportsTo = 1)
inner join Accounts on (Accounts.OwnerID = 109 and Accounts.AssignedTo = R.ReportsTo)
inner join Acc_ex1 on (Acc_ex1.OwnerID = 109 and Acc_ex1.Acc_ex1_Id = Accounts.AccountID and Acc_ex1.Acc_ex1_3 > '0')
inner join Acc_ex5 on (Acc_ex5.OwnerID = 109 and Acc_ex5.Acc_ex5_Id = Accounts.AccountID )
--where TerritoryID in ( select ChildRegionID RegionID from RegionWithSubRegions where OwnerID =109 and RegionID = 729)
union
select distinct R.ReportsTo as directReportingUserId, Acc_ex1_3 as GroupName, 1 as Groups,
case when Acc_ex5.Acc_ex5_92 between GETDATE()-365*10 and GETDATE() then 1 else 0 end as GroupsNotContacted
FROM ReportingMembers R
INNER JOIN TeamMembers T
ON (T.OwnerID = R.OwnerID AND T.MemberID = R.ReportsTo)
inner join Accounts on (Accounts.OwnerID = 109 and Accounts.AssignedTo = R.ReportsTo)
inner join Acc_ex1 on (Acc_ex1.OwnerID = 109 and Acc_ex1.Acc_ex1_Id = Accounts.AccountID and Acc_ex1.Acc_ex1_3 > '0')
inner join Acc_ex5 on (Acc_ex5.OwnerID = 109 and Acc_ex5.Acc_ex5_Id = Accounts.AccountID )
--where TerritoryID in ( select ChildRegionID RegionID from RegionWithSubRegions where OwnerID =109 and RegionID = 729)
where R.MemberID = 1
) GroupWiseInfo
group by directReportingUserId
) GroupInfo
on UserInfo.ReportsTo = GroupInfo.directReportingUserId
Please mark it as an answer/helpful if you find it as useful. Thanks, Satya Prakash Jugran -
Where would you check performance of webi? query is taking long time to run
Hello All,
In the bex query world running on portal you were able to go to sm50 and check what the query is doing and where it is taking a long time or atleast you were able to see the processes runing.
Where would you check the running processes when you are running a webi query, we are trying to write a webi report which is on universe which is created on bex query. The report is very simple just two fields and an mandatory variable which is coming from bex query (have defined the variable in bex query). When we exeute the query it is taking a long time just spinning and I am not getting any data back, on the same query before even hitting the run query button, I am trying to put a object in query filters and set the filter as In list from Value(s) from list and it is taking forever to set that filter.
Can we go to CMC or BW backend and check anywhere we are using sap authentication, I see the number of sessions in CMC but that is it.
Thanks for help in advance.Thank you both for the replies.
How would I get the MDX that is generated by the query, I remember there is a note for starting the MDX logging. Can you please let em know how would I get the MDX statement. Thanks.
Gowtham - What is the optimal array fetch size that needs to set for the universes, can you explain bit more about array fetch size?
All our universes are on BEx queries designed in SAP BW in that case does the array fetch size matter and array bind size matter? I had read this in oneof the universe designer manuals for OLAP universes The Array fetch size, Array bind size, and Login timeout parameters are not used for OLAP connections
Thanks again for replies. -
Query is taking long time to execute after migrating to 10g r2
Hi
We recently migrated the database from 9i to 10gr2 ((10.2.0.2.0).. This query was running in acceptable time before the upgrade in 9i.. Now it is taking a long long time to execute this... Can you please let me know what should i do to improve the performance now.. We are running stats everyday..
Thanks for your help,
Shree
======================================================================================
SELECT cr.cash_receipt_id
,cr.pay_from_customer
,cr.receipt_number
,cr.receipt_date
,cr.amount
,cust.account_number
,crh.gl_date
,cr.set_of_books_id
,sum(ra.amount_applied) amount_applied
FROM AR_CASH_RECEIPTS_ALL cr
,AR_RECEIVABLE_APPLICATIONS_ALL ra
,hz_cust_accounts cust
,AR_CASH_RECEIPT_HISTORY_ALL crh
,GL_PERIOD_STATUSES gps
,FND_APPLICATION app
WHERE cr.cash_receipt_id = ra.cash_receipt_id
AND ra.status = 'UNAPP'
AND cr.status <> 'REV'
AND cust.cust_account_id = cr.pay_from_customer
AND substr(cust.account_number,1,2) <> 'SI' -- Don't allocate Unapplied receipts FOR SI customers
AND crh.cash_receipt_id = cr.cash_receipt_id
AND app.application_id = gps.application_id
AND app.application_short_name = 'AR'
AND gps.period_name = 'May-07'
AND crh.gl_date <= gps.end_date
AND cr.receipt_number not like 'WH%'
-- AND cust.customer_number = '0000079260001'
GROUP BY cr.cash_receipt_id
,cr.pay_from_customer
,cr.receipt_number
,cr.receipt_date
,cr.amount
,cust.account_number
,crh.gl_date
,cr.set_of_books_id
HAVING sum(ra.amount_applied) > 0;
=========================================================================================
Here is the explain plan in 10g r2 (10.2.0.2.0)
PLAN_TABLE_OUTPUT
Plan hash value: 2617075047
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)|
| 0 | SELECT STATEMENT | | 92340 | 10M| | 513K (1)|
|* 1 | FILTER | | | | | |
| 2 | HASH GROUP BY | | 92340 | 10M| 35M| 513K (1)|
| 3 | TABLE ACCESS BY INDEX ROWID | AR_RECEIVABLE_APPLICATIONS_ALL | 2 | 34 |
| 4 | NESTED LOOPS | | 184K| 21M| | 510K (1)|
|* 5 | HASH JOIN | | 99281 | 9M| 3296K| 176K (1)|
|* 6 | TABLE ACCESS FULL | HZ_CUST_ACCOUNTS | 112K| 1976K| | 22563 (1)|
|* 7 | HASH JOIN | | 412K| 33M| 25M| 151K (1)|
| 8 | TABLE ACCESS BY INDEX ROWID | AR_CASH_RECEIPT_HISTORY_ALL | 332K| 4546K|
| 9 | NESTED LOOPS | | 498K| 19M| | 26891 (1)|
| 10 | NESTED LOOPS | | 2 | 54 | | 4 (0)|
| 11 | TABLE ACCESS BY INDEX ROWID| FND_APPLICATION | 1 | 8 | | 1 (0)|
|* 12 | INDEX UNIQUE SCAN | FND_APPLICATION_U3 | 1 | | | 0 (0)|
| 13 | TABLE ACCESS BY INDEX ROWID| GL_PERIOD_STATUSES | 2 | 38 | | 3 (0)
|* 14 | INDEX RANGE SCAN | GL_PERIOD_STATUSES_U1 | 1 | | | 2 (0)|
|* 15 | INDEX RANGE SCAN | AR_CASH_RECEIPT_HISTORY_N2 | 332K| | | 1011 (1)
PLAN_TABLE_OUTPUT
|* 16 | TABLE ACCESS FULL | AR_CASH_RECEIPTS_ALL | 5492K| 235M| | 108K
|* 17 | INDEX RANGE SCAN | AR_RECEIVABLE_APPLICATIONS_N1 | 4 | | | 2
Predicate Information (identified by operation id):
1 - filter(SUM("RA"."AMOUNT_APPLIED")>0)
5 - access("CUST"."CUST_ACCOUNT_ID"="CR"."PAY_FROM_CUSTOMER")
6 - filter(SUBSTR("CUST"."ACCOUNT_NUMBER",1,2)<>'SI')
7 - access("CRH"."CASH_RECEIPT_ID"="CR"."CASH_RECEIPT_ID")
12 - access("APP"."APPLICATION_SHORT_NAME"='AR')
14 - access("APP"."APPLICATION_ID"="GPS"."APPLICATION_ID" AND "GPS"."PERIOD_NAME"='May-07')
filter("GPS"."PERIOD_NAME"='May-07')
15 - access("CRH"."GL_DATE"<="GPS"."END_DATE")
16 - filter("CR"."STATUS"<>'REV' AND "CR"."RECEIPT_NUMBER" NOT LIKE 'WH%')
17 - access("CR"."CASH_RECEIPT_ID"="RA"."CASH_RECEIPT_ID" AND "RA"."STATUS"='UNAPP')
filter("RA"."CASH_RECEIPT_ID" IS NOT NULL)
Here is the explain plan in 9i
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=445977 Card=78530 By
tes=9423600)
1 0 FILTER
2 1 SORT (GROUP BY) (Cost=445977 Card=78530 Bytes=9423600)
3 2 HASH JOIN (Cost=443717 Card=157060 Bytes=18847200)
4 3 HASH JOIN (Cost=99563 Card=94747 Bytes=9758941)
5 4 TABLE ACCESS (FULL) OF 'HZ_CUST_ACCOUNTS' (Cost=12
286 Card=110061 Bytes=1981098)
6 4 HASH JOIN (Cost=86232 Card=674761 Bytes=57354685)
7 6 TABLE ACCESS (BY INDEX ROWID) OF 'AR_CASH_RECEIP
T_HISTORY_ALL' (Cost=17532 Card=542304 Bytes=7592256)
8 7 NESTED LOOPS (Cost=17536 Card=809791 Bytes=332
01431)
9 8 NESTED LOOPS (Cost=4 Card=1 Bytes=27)
10 9 TABLE ACCESS (BY INDEX ROWID) OF 'FND_APPL
ICATION' (Cost=1 Card=1 Bytes=8)
11 10 INDEX (UNIQUE SCAN) OF 'FND_APPLICATION_
U3' (UNIQUE)
12 9 TABLE ACCESS (BY INDEX ROWID) OF 'GL_PERIO
D_STATUSES' (Cost=3 Card=1 Bytes=19)
13 12 INDEX (RANGE SCAN) OF 'GL_PERIOD_STATUSE
S_U1' (UNIQUE) (Cost=2 Card=1)
14 8 INDEX (RANGE SCAN) OF 'AR_CASH_RECEIPT_HISTO
RY_N2' (NON-UNIQUE) (Cost=1740 Card=542304)
15 6 TABLE ACCESS (FULL) OF 'AR_CASH_RECEIPTS_ALL' (C
ost=60412 Card=8969141 Bytes=394642204)
16 3 TABLE ACCESS (FULL) OF 'AR_RECEIVABLE_APPLICATIONS_A
LL' (Cost=337109 Card=15613237 Bytes=265425029)Hi,
The plan between 9i and 10g is pretty the same but the amount of data fetched has considerably increased. I guess the query was performing slow even in 9i.
The AR_CASH_RECEIPT_HISTORY_ALL is presently having 332000 rows in 10g where as it was 17532 in 9i.
AR_CASH_RECEIPT_HISTORY_N2 is now having 332,000 rows in 10g where as in 9i it had 1,740
Try creating some indexes on
AR_CASH_RECEIPTS_ALL
hz_cust_accounts -
Taking long time in displaying the messages in SXMB_MONI
Dear All,
When I go to SXMB_MONI to display messages, it takes very long time in displaying the messgaes.
And when i double clicks on any message to see its details then also it takes very long in opening the details. During this period server also becomes so much slow that it becomes very difficult to even open any other screen on the server and it looks as server has got hanged up. But after a long wait once the messages are displayed in SXMB_MONI then the server behaves normally.
Kindly suggest what might be the error.
Regards,
NJHi,
Please check in tcode SM50, if there are any archiving, deletion jobs are scheduled or check in SXMB_ADMIN-->Persistence layer analysis if the level is too high, schedule the switch delete procedure.Also check in ST06 what is the Utilization %.
Thanks! -
Query regarding the ActiveSync and parameter time-taken from ActiveSync IIS logs.
Here what I see for from the logs.
[email protected] 45.101.90.185 Apple-iPad2C3/1202.410 200 0 0 1501129
443 [email protected] 45.101.90.185 Apple-iPad2C3/1202.410 200
0 0 22105
443 [email protected] 45.101.90.185 Apple-iPad2C3/1202.410 200
0 0 452
443 [email protected] 45.101.90.185 Apple-iPad2C3/1202.410 200
0 0 936
443 [email protected] 45.101.90.185 Apple-iPad2C3/1202.410 200
0 0 656238
In the above log, highlighted are the time-taken and I just want to check what is the ideal time-taken value, some value above should be causing some problem, like the one of the top 1501129 ?
?AND I see its for POST event and CMD=Ping&log query.......
We have Mobile Iron in the environment and we are seeing few timeout errors on MobileIron server and for users intermittently. They usually see below error... However we don't see any end users issues, but just want to get rid of below error. MobileIron guys
are pointing it to time-taken value which is high intermittently.
IOException connection to server [email protected] -- java.io.IOException:
awaitUninterruptibly was stopped by timeout
@BALAHi,
To understand more about the issue, I’d like to confirm the following information:
1. What’s your Exchange 2010 version?
http://support.microsoft.com/kb/2536517/en-us
2. Do you install other software, like SQL, on the same Exchange Server?
3. Change another admin account to access EMS.
Thanks,
Angela Shi
TechNet Community Support -
BEA query is taking long time to run
Hi All,
I am using BEA Weblogic 10.2. I am performing seraching in the repository.
The query string is:
cm_lifeCycleStatus==4&&SERVICE == 'RBT' &©RIGHTTO >= toDate('yyyy-MM-dd', '2010-07-01')&©RIGHTFROM <= toDate('yyyy-MM-dd', '2010-07-01')
Here SERVICE,COPYRIGHTTO,COPYRIGHTFROM are the property.
If i am using cm_midifiedDate instead of COPYRIGHTTO,COPYRIGHTFROM , it giving result very fast.
But the the need is to use COPYRIGHTTO,COPYRIGHTFROM .
Please suggest me how can i optimize this query.
The code to fecth is:
ctx = new ContentContext(this.getRequest());
IVersionManager ivm = ContentManagerFactory.getVersionManager();
Expression exp = ExpressionHelper.parse(query);
Search search = new Search();
search.setExpression(exp);
search.setFullTextSearch(false);
nodeList = ivm.search(ctx, search);
Thnaks
ArvindI'm not completely sure that the Version tables have indices that are optimized for query performance. Based on your original post, I'm assuming that you are eventually getting the correct results back but it just takes too long? You might want to do some database diagnostics to see how the query is being executed and if any index is being consulted. I would assume not and that is where your performance issue might be coming from. The published content tables (such as CM_NODE) are optimized for query response.
Explicit properties only apply to the Published CM_NODE table. To do this, you'd add a column to the CM_NODE database table, ensure that the datatype on the column matches your desired Property data type. Then, in your Content Type definition, in the Portal Admin, you'd mark the "Is Explicit" attribute on the Property and enter the name of the database column which you created to store the values. Of course, in the database, you'd probably want to create an index on this new column to make it faster for searching.
Brad
Maybe you are looking for
-
All my Garage Band songs are gone in the app after I uploaded to iCloud.
All my Garage Band songs are gone in the app after I uploaded to iCloud. Where can I retrieve the songs? iCloud doesn't show any Garage Band folder backup. Help please!!!
-
How to Print Margin of subsequent template (Report Builder 6.05.32.0)
My report consists of 3 parts, part A, B and C. Each part is of different style. Therefore I use 3 templates, each for each style. Part A appears first, then B and C. Part A (based on template A): - Top margin is printed Part B (based on template B):
-
Rogue detection with Prime 2.1
Hi@all, i know many questions in the last days, but i must say, the last WCS works better as the compination Prime 2.1 and 5760 ;). My problem, we have a huge campus and at peaks ~ 1500 rogue-aps. In my new configuration (2x 5760 and Prime 2.1), the
-
Loading a flash inside another flash
i want to know how i can load a flash inside another flash container
-
Photoshop CS4 too slow to open files
Hello all, I have a problem, when I open a file on Photoshop CS4, the program open this slowly. I tried with image of various dimensions also 20kb and located on desktop, but photoshop it's always too slow. Can you help me??? Thanks