Performance tuning needed for a query.
Hi all,
I am facing problem to extract data and insert into another table. I need to fetch part number from all_parts_already and then based on the result I need to extract place from all_parts and insert into all_parts_already.
Sample data in the tables:
table all_parts_already:
part part_desc technique company place
1 A Engine TVS B1
1 Av Engine TVS B2
1 Ab Engine TVS B3
2 Ah Engine TVS B3
2 Ap Engine TVS B2
table all_parts:
technique company place
Engine TVS B1
Kim TVS B2
Engine TVS B3
Engine TVS B4
XXXXX TVS B5
Engine TVS B6
for c1 in (select distinct parts from all_parts_already where
technique = 'Engine' and
Company = 'TVS' ) loop
for c2 in (select distinct place from all_parts where
technique = 'Engine' and
Company ='TVS' and
minus
select distinct Place from all_parts_already where
technique = 'Engine' and
Company = 'TVS' and
parts = c1.parts ) loop
insert into all_parts_already (select c2.place,place_desc,c1.parts,c2.place from place_master where parts=c1.parts and place=c2.place);
end loop;
end loop;
the data i am dealing with is in millions. One technique may have 1000 parts. One part may have 500 places. So the loop runs that many times creating the delay.
Please tell me how to move forward.I am getting the output i need but the time it takes is too much(goes on to days)
Thanks a lot
:)
Hi this is the Oracle Designer forum. You may be better asking over at one of the database/sql/plsql forums
Similar Messages
-
Need OES Performance tuning steps for 10g
Hi Guys,
I am looking for a performance tuning document for OES 10g?
can someone provide me that or can someone illustrate the steps please?
Regards,
NaveenHi Gopi,
Following are the different tools provided by SAP for performance analysis of an ABAP object
Run time analysis transaction SE30
This transaction gives all the analysis of an ABAP program with respect to the database and the non-database processing.
SQL Trace transaction ST05
The trace list has many lines that are not related to the SELECT statement in the ABAP program. This is because the execution of any ABAP program requires additional administrative SQL calls. To restrict the list output, use the filter introducing the trace list.
check these links:
http://www.sapgenie.com/abap/performance.htm
http://www.sapdevelopment.co.uk/perform/performhome.htm
http://www.thespot4sap.com/Articles/SAPABAPPerformanceTuning_Introduction.asp
regards,
keerthi. -
Performance Tuning Certification for Application Developer
Hi,
Can you please advise if there is any Oracle Performance Tuning certification for an Application Developer and Oracle 9i to 10G migration certification? If yes, can you please let me know its Oracle examination number?
I have already passed 1Z0-007 and 1Z0-147 in Oct 2008.
Thanks in advance,
Sandeep Kumar... if there is any Oracle Performance Tuning certification for an Application Developer ...There is no performance tuning related certification for application developers. There is one for the DBA track.
Also -- to answer your question in the other thread:
So to clear this certification do I need to re-appear all the 3 exams as they were given in 2008 or just 1Z0-146 is enough.Having passed 1Z0-007 and 1Z0-147, if you pass 1Z0-046, you will gain the certification: Oracle Advanced PL/SQL Developer Certified Professional -
help needed for writing query
i have the following tables(with data) as mentioned below
FK*-foregin key (SUBJECTS)
FK**-foregin key (COMBINATION)
1)SUBJECTS(table name)
SUB_ID(NUMBER) SUB_CODE(VARCHAR2) SUB_NAME (VARCHAR2)
2 02 Computer Science
3 03 Physics
4 04 Chemistry
5 05 Mathematics
7 07 Commerce
8 08 Computer Applications
9 09 Biology
2)COMBINATION
COMB_ID(NUMBER) COMB_NAME(VARCHAR2) SUB_ID1(NUMBER(FK*)) SUB_ID2(NUMBER(FK*)) SUB_ID3(NUMBER(FK*)) SUBJ_ID4(NUMBER(FK*))
383 S1 9 4 2 3
384 S2 4 2 5 3
---------I actually designed the ABOVE table also like this
3) a)COMBINATION
COMB_ID(NUMBER) COMB_NAME(VARCHAR2)
383 S1
384 S2
b)COMBINATION_DET
COMBDET_ID(NUMBER) COMB_ID(FK**) SUB_ID(FK*)
1 383 9
2 383 4
3 383 2
4 383 3
5 384 4
6 384 2
7 384 5
8 384 3
Business rule: a combination consists of a maximum of 4 subjects (must contain)
and the user is less relevant to a COMB_NAME(name of combinations) but user need
the subjects contained in combinations
i need the following output
COMB_ID COMB_NAME SUBJECT1 SUBJECT2 SUBJECT3 SUBJECT4
383 S1 Biology Chemistry Computer Science Physics
384 S2 Chemistry Computer Science Mathematics Physics
or even this is enough(what i actually needed)
COMB_ID subjects
383 Biology,Chemistry,Computer Science,Physics
384 Chemistry,Computer Science,Mathematics,Physics
you can use any of the COMBINATION table(either (2) or (3))
and i want to know
1)which design is good in this case
(i think SUB_ID1,SUB_ID2,SUB_ID3,SUB_ID4 is not a
good method to link with same table but if 4 subjects only(and must) comes
detail table is not neccessary )
now i am achieving the result by program-coding in C# after getting the rows from oracle
i am using oracle 9i (also ODP.NET)
i want to know how can i get the result in the stored procedure itsef.
2)how it could be designed in any other way.
any help/suggestion is welcome
thanks for your time --PradeeshWell I forgot the table-alias, here now with:
SELECT C.COMB_ID
, C.COMB_NAME
, (SELECT SUB_NAME
FROM SUBJECTS
WHERE SUB_ID = C.SUB_ID1) AS SUBJECT_NAME1
, (SELECT SUB_NAME
FROM SUBJECTS
WHERE SUB_ID = C.SUB_ID2) AS SUBJECT_NAME2
, (SELECT SUB_NAME
FROM SUBJECTS
WHERE SUB_ID = C.SUB_ID3) AS SUBJECT_NAME3
, (SELECT SUB_NAME
FROM SUBJECTS
WHERE SUB_ID = C.SUB_ID4) AS SUBJECT_NAME4
FROM COMBINATION C;
As you need exactly 4 subjects, the columns-solution is just fine I would say. -
Performance Tuning Guidelines for Windows Server 2008 R2 mistake?
Hi all,
I'm reading the "Performance Tuning Guidelines for Windows Server 2008 R2" and I think there is same kind of error. At page 53 there is a sub chapter "I/O Priorities" that explain how to handle I/O priorities.
In the guide it is said that in the registry I have to have a key:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\DeviceClasses\{Device GUID}\DeviceParameters\Classpnp\
Where {Device GUID} I think it is the value I get in device manager under one of my disks -> properties -> details -> "Device Class GUID"
the trouble is that under the key HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\DeviceClasses\ I've no subkey matching my disk's device class guid! Maybe I'm drunk but I've checked every sub key under HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\DeviceClasses\
but neither of them as a subkey named "DeviceParameter"!!
So am I wrong?Hi Andrea,
To find the "DeviceParameter", please try to follow the steps below:
1.Find this registry key and note the DeviceInstance value:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\DeviceClasses\
2.Find the device instance registry key under "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum" which contains information about the devices on the system and get the device interface GUID:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\<hardware id>\<instance id>\Device Parameters
I hope this helps. -
XMLAGG structure, performance help needed for odd nesting in schema
Hello,
I have to produce XML to look like:
<?xml version='1.0'?>
<enterprise>
<membership>
<sourcedid>
<id>PHYS_101_001_FA2007</id>
</sourcedid>
<!-- NOTE: absence of "members" level tag for XMLAGG! -->
<member>
<sourcedid>
<id>D2LU0001</id>
</sourcedid>
<role roletype="Sample Role">
<status>1</status>
</role>
</member>
<member>
<sourcedid>
<id>D2LU0002</id>
</sourcedid>
<role roletype="Sample Role">
<status>1</status>
</role>
</member>
</membership>
</enterprise>This would be straightforward if the schema allowed for a "<members>" tag under which to nest the <member> tags. But, it does not allow for that tag or any other than those listed above.
I have a query which does produce that output (except for the roletype attribute), but its performance is horrible; it takes about 40 minutes to return data:
SELECT
XMLROOT(
XMLELEMENT("enterprise",
XMLAGG(
XMLELEMENT("membership",
XMLFOREST( XMLELEMENT("id",cx.mapped_course_id) as "sourcedid"
(SELECT XMLAGG(
XMLELEMENT("member",
XMLFOREST(XMLELEMENT("id",spriden_id) AS "sourcedid",
XMLELEMENT("status",'1') AS "role"
FROM enrollments_fall_sfrstca efs
, spriden sp
, gzv_tuid t
WHERE sp.spriden_change_ind IS NULL
AND sp.spriden_pidm = t.pidm
AND t.tuid = efs.user_name
AND efs.mapped_course_id = cx.mapped_course_id
AND efs.term = cx.semester
, VERSION '1.0', STANDALONE NO VALUE)
FROM courses_xt cx
WHERE cx.semester = :term_code
;Similar queries are producing courses and users XML fine with no performance issues, but these are driven off either the courses view or the enrollments view, but not both.
Is there some other way I can produce the nesting I need for the vendor's schema?
The source views are basically as follows (showing relevant columns only):
courses_xt:
MAPPED_COURSE_ID SEMEST
AVFT209-13307-201210 201210
AVFT210-13308-201210 201210enrollments_fall_sfrstca:
MAPPED_COURSE_ID USER_NAME
AVFT209-13307-201210 FULLERC8
AVFT209-13307-201210 SHUPEK
AVFT209-13307-201210 NOMAN
AVFT210-13308-201210 SHUPEK
AVFT210-13308-201210 PELLONMWhen I have the query without the XML (with the subquery as a column of the outer query), this returns the correct data quickly (a couple of minutes).
I have tried various permutations of XMLFOREST, XMLELEMENT, XMLAGG but either I get syntax errors, or the data is wrong (e.g. repeated '<membership>' for each '<member>', or I have to create an invalid tag '<members>' to be filtered later).
Please advise!
Thanks,
Anita LeesHi Anita,
Have you tried with a GROUP BY and no subquery?
Here's an example using SCOTT schema.
I've used the same tag names and structure so that you can see the analogy :
SELECT XMLElement("enterprise",
XMLAgg(
XMLElement("membership",
XMLElement("sourceid", xmlelement("id", d.deptno))
, XMLAgg(
XMLElement("member",
XMLElement("sourceid",
XMLElement("id", e.empno)
, XMLElement("role",
XMLAttributes(e.job as "roletype")
, XMLElement("status", '1')
FROM scott.dept d
LEFT OUTER JOIN scott.emp e ON e.deptno = d.deptno
WHERE d.deptno IN (10,20)
GROUP BY d.deptno
;which gives :
<enterprise>
<membership>
<sourceid>
<id>10</id>
</sourceid>
<member>
<sourceid>
<id>7782</id>
</sourceid>
<role roletype="MANAGER">
<status>1</status>
</role>
</member>
<member>
<sourceid>
<id>7934</id>
</sourceid>
<role roletype="CLERK">
<status>1</status>
</role>
</member>
<member>
<sourceid>
<id>7839</id>
</sourceid>
<role roletype="PRESIDENT">
<status>1</status>
</role>
</member>
</membership>
<membership>
<sourceid>
<id>20</id>
</sourceid>
<member>
<sourceid>
<id>7369</id>
</sourceid>
<role roletype="CLERK">
<status>1</status>
</role>
</member>
<member>
<sourceid>
<id>7902</id>
</sourceid>
<role roletype="ANALYST">
<status>1</status>
</role>
</member>
<member>
<sourceid>
<id>7566</id>
</sourceid>
<role roletype="MANAGER">
<status>1</status>
</role>
</member>
</membership>
</enterprise> -
Looking for Bi Performance & Tuning book for BI...
Hi
I am looking for BI-7 (Performance & Tuning) book. Actually i looked SAP Press site & found book "SAP BW Performance Optimization Guide" but its BW-3.5 based but I want for BI 7.
Pls. Suggest me any good book on this topic.
Thanks
Edited by: Harpal Singh on Oct 5, 2010 9:45 AMI am also a BI developer...
"SAP NetWeaver BW: Administration and Monitoring:
offers a lot of insight into what happens when loading happens and also talks in length about how to tune the system using RSADMIN parameters etc...
I found this book very useful and in fact it helped me a lot preparing for the BI Professional exam in data modeling ...
and to answer your question - the BW performance tuning book also talks a lot about memory allocation / consumption etc which might be stuff that is usually used by BASIS ... and since the concepts are the same - you could go with the 3.5 book and get to know the options you have ...
Edited by: Arun Varadarajan on Oct 8, 2010 2:33 AM -
Query performance tuning need your suggestions
Hi,
Below is the sql query and explain plan which is taking 2 hours to execute and sometime it is breaking up( erroring out) due to memory issue.
Below it the query which i need to improve the performance of the code please need your suggestion in order to tweak so that time take for execution become less and also in less memory consumption
select a11.DATE_ID DATE_ID,
sum(a11.C_MEASURE) WJXBFS1,
count(a11.PKEY_GUID) WJXBFS2,
count(Case when a11.C_MEASURE <= 10 then a11.PKEY_GUID END) WJXBFS3,
count(Case when a11.STATUS = 'Y' and a11.C_MEASURE > 10 then a11.PKEY_GUID END) WJXBFS4,
count(Case when a11.STATUS = 'N' then a11.PKEY_GUID END) WJXBFS5,
sum(((a11.C_MEASURE ))) WJXBFS6,
a17.DESC_DATE_MM_DD_YYYY DESC_DATE_MM_DD_YYYY,
a11.DNS DNS,
a12.VVALUE VVALUE,
a12.VNAME VNAME,
a13.VVALUE VVALUE0,
a13.VNAME VNAME0,
9 a14.VVALUE VVALUE1,
a14.VNAME VNAME1,
a15.VVALUE VVALUE2,
a15.VNAME VNAME2,
a16.VVALUE VVALUE3,
a16.VNAME VNAME3,
a11.PKEY_GUID PKEY_GUID,
a11.UPKEY_GUID UPKEY_GUID,
a17.DAY_OF_WEEK DAY_OF_WEEK,
a17.D_WEEK D_WEEK,
a17.MNTH_ID DAY_OF_MONTH,
a17.YEAR_ID YEAR_ID,
a17.DESC_YEAR_FULL DESC_YEAR_FULL,
a17.WEEK_ID WEEK_ID,
a17.WEEK_OF_YEAR WEEK_OF_YEAR
from ACTIVITY_F a11
join (SELECT A.ORG as ORG,
A.DATE_ID as DATE_ID,
A.TIME_OF_DAY_ID as TIME_OF_DAY_ID,
A.DATE_HOUR_ID as DATE_HOUR_ID,
A.TASK as TASK,
A.PKEY_GUID as PKEY_GUID,
A.VNAME as VNAME,
A.VVALUE as VVALUE
FROM W_ORG_D A join W_PERSON_D B on
(A.TASK = B.TASK AND A.ORG = B.ID
AND A.VNAME = B.VNAME)
WHERE B.VARIABLE_OBJ = 1 ) a12
on (a11.PKEY_GUID = a12.PKEY_GUID and
a11.DATE_ID = a12.DATE_ID and
a11.ORG = a12.ORG)
join (SELECT A.ORG as ORG,
A.DATE_ID as DATE_ID,
A.TIME_OF_DAY_ID as TIME_OF_DAY_ID,
A.DATE_HOUR_ID as DATE_HOUR_ID,
A.TASK as TASK,
A.PKEY_GUID as PKEY_GUID,
A.VNAME as VNAME,
A.VVALUE as VVALUE
FROM W_ORG_D A join W_PERSON_D B on
(A.TASK = B.TASK AND A.ORG = B.ID
AND A.VNAME = B.VNAME)
WHERE B.VARIABLE_OBJ = 2) a13
on (a11.PKEY_GUID = a13.PKEY_GUID and
a11.DATE_ID = a13.DATE_ID and
a11.ORG = a13.ORG)
join (SELECT A.ORG as ORG,
A.DATE_ID as DATE_ID,
A.TIME_OF_DAY_ID as TIME_OF_DAY_ID,
A.DATE_HOUR_ID as DATE_HOUR_ID,
A.TASK as TASK,
A.PKEY_GUID as PKEY_GUID,
A.VNAME as VNAME,
A.VVALUE as VVALUE
FROM W_ORG_D A join W_PERSON_D B on
(A.TASK = B.TASK AND A.ORG = B.ID
AND A.VNAME = B.VNAME)
WHERE B.VARIABLE_OBJ = 3 ) a14
on (a11.PKEY_GUID = a14.PKEY_GUID and
a11.DATE_ID = a14.DATE_ID and
a11.ORG = a14.ORG)
join (SELECT A.ORG as ORG,
A.DATE_ID as DATE_ID,
A.TIME_OF_DAY_ID as TIME_OF_DAY_ID,
A.DATE_HOUR_ID as DATE_HOUR_ID,
A.TASK as TASK,
A.PKEY_GUID as PKEY_GUID,
A.VNAME as VNAME,
A.VVALUE as VVALUE
FROM W_ORG_D A join W_PERSON_D B on
(A.TASK = B.TASK AND A.ORG = B.ID
AND A.VNAME = B.VNAME)
WHERE B.VARIABLE_OBJ = 4) a15
on (a11.PKEY_GUID = a15.PKEY_GUID and
89 a11.DATE_ID = a15.DATE_ID and
a11.ORG = a15.ORG)
join (SELECT A.ORG as ORG,
A.DATE_ID as DATE_ID,
A.TIME_OF_DAY_ID as TIME_OF_DAY_ID,
A.DATE_HOUR_ID as DATE_HOUR_ID,
A.TASK as TASK,
A.PKEY_GUID as PKEY_GUID,
A.VNAME as VNAME,
A.VVALUE as VVALUE
FROM W_ORG_D A join W_PERSON_D B on
(A.TASK = B.TASK AND A.ORG = B.ID
AND A.VNAME = B.VNAME)
WHERE B.VARIABLE_OBJ = 9) a16
on (a11.PKEY_GUID = a16.PKEY_GUID and
a11.DATE_ID = a16.DATE_ID and
A11.ORG = A16.ORG)
join W_DATE_D a17
ON (A11.DATE_ID = A17.ID)
join W_SALES_D a18
on (a11.TASK = a18.ID)
where (a17.TIMSTAMP between To_Date('2001-02-24 00:00:00', 'YYYY-MM-DD HH24:MI:SS') and To_Date('2002-09-12 00:00:00', 'YYYY-MM-DD HH24:MI:SS')
and a11.ORG in (12)
and a18.SRC_TASK = 'AX012Z')
group by a11.DATE_ID,
a17.DESC_DATE_MM_DD_YYYY,
a11.DNS,
a12.VVALUE,
a12.VNAME,
a13.VVALUE,
a13.VNAME,
a14.VVALUE,
a14.VNAME,
a15.VVALUE,
a15.VNAME,
a16.VVALUE,
a16.VNAME,
a11.PKEY_GUID,
a11.UPKEY_GUID,
a17.DAY_OF_WEEK,
a17.D_WEEK,
a17.MNTH_ID,
a17.YEAR_ID,
a17.DESC_YEAR_FULL,
a17.WEEK_ID,
a17.WEEK_OF_YEAR;
Explained.
PLAN_TABLE_OUTPUT
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 1245 | 47 (9)| 00:00:01 |
| 1 | HASH GROUP BY | | 1 | 1245 | 47 (9)| 00:00:01 |
|* 2 | HASH JOIN | | 1 | 1245 | 46 (7)| 00:00:01 |
|* 3 | HASH JOIN | | 1 | 1179 | 41 (5)| 00:00:01 |
|* 4 | HASH JOIN | | 1 | 1113 | 37 (6)| 00:00:01 |
|* 5 | HASH JOIN | | 1 | 1047 | 32 (4)| 00:00:01 |
|* 6 | HASH JOIN | | 1 | 981 | 28 (4)| 00:00:01 |
| 7 | NESTED LOOPS | | 1 | 915 | 23 (0)| 00:00:01 |
| 8 | NESTED LOOPS | | 1 | 763 | 20 (0)| 00:00:01 |
| 9 | NESTED LOOPS | | 1 | 611 | 17 (0)| 00:00:01 |
| 10 | NESTED LOOPS | | 1 | 459 | 14 (0)| 00:00:01 |
| 11 | NESTED LOOPS | | 1 | 307 | 11 (0)| 00:00:01 |
| 12 | NESTED LOOPS | | 1 | 155 | 7 (0)| 00:00:01 |
| 13 | NESTED LOOPS | | 1 | 72 | 3 (0)| 00:00:01 |
| 14 | TABLE ACCESS BY INDEX ROWID| W_SALES_D | 1 | 13 | 2 (0)| 00:00:01 |
|* 15 | INDEX UNIQUE SCAN | CONS_UNQ_W_SALES_D_SRC_ID | 1 | | 1 (0)| 00:00:01 |
| 16 | TABLE ACCESS BY INDEX ROWID| W_DATE_D | 1 | 59 | 1 (0)| 00:00:01 |
|* 17 | INDEX UNIQUE SCAN | UIDX_DD_TIMSTAMP | 1 | | 0 (0)| 00:00:01 |
| 18 | TABLE ACCESS BY INDEX ROWID | ACTIVITY_F | 1 | 83 | 4 (0)| 00:00:01 |
|* 19 | INDEX RANGE SCAN | PK_ACTIVITY_F | 1 | | 3 (0)| 00:00:01 |
|* 20 | TABLE ACCESS BY INDEX ROWID | W_ORG_D | 1 | 152 | 4 (0)| 00:00:01 |
|* 21 | INDEX RANGE SCAN | IDX_FK_CVSF_PKEY_GUID | 10 | | 3 (0)| 00:00:01 |
|* 22 | TABLE ACCESS BY INDEX ROWID | W_ORG_D | 1 | 152 | 3 (0)| 00:00:01 |
|* 23 | INDEX RANGE SCAN | IDX_FK_CVSF_PKEY_GUID | 10 | | 3 (0)| 00:00:01 |
|* 24 | TABLE ACCESS BY INDEX ROWID | W_ORG_D | 1 | 152 | 3 (0)| 00:00:01 |
|* 25 | INDEX RANGE SCAN | IDX_FK_CVSF_PKEY_GUID | 10 | | 3 (0)| 00:00:01 |
|* 26 | TABLE ACCESS BY INDEX ROWID | W_ORG_D | 1 | 152 | 3 (0)| 00:00:01 |
|* 27 | INDEX RANGE SCAN | IDX_FK_CVSF_PKEY_GUID | 10 | | 3 (0)| 00:00:01 |
|* 28 | TABLE ACCESS BY INDEX ROWID | W_ORG_D | 1 | 152 | 3 (0)| 00:00:01 |
|* 29 | INDEX RANGE SCAN | IDX_FK_CVSF_PKEY_GUID | 10 | | 3 (0)| 00:00:01 |
|* 30 | TABLE ACCESS FULL | W_PERSON_D | 1 | 66 | 4 (0)| 00:00:01 |
|* 31 | TABLE ACCESS FULL | W_PERSON_D | 1 | 66 | 4 (0)| 00:00:01 |
|* 32 | TABLE ACCESS FULL | W_PERSON_D | 1 | 66 | 4 (0)| 00:00:01 |
|* 33 | TABLE ACCESS FULL | W_PERSON_D | 1 | 66 | 4 (0)| 00:00:01 |
|* 34 | TABLE ACCESS FULL | W_PERSON_D | 1 | 66 | 4 (0)| 00:00:01 |
-----------------------------------------------------------------------------------------------------------------------Hi,
I'm not a tuning expert but I can suggest you to post your request according to this template:
Thread: HOW TO: Post a SQL statement tuning request - template posting
HOW TO: Post a SQL statement tuning request - template posting
Then:
a) you should posting a code which is easy to read. What about formatting? Your code had to be fixed in a couple of lines.
b) You could simplify your code using the with statement. This has nothing to do with the tuning but it will help the readability of the query.
Check it below:
WITH tab1 AS (SELECT a.org AS org
, a.date_id AS date_id
, a.time_of_day_id AS time_of_day_id
, a.date_hour_id AS date_hour_id
, a.task AS task
, a.pkey_guid AS pkey_guid
, a.vname AS vname
, a.vvalue AS vvalue
, b.variable_obj
FROM w_org_d a
JOIN
w_person_d b
ON ( a.task = b.task
AND a.org = b.id
AND a.vname = b.vname))
SELECT a11.date_id date_id
, SUM (a11.c_measure) wjxbfs1
, COUNT (a11.pkey_guid) wjxbfs2
, COUNT (CASE WHEN a11.c_measure <= 10 THEN a11.pkey_guid END) wjxbfs3
, COUNT (CASE WHEN a11.status = 'Y' AND a11.c_measure > 10 THEN a11.pkey_guid END) wjxbfs4
, COUNT (CASE WHEN a11.status = 'N' THEN a11.pkey_guid END) wjxbfs5
, SUM ( ( (a11.c_measure))) wjxbfs6
, a17.desc_date_mm_dd_yyyy desc_date_mm_dd_yyyy
, a11.dns dns
, a12.vvalue vvalue
, a12.vname vname
, a13.vvalue vvalue0
, a13.vname vname0
, a14.vvalue vvalue1
, a14.vname vname1
, a15.vvalue vvalue2
, a15.vname vname2
, a16.vvalue vvalue3
, a16.vname vname3
, a11.pkey_guid pkey_guid
, a11.upkey_guid upkey_guid
, a17.day_of_week day_of_week
, a17.d_week d_week
, a17.mnth_id day_of_month
, a17.year_id year_id
, a17.desc_year_full desc_year_full
, a17.week_id week_id
, a17.week_of_year week_of_year
FROM activity_f a11
JOIN tab1 a12
ON ( a11.pkey_guid = a12.pkey_guid
AND a11.date_id = a12.date_id
AND a11.org = a12.org
AND a12.variable_obj = 1)
JOIN tab1 a13
ON ( a11.pkey_guid = a13.pkey_guid
AND a11.date_id = a13.date_id
AND a11.org = a13.org
AND a13.variable_obj = 2)
JOIN tab1 a14
ON ( a11.pkey_guid = a14.pkey_guid
AND a11.date_id = a14.date_id
AND a11.org = a14.org
AND a14.variable_obj = 3)
JOIN tab1 a15
ON ( a11.pkey_guid = a15.pkey_guid
AND a11.date_id = a15.date_id
AND a11.org = a15.org
AND a15.variable_obj = 4)
JOIN tab1 a16
ON ( a11.pkey_guid = a16.pkey_guid
AND a11.date_id = a16.date_id
AND a11.org = a16.org
AND a16.variable_obj = 9)
JOIN w_date_d a17
ON (a11.date_id = a17.id)
JOIN w_sales_d a18
ON (a11.task = a18.id)
WHERE (a17.timstamp BETWEEN TO_DATE ('2001-02-24 00:00:00', 'YYYY-MM-DD HH24:MI:SS')
AND TO_DATE ('2002-09-12 00:00:00', 'YYYY-MM-DD HH24:MI:SS')
AND a11.org IN (12)
AND a18.src_task = 'AX012Z')
GROUP BY a11.date_id, a17.desc_date_mm_dd_yyyy, a11.dns, a12.vvalue
, a12.vname, a13.vvalue, a13.vname, a14.vvalue
, a14.vname, a15.vvalue, a15.vname, a16.vvalue
, a16.vname, a11.pkey_guid, a11.upkey_guid, a17.day_of_week
, a17.d_week, a17.mnth_id, a17.year_id, a17.desc_year_full
, a17.week_id, a17.week_of_year;
{code}
I hope I did not miss anything while reformatting the code. I could not test it not having the proper tables.
As I said before I'm not a tuning expert nor I pretend to be but I see this:
1) Table W_PERSON_D is read in full scan. Any possibility of using indexes?
2) Tables W_SALES_D, W_DATE_D, ACTIVITY_F and W_ORG_D have TABLE ACCESS BY INDEX ROWID which definitely is not fast.
You should provide additional information for tuning your query checking the post I mentioned previously.
Regards.
Al -
Tuning needed for sql:EXPLAIN PLAN attached
DB Version:10gR2
The below sql was running slow, so i took an explain plan
SQL> explain plan for
2 SELECT COUNT(1) FROM SHIP_DTL WHERE
3 SHIP_DTL.PLT_ID = 'AM834'
4 AND SHIP_DTL.WHSE = '34' AND
5 SHIP_DTL.STAT_CODE != '845'
6 ORDER BY SHIP_DTL.LOAD_SEQ ASC;
Explained.
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)|
| 0 | SELECT STATEMENT | | 1 | 18 | 5 (20)|
| 1 | SORT AGGREGATE | | 1 | 18 | |
|* 2 | TABLE ACCESS BY INDEX ROWID| SHIP_DTL | 200 | 3600 | 5 (20)|
|* 3 | INDEX RANGE SCAN | SHIP_DTL_IND_4 | 203 | | 3 (0)|
Predicate Information (identified by operation id):
PLAN_TABLE_OUTPUT
2 - filter("SHIP_DTL"."WHSE"='34' AND "SHIP_DTL"."STAT_CODE"<>845)
3 - access("SHIP_DTL"."PLT_ID"='AM834')Why is there an INDEX RANGE scan where there is no BETWEEN operator in the query? What are various options(indexes, rewriting query) in tuning this query?james_p wrote:
DB Version:10gR2
The below sql was running slow, so i took an explain planCheck your plan, the optimizer estimates that the following query:
select count(*)
from SHIP_DTL
where "SHIP_DTL"."PLT_ID"='AM834';only returns 200 records. Is this correct? Please post the result of above query.
It probably isn't the case, because retrieving 200 records per index range scan and single row random table access shouldn't take long, at maximum a couple of seconds if you need to read each block actually from disk rather than from the cache.
If the estimate is wrong you need to check the statistics on the table and index that were used by the optimizer to come to that conclusion.
Are you sure that this plan is the actual plan used at execution time? You can check for the actual plans used to execute by using the DBMS_XPLAN.DISPLAY_CURSOR function in 10g if the SQL is still cached in the Shared Pool. You need to pass the SQL_ID and SQL_CHILD_NUMBER which you can retrieve from V$SESSION while the statement is executing.
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/ -
Tuning tricks for the query.
Hi Everyone,
This is my DB version @ production.
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
TNS for Linux: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
We have a query, which is running more than 3 mins at production as we have 40 millions active records for almost 2 million active patients.
So clearly the active record percentage is 98. We have indexes on all required field values last date of computed statistics was 1st Jan 2014.
But we are unable achieve the performance from the query. If we are making it tightly coupled with parent - child relationship, then it's generating cost
value more than 2 million. So we tried some sub-queries but still the cost value is in million. Please do have a look at the query and suggest me something where
I can meliorate this. We can't go change DB structure straight away right now. So what needs to be done here? Please suggest something.
Query:-
select distinct
(select p.last_name || ', ' || p.first_name
from patient p
where p.patient_id = loc.patient_id) as patient_name,
(select p.external_id
from patient p
where p.patient_id = loc.patient_id) as external_id,
(select p.spectra_mrn
from patient p
where p.patient_id = loc.patient_id) as spectra_mrn,
ord.requisition_number as requisition_number,
f.facility_name as facility_name,
f.facility_id as facility_id,
(select fad.account_type as modality
from patient p,
patient_facility_modality pfm,
facility_account_modality fam,
facility_account_detail fad
where p.patient_id = pfm.patient_id
and pfm.facility_account_modality_id =
fam.facility_account_modality_id
and fam.facility_account_detail_id = fad.facility_account_detail_id
and p.patient_id = loc.patient_id
and pfm.facility_id = loc.facility_id) as modality,
(select fad.account_number as account_number
from patient p,
patient_facility_modality pfm,
facility_account_modality fam,
facility_account_detail fad
where p.patient_id = pfm.patient_id
and pfm.facility_account_modality_id =
fam.facility_account_modality_id
and fam.facility_account_detail_id = fad.facility_account_detail_id
and p.patient_id = loc.patient_id
and pfm.facility_id = loc.facility_id) as account_number,
(select fad.hlab_num as hlab_num
from patient p,
patient_facility_modality pfm,
facility_account_modality fam,
facility_account_detail fad
where p.patient_id = pfm.patient_id
and pfm.facility_account_modality_id =
fam.facility_account_modality_id
and fam.facility_account_detail_id = fad.facility_account_detail_id
and p.patient_id = loc.patient_id
and pfm.facility_id = loc.facility_id) as hlab_num,
loc.order_draw_dt as draw_dt,
c.corporation_name as corporation_name,
c.corporation_acronym as acronym,
loc.patient_id,
loct.test_id
from lab_order_occ loc,
lab_order_occ_test loct,
facility f,
corporation c,
order_requisition_header ord
where loc.lab_order_occ_id = loct.lab_order_occ_id
and loc.facility_id = f.facility_id
and f.corporation_id = c.corporation_id
and ord.patient_id = loc.patient_id
and ord.facility_id = loc.facility_id
and ord.draw_dt = loc.order_draw_dt
and loc.order_draw_dt between trunc(sysdate) - 7 and trunc(sysdate)
and loc.status = 'A'
and loc.msg_sent_to_lab_yn = 'Y'
and loct.status <> 'R'
and loct.test_id in (
select test_id
from test_required
where required_test_code in (
select test_code
from interface_adt_aoe_master))
and
(select count(*) from interface_adt_aoe_master where source_system = corporation_acronym
and test_code = (select test_code from test where test_id=(select aoe_test_id from lab_order_occ_test_aoe where lab_order_occ_test_id= loct.lab_order_occ_test_id)))
!=
(select count(*) from EMR_ADTAOE_DTL where patient_id = loc.patient_id and facility_id = loc.facility_id and (
(test_id = (select aoe_test_id from lab_order_occ_test_aoe where lab_order_occ_test_id= loct.lab_order_occ_test_id) and trunc(draw_date) like trunc(loc.order_draw_dt))
or (test_id = (select aoe_test_id from lab_order_occ_test_aoe where LAB_ORDER_OCC_TEST_ID= loct.lab_order_occ_test_id) and trunc(draw_date)= trunc(to_date('12-31-2999','mm-dd-yyyy')))
and STATUS = 'Y' and ANSWER is not null)
Execution Plan @ QAT environment
explain plan succeeded.
PLAN_TABLE_OUTPUT
Plan hash value: 2140167730
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 399 | 59451 | 6293 (1)| 00:01:16 |
| 1 | TABLE ACCESS BY INDEX ROWID | PATIENT | 1 | 21 | 2 (0)| 00:00:01 |
|* 2 | INDEX UNIQUE SCAN | PATIENT_PK | 1 | | 1 (0)| 00:00:01 |
| 3 | TABLE ACCESS BY INDEX ROWID | PATIENT | 1 | 11 | 2 (0)| 00:00:01 |
|* 4 | INDEX UNIQUE SCAN | PATIENT_PK | 1 | | 1 (0)| 00:00:01 |
| 5 | TABLE ACCESS BY INDEX ROWID | PATIENT | 1 | 12 | 2 (0)| 00:00:01 |
|* 6 | INDEX UNIQUE SCAN | PATIENT_PK | 1 | | 1 (0)| 00:00:01 |
| 7 | NESTED LOOPS | | 1 | 43 | 5 (0)| 00:00:01 |
| 8 | NESTED LOOPS | | 1 | 29 | 4 (0)| 00:00:01 |
| 9 | NESTED LOOPS | | 1 | 19 | 3 (0)| 00:00:01 |
|* 10 | INDEX UNIQUE SCAN | PATIENT_PK | 1 | 5 | 1 (0)| 00:00:01 |
|* 11 | INDEX RANGE SCAN | PATIENT_FACILITY_MOD_IX_01 | 1 | 14 | 2 (0)| 00:00:01 |
| 12 | TABLE ACCESS BY INDEX ROWID | FACILITY_ACCOUNT_MODALITY | 1 | 10 | 1 (0)| 00:00:01 |
|* 13 | INDEX UNIQUE SCAN | FACILITY_ACCOUNT_MODALITY_PK | 1 | | 0 (0)| 00:00:01 |
| 14 | TABLE ACCESS BY INDEX ROWID | FACILITY_ACCOUNT_DETAIL | 1 | 14 | 1 (0)| 00:00:01 |
|* 15 | INDEX UNIQUE SCAN | FACILITY_ACCOUNT_DETAIL_PK | 1 | | 0 (0)| 00:00:01 |
| 16 | NESTED LOOPS | | 1 | 40 | 5 (0)| 00:00:01 |
| 17 | NESTED LOOPS | | 1 | 29 | 4 (0)| 00:00:01 |
| 18 | NESTED LOOPS | | 1 | 19 | 3 (0)| 00:00:01 |
|* 19 | INDEX UNIQUE SCAN | PATIENT_PK | 1 | 5 | 1 (0)| 00:00:01 |
|* 20 | INDEX RANGE SCAN | PATIENT_FACILITY_MOD_IX_01 | 1 | 14 | 2 (0)| 00:00:01 |
| 21 | TABLE ACCESS BY INDEX ROWID | FACILITY_ACCOUNT_MODALITY | 1 | 10 | 1 (0)| 00:00:01 |
|* 22 | INDEX UNIQUE SCAN | FACILITY_ACCOUNT_MODALITY_PK | 1 | | 0 (0)| 00:00:01 |
| 23 | TABLE ACCESS BY INDEX ROWID | FACILITY_ACCOUNT_DETAIL | 1 | 11 | 1 (0)| 00:00:01 |
|* 24 | INDEX UNIQUE SCAN | FACILITY_ACCOUNT_DETAIL_PK | 1 | | 0 (0)| 00:00:01 |
| 25 | NESTED LOOPS | | 1 | 42 | 5 (0)| 00:00:01 |
| 26 | NESTED LOOPS | | 1 | 29 | 4 (0)| 00:00:01 |
| 27 | NESTED LOOPS | | 1 | 19 | 3 (0)| 00:00:01 |
|* 28 | INDEX UNIQUE SCAN | PATIENT_PK | 1 | 5 | 1 (0)| 00:00:01 |
|* 29 | INDEX RANGE SCAN | PATIENT_FACILITY_MOD_IX_01 | 1 | 14 | 2 (0)| 00:00:01 |
| 30 | TABLE ACCESS BY INDEX ROWID | FACILITY_ACCOUNT_MODALITY | 1 | 10 | 1 (0)| 00:00:01 |
|* 31 | INDEX UNIQUE SCAN | FACILITY_ACCOUNT_MODALITY_PK | 1 | | 0 (0)| 00:00:01 |
| 32 | TABLE ACCESS BY INDEX ROWID | FACILITY_ACCOUNT_DETAIL | 1 | 13 | 1 (0)| 00:00:01 |
|* 33 | INDEX UNIQUE SCAN | FACILITY_ACCOUNT_DETAIL_PK | 1 | | 0 (0)| 00:00:01 |
| 34 | HASH UNIQUE | | 399 | 59451 | 6293 (1)| 00:01:16 |
|* 35 | FILTER | | | | | |
|* 36 | FILTER | | | | | |
|* 37 | HASH JOIN | | 399 | 59451 | 6285 (1)| 00:01:16 |
| 38 | TABLE ACCESS FULL | CORPORATION | 291 | 11640 | 3 (0)| 00:00:01 |
| 39 | NESTED LOOPS | | 399 | 43491 | 6282 (1)| 00:01:16 |
|* 40 | HASH JOIN | | 2113 | 216K| 6281 (1)| 00:01:16 |
| 41 | TABLE ACCESS FULL | TEST_REQUIRED | 1184 | 10656 | 5 (0)| 00:00:01 |
|* 42 | TABLE ACCESS BY INDEX ROWID | LAB_ORDER_OCC_TEST | 8 | 144 | 5 (0)| 00:00:01 |
| 43 | NESTED LOOPS | | 1345 | 126K| 6276 (1)| 00:01:16 |
|* 44 | HASH JOIN | | 170 | 13260 | 5425 (1)| 00:01:06 |
|* 45 | HASH JOIN | | 170 | 8670 | 5403 (1)| 00:01:05 |
|* 46 | TABLE ACCESS BY INDEX ROWID| LAB_ORDER_OCC | 12775 | 336K| 569 (1)| 00:00:07 |
|* 47 | INDEX SKIP SCAN | LAB_ORDER_OCC_IX_07 | 2218 | | 13 (8)| 00:00:01 |
|* 48 | TABLE ACCESS BY INDEX ROWID| ORDER_REQUISITION_HEADER | 56952 | 1334K| 4833 (1)| 00:00:58 |
|* 49 | INDEX SKIP SCAN | ORDER_REQUISITION_HEADER_IX_04 | 4905 | | 1707 (1)| 00:00:21 |
| 50 | TABLE ACCESS FULL | FACILITY | 4252 | 112K| 22 (0)| 00:00:01 |
|* 51 | INDEX RANGE SCAN | LAB_ORDER_OCC_TEST_IX_01 | 8 | | 2 (0)| 00:00:01 |
|* 52 | INDEX RANGE SCAN | INTERFACE_ADT_AOE_MASTER_IX_01 | 1 | 4 | 0 (0)| 00:00:01 |
| 53 | SORT AGGREGATE | | 1 | 12 | | |
|* 54 | TABLE ACCESS BY INDEX ROWID | INTERFACE_ADT_AOE_MASTER | 1 | 12 | 2 (0)| 00:00:01 |
|* 55 | INDEX RANGE SCAN | INTERFACE_ADT_AOE_MASTER_IX_01 | 4 | | 1 (0)| 00:00:01 |
| 56 | TABLE ACCESS BY INDEX ROWID | TEST | 1 | 9 | 2 (0)| 00:00:01 |
|* 57 | INDEX UNIQUE SCAN | TEST_PK | 1 | | 1 (0)| 00:00:01 |
|* 58 | INDEX RANGE SCAN | LAB_ORDER_OCC_TEST_AOE_PK | 1 | 10 | 3 (0)| 00:00:01 |
| 59 | SORT AGGREGATE | | 1 | 29 | | |
|* 60 | FILTER | | | | | |
|* 61 | TABLE ACCESS BY INDEX ROWID | EMR_ADTAOE_DTL | 1 | 29 | 30 (0)| 00:00:01 |
|* 62 | INDEX RANGE SCAN | EMR_ADTAOE_DTL_IX_01 | 174 | | 3 (0)| 00:00:01 |
|* 63 | INDEX RANGE SCAN | LAB_ORDER_OCC_TEST_AOE_PK | 1 | 10 | 3 (0)| 00:00:01 |
|* 64 | INDEX RANGE SCAN | LAB_ORDER_OCC_TEST_AOE_PK | 1 | 10 | 3 (0)| 00:00:01 |
Query Block Name / Object Alias (identified by operation id):
1 - SEL$2 / P@SEL$2
2 - SEL$2 / P@SEL$2
3 - SEL$3 / P@SEL$3
4 - SEL$3 / P@SEL$3
5 - SEL$4 / P@SEL$4
6 - SEL$4 / P@SEL$4
7 - SEL$5
10 - SEL$5 / P@SEL$5
11 - SEL$5 / PFM@SEL$5
12 - SEL$5 / FAM@SEL$5
13 - SEL$5 / FAM@SEL$5
14 - SEL$5 / FAD@SEL$5
15 - SEL$5 / FAD@SEL$5
16 - SEL$6
19 - SEL$6 / P@SEL$6
20 - SEL$6 / PFM@SEL$6
21 - SEL$6 / FAM@SEL$6
22 - SEL$6 / FAM@SEL$6
23 - SEL$6 / FAD@SEL$6
24 - SEL$6 / FAD@SEL$6
25 - SEL$7
28 - SEL$7 / P@SEL$7
29 - SEL$7 / PFM@SEL$7
30 - SEL$7 / FAM@SEL$7
31 - SEL$7 / FAM@SEL$7
32 - SEL$7 / FAD@SEL$7
33 - SEL$7 / FAD@SEL$7
34 - SEL$AA3B83ED
38 - SEL$AA3B83ED / C@SEL$1
41 - SEL$AA3B83ED / TEST_REQUIRED@SEL$8
42 - SEL$AA3B83ED / LOCT@SEL$1Hi Karthick,
Thanks for the response. The suggestion is really good. But we have some tables accessed like "lab_order_occ" which size is more than 8GB also having no partitions. If I'll ask for altering DB structure, this will be finalized not less than 6 months. Please do have a look at the plan now. It's generating more cost.
explain plan succeeded.
PLAN_TABLE_OUTPUT
Plan hash value: 2523654849
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1057 | 293K| 25324 (2)| 00:05:04 |
|* 1 | FILTER | | | | | |
|* 2 | HASH JOIN RIGHT SEMI | | 1057 | 293K| 25317 (2)| 00:05:04 |
| 3 | VIEW | VW_NSO_1 | 224 | 2912 | 5 (0)| 00:00:01 |
|* 4 | FILTER | | | | | |
| 5 | NESTED LOOPS | | 224 | 2912 | 5 (0)| 00:00:01 |
| 6 | TABLE ACCESS FULL | TEST_REQUIRED | 1184 | 10656 | 5 (0)| 00:00:01 |
|* 7 | INDEX RANGE SCAN | INTERFACE_ADT_AOE_MASTER_IX_01 | 1 | 4 | 0 (0)| 00:00:01 |
|* 8 | TABLE ACCESS BY INDEX ROWID | LAB_ORDER_OCC_TEST | 8 | 144 | 5 (0)| 00:00:01 |
| 9 | NESTED LOOPS | | 1345 | 355K| 25311 (2)| 00:05:04 |
|* 10 | HASH JOIN | | 170 | 43010 | 24460 (2)| 00:04:54 |
| 11 | TABLE ACCESS FULL | CORPORATION | 291 | 11640 | 3 (0)| 00:00:01 |
|* 12 | HASH JOIN | | 170 | 36210 | 24457 (2)| 00:04:54 |
| 13 | NESTED LOOPS OUTER | | 170 | 31620 | 24434 (2)| 00:04:54 |
|* 14 | HASH JOIN | | 170 | 14960 | 5403 (1)| 00:01:05 |
|* 15 | TABLE ACCESS BY INDEX ROWID | LAB_ORDER_OCC | 12775 | 598K| 569 (1)| 00:00:07 |
|* 16 | INDEX SKIP SCAN | LAB_ORDER_OCC_IX_07 | 2218 | | 13 (8)| 00:00:01 |
|* 17 | TABLE ACCESS BY INDEX ROWID | ORDER_REQUISITION_HEADER | 56952 | 2224K| 4833 (1)| 00:00:58 |
|* 18 | INDEX SKIP SCAN | ORDER_REQUISITION_HEADER_IX_04 | 4905 | | 1707 (1)| 00:00:21 |
| 19 | VIEW PUSHED PREDICATE | | 1 | 98 | 112 (2)| 00:00:02 |
|* 20 | HASH JOIN | | 93 | 8835 | 112 (2)| 00:00:02 |
|* 21 | HASH JOIN | | 93 | 6231 | 56 (2)| 00:00:01 |
|* 22 | HASH JOIN | | 93 | 5301 | 48 (3)| 00:00:01 |
| 23 | NESTED LOOPS | | 68 | 2924 | 44 (0)| 00:00:01 |
| 24 | TABLE ACCESS BY INDEX ROWID| PATIENT | 1 | 34 | 2 (0)| 00:00:01 |
|* 25 | INDEX UNIQUE SCAN | PATIENT_PK | 1 | | 1 (0)| 00:00:01 |
| 26 | TABLE ACCESS BY INDEX ROWID| LAB_ORDER_OCC | 68 | 612 | 42 (0)| 00:00:01 |
|* 27 | INDEX RANGE SCAN | LAB_ORDER_OCC_IX_02 | 53 | | 2 (0)| 00:00:01 |
|* 28 | INDEX RANGE SCAN | PATIENT_FACILITY_MOD_IX_01 | 111 | 1554 | 3 (0)| 00:00:01 |
| 29 | TABLE ACCESS FULL | FACILITY_ACCOUNT_MODALITY | 9159 | 91590 | 8 (0)| 00:00:01 |
| 30 | TABLE ACCESS FULL | FACILITY_ACCOUNT_DETAIL | 7266 | 198K| 55 (0)| 00:00:01 |
| 31 | TABLE ACCESS FULL | FACILITY | 4252 | 112K| 22 (0)| 00:00:01 |
|* 32 | INDEX RANGE SCAN | LAB_ORDER_OCC_TEST_IX_01 | 8 | | 2 (0)| 00:00:01 |
| 33 | SORT AGGREGATE | | 1 | 12 | | |
|* 34 | TABLE ACCESS BY INDEX ROWID | INTERFACE_ADT_AOE_MASTER | 1 | 12 | 2 (0)| 00:00:01 |
|* 35 | INDEX RANGE SCAN | INTERFACE_ADT_AOE_MASTER_IX_01 | 4 | | 1 (0)| 00:00:01 |
| 36 | TABLE ACCESS BY INDEX ROWID | TEST | 1 | 9 | 2 (0)| 00:00:01 |
|* 37 | INDEX UNIQUE SCAN | TEST_PK | 1 | | 1 (0)| 00:00:01 |
|* 38 | INDEX RANGE SCAN | LAB_ORDER_OCC_TEST_AOE_PK | 1 | 10 | 3 (0)| 00:00:01 |
| 39 | SORT AGGREGATE | | 1 | 29 | | |
|* 40 | FILTER | | | | | |
|* 41 | TABLE ACCESS BY INDEX ROWID | EMR_ADTAOE_DTL | 1 | 29 | 30 (0)| 00:00:01 |
|* 42 | INDEX RANGE SCAN | EMR_ADTAOE_DTL_IX_01 | 174 | | 3 (0)| 00:00:01 |
|* 43 | INDEX RANGE SCAN | LAB_ORDER_OCC_TEST_AOE_PK | 1 | 10 | 3 (0)| 00:00:01 |
Query Block Name / Object Alias (identified by operation id):
1 - SEL$19EEE7EA
3 - SEL$9DB3EFF9 / VW_NSO_1@SEL$19EEE7EA
4 - SEL$9DB3EFF9
6 - SEL$9DB3EFF9 / TEST_REQUIRED@SEL$3
7 - SEL$9DB3EFF9 / INTERFACE_ADT_AOE_MASTER@SEL$4
8 - SEL$19EEE7EA / LOCT@SEL$1
11 - SEL$19EEE7EA / C@SEL$1
15 - SEL$19EEE7EA / LOC@SEL$1
16 - SEL$19EEE7EA / LOC@SEL$1
17 - SEL$19EEE7EA / ORD@SEL$1
18 - SEL$19EEE7EA / ORD@SEL$1
19 - SEL$639F1A6F / P@SEL$1
20 - SEL$639F1A6F
24 - SEL$639F1A6F / P@SEL$2
25 - SEL$639F1A6F / P@SEL$2
26 - SEL$639F1A6F / LOC@SEL$2
27 - SEL$639F1A6F / LOC@SEL$2
28 - SEL$639F1A6F / PFM@SEL$2
29 - SEL$639F1A6F / FAM@SEL$2
30 - SEL$639F1A6F / FAD@SEL$2
31 - SEL$19EEE7EA / F@SEL$1
32 - SEL$19EEE7EA / LOCT@SEL$1
33 - SEL$5
34 - SEL$5 / INTERFACE_ADT_AOE_MASTER@SEL$5
35 - SEL$5 / INTERFACE_ADT_AOE_MASTER@SEL$5
36 - SEL$6 / TEST@SEL$6
37 - SEL$6 / TEST@SEL$6
38 - SEL$7 / LAB_ORDER_OCC_TEST_AOE@SEL$7
39 - SEL$8
41 - SEL$8 / EMR_ADTAOE_DTL@SEL$8
42 - SEL$8 / EMR_ADTAOE_DTL@SEL$8
43 - SEL$9 / LAB_ORDER_OCC_TEST_AOE@SEL$9
Predicate Information (identified by operation id):
1 - filter( (SELECT /*+ */ COUNT(*) FROM "KORUS2XPROD_OWN"."INTERFACE_ADT_AOE_MASTER"
"INTERFACE_ADT_AOE_MASTER" WHERE "TEST_CODE"= (SELECT /*+ */ "TEST_CODE" FROM "KORUS2XPROD_OWN"."TEST" "TEST"
WHERE "TEST_ID"= (SELECT /*+ */ "AOE_TEST_ID" FROM "KORUS2XPROD_OWN"."LAB_ORDER_OCC_TEST_AOE"
"LAB_ORDER_OCC_TEST_AOE" WHERE "LAB_ORDER_OCC_TEST_ID"=:B1)) AND "SOURCE_SYSTEM"=:B2)<> (SELECT /*+ */ COUNT(*)
FROM "KORUS2XPROD_OWN"."EMR_ADTAOE_DTL" "EMR_ADTAOE_DTL" WHERE "TEST_ID"= (SELECT /*+ */ "AOE_TEST_ID" FROM
"KORUS2XPROD_OWN"."LAB_ORDER_OCC_TEST_AOE" "LAB_ORDER_OCC_TEST_AOE" WHERE "LAB_ORDER_OCC_TEST_ID"=:B3) AND
"PATIENT_ID"=:B4 AND "FACILITY_ID"=:B5 AND "STATUS"='Y' AND (TO_CHAR(TRUNC(INTERNAL_FUNCTION("DRAW_DATE"))) LIKE
TO_CHAR(TRUNC(:B6)) OR TRUNC(INTERNAL_FUNCTION("DRAW_DATE"))=TO_DATE(' 2999-12-31 00:00:00', 'syyyy-mm-dd
hh24:mi:ss')) AND "ANSWER" IS NOT NULL))
2 - access("LOCT"."TEST_ID"="$nso_col_1")
4 - filter(TRUNC(SYSDATE@!)-7<=TRUNC(SYSDATE@!))
7 - access("REQUIRED_TEST_CODE"="TEST_CODE")
8 - filter("LOCT"."STATUS"<>'R')
10 - access("F"."CORPORATION_ID"="C"."CORPORATION_ID")
12 - access("LOC"."FACILITY_ID"="F"."FACILITY_ID")
14 - access("ORD"."PATIENT_ID"="LOC"."PATIENT_ID" AND "ORD"."FACILITY_ID"="LOC"."FACILITY_ID" AND
"ORD"."DRAW_DT"="LOC"."ORDER_DRAW_DT")
15 - filter("LOC"."PATIENT_ID" IS NOT NULL AND "LOC"."MSG_SENT_TO_LAB_YN"='Y')
16 - access("LOC"."ORDER_DRAW_DT">=TRUNC(SYSDATE@!)-7 AND "LOC"."STATUS"='A' AND
"LOC"."ORDER_DRAW_DT"<=TRUNC(SYSDATE@!))
filter("LOC"."STATUS"='A')
17 - filter("ORD"."PATIENT_ID" IS NOT NULL)
18 - access("ORD"."DRAW_DT">=TRUNC(SYSDATE@!)-7 AND "ORD"."DRAW_DT"<=TRUNC(SYSDATE@!))
filter("ORD"."DRAW_DT">=TRUNC(SYSDATE@!)-7 AND "ORD"."DRAW_DT"<=TRUNC(SYSDATE@!))
20 - access("FAM"."FACILITY_ACCOUNT_DETAIL_ID"="FAD"."FACILITY_ACCOUNT_DETAIL_ID")
21 - access("PFM"."FACILITY_ACCOUNT_MODALITY_ID"="FAM"."FACILITY_ACCOUNT_MODALITY_ID")
22 - access("PFM"."FACILITY_ID"="LOC"."FACILITY_ID")
25 - access("P"."PATIENT_ID"="LOC"."PATIENT_ID")
27 - access("LOC"."PATIENT_ID"="LOC"."PATIENT_ID") -
hello ,
I am a beginner in terms of writing sql queries. I hope some body can help me out.
I have two tables
mysql> desc user_group_t;
---------------------------------------------------+
| Field | Type | Null | Key | Default | Extra |
---------------------------------------------------+
| userAccountId | char(8) | | PRI | | |
| groupId | char(8) | | PRI | | |
---------------------------------------------------+
2 rows in set (0.00 sec)
mysql> desc group_t;
---------------------------------------------------+
| Field | Type | Null | Key | Default | Extra |
---------------------------------------------------+
| id | char(8) | | PRI | | |
| name | char(50) | YES | | NULL | |
| email | char(100) | YES | | NULL | |
| description | char(254) | YES | | NULL | |
| parentId | char(8) | YES | | NULL | |
| creatorId | char(8) | YES | | NULL | |
| createDate | char(20) | YES | | NULL | |
| updateDate | char(20) | YES | | NULL | |
| updatorId | char(8) | YES | | NULL | |
---------------------------------------------------+
9 rows in set (0.00 sec)
what I want is list of all groups with id,name and #of members(which is the # of rows in the user_group_t for any given id). Importantly I need the groups with 0 members also to be listed. In short my output should contain exactly the same number of rows as in group_t table with an additional column indicating # of members for that group.
Any help would be greatly appreciated.
Thanks in Advance.
-VasanthThanks Donald,
Actually I figured it out, with the following query:
select id,name,sum(if(groupid is not null,1,0)) as members from group_t left join user_group_t on id=groupid group by id;
I tried your solution, but mysql says there is an error at '+' . Anyway I modified your solution to the one below and it worked.
select a.id, a.name, count(b.groupid) from group_t a left join user_group_t b on a.id=b.groupid group by a.id, a.name;
I tried that before but then I used Count(*) instead of count on groupid. Your solution is elagant and I will go with yours.
Thanks again.
Vasanth -
Performance Tuning on a Select Query
Hi,
We have a select statement as mentioned below.
SELECT loobj1 gpart vkont proid tdate lotyp lockr
INTO TABLE tb_dfkklocks
FROM dfkklocks
FOR ALL ENTRIES IN tb_fkkvkp
WHERE
lotyp = '02'
AND proid = '01'
AND lockr >= '0'
AND lockr <= '9'
AND gpart = tb_fkkvkp-gpart
AND vkont = tb_fkkvkp-vkont.
We have Primary key as shown below.
CLIENT
LOOBJ1
LOTYP
PROID
LOCKR
FDATE
TDATE
GPART
VKONT
We have a secondary index only on TDATE. What can be the ideal select stement to improve the performance?
Regards,
Lijo JosephHi Lijo,
Couple of pointers from my end.
1). Try avoiding a FOR ALL ENTRIES if the base table is huge. Instead use a array fetch and pick up more data instead of trying to restrict the data using a FOR ALL ENTRIES as this does a LOOP on the database while selecting the data.
So i would suggest not use FOR ALL ENTRIES if the base table is huge. So analyse before using a select query.
2). It is actually very difficult to mention which option is better. I would say that it all depends on the scenario. What amount of data is to be read, from which table it is being read, what kind of processing is required on database,..... and many more analysis goes to write a an efficient select statement.
3). If i am not wrong i think if you are using a FOR ALL ENTRIES and dont specify the key completely then there is no gaurentee that you fetch all the unique records. The system will compare all the character fields as a KEY field and it will not fetch all the records. So while using a FOR ALL ENTRIES its recommended to use all the key fields.
4). If you would like to really spend time and work on a efficient select statement then try using the tcode ST05 --> Select the button EXPLAIN SQL REQUEST.
type in your select query and see what is the cost of the select statement fired on the database. This will help you to select the best statement. This is a very useful tool if we have complex select statements.
Hope this info is helpful.
Cheers
VJ
Message was edited by: Vijayendra Rao -
Hi,
I am just wondering what could be the best SQL for the following scenario.
Table 1 Table2
COL1 COL2 COL3 COL1 COL2 COL3
AAA 123 10 AAA 123 12
AAA 123 12
AAA 123 14
AAA 456 10
AAA 456 12
AAA 456 14
Given the above data, I want only the AAA/123/10 and AAA/123/14 records from table1, and leave the others alone.
The tables are huge (200 million) and indexed on all the three columns and my SQL is taking much time to complete.
SQL i have used
select col1, col2, col3 from (
select a.col1, a.col2, a.col3, b.col3 col4 from
table1 a
left join
table2 b
on
a.col1 = b.col1 and
a.col2 = b.col2 and
a.col3 = b.col3
where exists (select 1 from table2 c where a.col1 = c.col1 and a.col2 = c.col2)
) x
where x.col4 is null
Can anyone give me better solution than this?Depending on your data, there is a good possibility that the intermediate result set, after the outerjoin from table1 to table2, is even more huge than the original tables. This might impact the time it takes to process your query in a negative way.
The next query does something similar, but with a smaller intermediate result sets and is therefore probably a bit faster. At least it's worth the try. Please let us know the impact.
SQL> select t1.col1
2 , t1.col2
3 , t1.col3
4 from table1 t1
5 where exists
6 ( select null
7 from table2 t2
8 where t2.col1 = t1.col1
9 and t2.col2 = t1.col2
10 )
11 minus
12 select t2.col1
13 , t2.col2
14 , t2.col3
15 from table2 t2
16 /
COL COL2 COL3
AAA 123 10
AAA 123 14
2 rows selected.Regards,
Rob. -
IIR 2.8.0.7 performance tuning suggestions / documents for Oracle 11?
Would we have any hints or white papers that would support a customer in IIR matching server tuning for initial load performance,
beyond the Siebel specific
Performance Tuning Guidelines for Siebel CRM Application on Oracle Database (Doc ID 781927.1)
which does NOT generate any statistics on the Informatica Schema?
Customer is starting production data load into Siebel UCM of over 5 million customer records . Their current bottle neck seems to be IIR queries and high IIR host resources usage.
This would be for Siebel 8.1.1.4 [21225] on Oracle 11.1.0.6; I currently do not know if ACR 475 with its EBC access is used or not; I'd be looking for any performance tuning suggestions on the Informatica & database side - I have not found anything helpful in the informatica knowledgebase and in the 2.8.0.7 docs the only performance tuning suggestions seem to be on IDT loads.
Obviously performance can be influenced by the matching fields used, but this customer will be looking for performance tuning suggestions keeping the matching fields and thresholds they got approved from the business side.
Any documents we could share?Hi Varad,
Well, Oracle Metalink actually got it fixed for me! Got to give them credit.
I ran the 1st bit of SQL they sent me and it fixed it so I think it was only cosmetic. I've enclosed all of their response in case others may find themselves in similar situation.
Thanks again for YOUR help too.
Perry
==========================================================
1. Do you see any invalid objects in the database?
2. Please update the SR with the output of running the commands below
1.Connect as SYS.
set serveroutput on (This will let you see if any check fails)
exec validate_apex; (If your version is 2.0 or above)
If all are fine, the registry should be changed to VALID for APEX and you should see the following
message:
PL/SQL procedure successfully completed.
Note : The procedure validate_apex should always complete successfully.
With serveroutput on, it should show why Application Express is listed as invalid.It should show output like:
FAILED CHECK FOR <<obect_name>>
Or
FAILED EXISTENCE CHECK FOR <<object_name>> -
MySQL InnoDB performance tuning
Hi,
We recently updated our Solaris 10 (Sparc) patch level. It is from:
Solaris 10 8/07 s10s_u4wos_12b SPARC
Patch level 137111-05
to
Solaris 10 10/09 s10s_u8wos_08a SPARC
Patch level 144488-14
We have two functions in MySQL uses InnoDB. In the old version of Solaris 10 (8/07), one function takes less than 1 sec to finish execute.
However in the newer version of Solaris 10 (10/09). It takes about 40 secs to finish execute.
So, we found one solution in google that said to change the innodb_flush_log_at_trx_commit to 0 instead of default 1, then the function take only about 0.41 sec to finish execute.
So does anyone know what did the newer version of Solaris (update 8) has changed that I need to change this innodb_flush_log_at_commit to make better performance b/c the older version of Solaris the mysql innodb_flush_log_at_trx_commit still 1 and peformance is less than 1 secs.
Thanks!No one can tell you how to tune your database because there are too many variables that are specific to your installation.
Some of the major factors hinge on the size of your database tables, both in terms of number of rows and the type of data within them. Then there's questions of whether you're using InnoDB or MyISAM, the cacheability of the data, the ratio of reads to writes, the size of each record, etc., etc., etc.
Tuning paramaters for a 4 TB database with 20,000,000 rows are going to be radically different than those for a 100MB database with 10,000 rows.
Then, of course, there are factors that aren't in my.cnf anyway - things like table indexes, data formats, query structure, etc.
The same query can take radically different amounts of time depending on the indexes on the table. Conversely, much (most?) performance tuning comes down to query optimization rather than database configuration - reordering the parameters in a query can have dramatic effects on performance, depending on the database structure.
So, you see, you're not likely to find a magic bullet that says 'make sure you add the gofaster=1 parameter to your my.cnf'. Database Administrators make a living with this stuff and every situation is different.
Maybe you are looking for
-
Solman Document Access thro portal
hi I wanted to know if we store the documents on SOLMAN, can they be accessed using portal. if yes may i know how
-
I'm now using Photoshop CS5. I modified a jpeg image that I created in CS2, but when I tried to save it, I window opened saying that either the file was locked or I didn't have the necessary permissions. When I checked the file in the Get Info dialog
-
Error when Create TO (LT06)
Dear All I saved a GR (From Purchase Order Return) and now I'm wanted to create TO with reference of GR number. But system showing the below message. You have not selected any data for the material document 5000000266 Message no. L2030 thanks imron
-
The pull-down includes a few logical places where I might want to save my bookmark, but it also includes a few that I may have used in the past but no longer want listed. How do I remove the erroneous locations??
-
My itouch got stolen and facebook and twitter automatically sign in when i turn on my itouch. If i change those passwords will they still be signed in automatically when they turn it on? I dont want them to have access to my facebook ect.