Need guidance in query optimization
hi everyone.
This query takes more than 400 milli seconds to execute.it executes more than 25 times.make the web page slow.
can anyone provide guidance in optimizing this query
SELECT
DISTINCT *
FROM
PRICING_ANALYST
WHERE
USER_ID IN
SELECT
FROM
PRICING_ANALYST pa,
ALC_PROJECT p,
REQUEST r,
ALCG_TEMP_QUOTE q,
ALC_USER u,
REQUESTER, ALC_COUNTRY
WHERE
r.REQUEST_ID = 172938
AND
r.temp_quote_ref_num = q.temp_quote_ref_num
AND
r.user_id = q.user_id
AND
r.project_id = q.project_id
AND
pa.country_code = q.country_code
AND
q.country_code = alc_country.country_code
AND
p.project_id = r.project_id
AND
pa.user_id = u.user_id
AND
requester.user_id = p.user_id
AND
requester.project_id = p.project_id
AND
pa.CUSTOMER_EQUANT = 'Y'
OR
pa.CUSTOMER_NEW_EQUANT = 'Y'
OR
pa.CUSTOMER_EXISTING_EQUANT = 'Y'
OR
pa.CUSTOMER_EXISTING_GLOBALONE = 'Y'
OR
pa.CUSTOMER_OTHERS = 'Y'
OR
pa.CUSTOMER_FRANCE_TELECOM = 'Y'
OR
pa.CUSTOMER_SPRINT = 'Y'
AND
pa.COUNTRY_CODE = q.COUNTRY_CODE
AND
pa.Business_Opportunity IS null
OR
substr(pa.Business_Opportunity, instr(pa.Business_Opportunity,(r.Business_Opportunity || '''')), length(r.Business_Opportunity))= r.Business_Opportunity)
AND
pa.REQUEST_local_loop = 'Y'
AND
substr(pa.ACCESS_TECH_ID, instr(pa.ACCESS_TECH_ID, (q.ACCESS_TECH_ID || '''')), length(q.ACCESS_TECH_ID)) = q.ACCESS_TECH_ID
)
Hi,
Pl make sure all tables related to this query are analyzed recently with indexes, try to preserve the explain plan of the queries when it is running properly, so we can compare if slow running query, any change in the plan.
Dilipkumar Patel
Similar Messages
-
Need guidance on Query for fine Tuning
Hi ,
Please help me on the below query while rewriting. Actually it is taking 2.56 sec to give 2.25 lacs records.
I am trying to tune this query since 2 days,but not able to understand where to change & why it is taking that much time.
Using : Oracle 10g version
Tool : TOAD 8.6.1
There are Indexes on every column used in Where clause but still some table scanning full.
becoz of Inner Join it is taking much time, So Can anyone rewrite the below query for faster execution.
SELECT workorder.fincode,
workorder.istask,
workorder.status,
workorder.targstartdate,
workorder.targcompdate,
workorder.schedfinish,
workorder.actfinish,
workorder.estdur,
workorder.wonum,
workorder.mprn,
workorder.sihousename AS wositehousename,
workorder.sihouseno AS wositehouseno,
workorder.sistreet AS wositestreet,
workorder.sicounty AS wositecounty,
workorder.siposttown AS wositeposttown,
workorder.sipostcode AS wositepostcode,
workorder.workorderid
FROM (maximo.sr
INNER JOIN
(maximo.relatedrecord INNER JOIN maximo.workorder
ON relatedrecord.relatedreckey =
(CASE
WHEN workorder.PARENT IS NOT NULL
THEN workorder.PARENT
ELSE workorder.wonum
END
AND relatedrecord.orgid = workorder.orgid
AND relatedrecord.siteid = workorder.siteid
AND relatedrecord.relatedrecclass = 'WORKORDER')
ON sr.ticketid = relatedrecord.recordkey
AND sr.orgid = relatedrecord.orgid
AND sr.siteid = relatedrecord.siteid
AND relatedrecord.CLASS = 'SR')
LEFT JOIN
frozen_quote@gqmfof
ON sr.ticketid = customer_enquiry_ref AND sr.quotever = quote_version
Explan Result:
PLAN_TABLE_OUTPUT
Plan hash value: 599875212
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Inst |IN-OUT|
| 0 | SELECT STATEMENT | | 1569 | 272K| 3362 (1)| 00:00:41 | | |
|* 1 | HASH JOIN | | 1569 | 272K| 3362 (1)| 00:00:41 | | |
|* 2 | HASH JOIN RIGHT OUTER | | 1263 | 92199 | 417 (4)| 00:00:06 | | |
| 3 | REMOTE | | 1 | 10 | 2 (0)| 00:00:01 | GQMFOF | R->S |
| 4 | NESTED LOOPS | | 1263 | 79569 | 414 (3)| 00:00:05 | | |
| 5 | MERGE JOIN CARTESIAN | | 3798 | 159K| 397 (3)| 00:00:05 | | |
| 6 | VIEW | VW_NSO_1 | 1 | 14 | 3 (34)| 00:00:01 | | |
| 7 | SORT UNIQUE | | 1 | 26 | 3 (34)| 00:00:01 | | |
|* 8 | INDEX RANGE SCAN | SYNONYMDOM_NDX1 | 1 | 26 | 2 (0)| 00:00:01 | | |
| 9 | BUFFER SORT | | 3798 | 107K| 397 (3)| 00:00:05 | | |
|* 10 | TABLE ACCESS FULL | RELATEDRECORD | 3798 | 107K| 394 (3)| 00:00:05 | | |
|* 11 | TABLE ACCESS BY INDEX ROWID| TICKET | 1 | 20 | 1 (0)| 00:00:01 | | |
|* 12 | INDEX UNIQUE SCAN | TICKET_NDX1 | 1 | | 0 (0)| 00:00:01 | | |
| 13 | TABLE ACCESS FULL | WORKORDER | 231K| 23M| 2943 (1)| 00:00:36 | | |
Predicate Information (identified by operation id):
1 - access("RELATEDRECORD"."RELATEDRECKEY"=CASE WHEN ("WORKORDER"."PARENT" IS NOT NULL) THEN
"WORKORDER"."PARENT" ELSE "WORKORDER"."WONUM" END AND "RELATEDRECORD"."ORGID"="WORKORDER"."ORGID" AND
"RELATEDRECORD"."SITEID"="WORKORDER"."SITEID")
2 - access("TICKET"."QUOTEVER"="QUOTE_VERSION"(+) AND "TICKET"."TICKETID"="CUSTOMER_ENQUIRY_REF"(+))
8 - access("DOMAINID"='TKCLASS' AND "MAXVALUE"='SR')
10 - filter("RELATEDRECORD"."CLASS"='SR' AND "RELATEDRECORD"."RELATEDRECCLASS"='WORKORDER')
11 - filter("TICKET"."ORGID"="RELATEDRECORD"."ORGID" AND "TICKET"."SITEID"="RELATEDRECORD"."SITEID")
12 - access("CLASS"="$nso_col_1" AND "TICKET"."TICKETID"="RELATEDRECORD"."RECORDKEY")
Regards,
GRAdd the NOCYCLE clause to your connect by statement CONNECT BY NOCYCLE PRIOR
You also might want to add the organization ID into your join. -
Hi Everyone:
I have a user on my site who's trying to find information on database query optimization. She's willing to pay $3 to someone who will give her some very basic information. I figured those of you who read this forum would have something handy you could just provide to her. It's not the information she's paying for, but the service of someone retrieving it for her. Would someone take a look? You can find her request here:
http://www.yepic.com/index.php?module=ContReq&hdnRequestID=8
The one problem is you have to register on the site before you can post your response. You just need to give create a username, email and password, though. It's very easy. I'd appreciate someone helping one of my users out.. . . she's trying to avoid the
search taxSearch tax... never heard it put that way. I guess you are trying to avoid the "search engine" tax by advertising your site here? Maybe some one will help you out by answering the request from Corey for Search Engine Optimization. -
Oracle 11g on Linux : Query Optimization issue
Hi guru,
I am facing one query optimization related problem in group by query
Table (10 million Records)
Product(ProductId number,ProductName varchar(100),CategoryId VARCHAR2(38),SubCategoryId VARCHAR2(38))
Index
create index idxCategory on Product (CategoryId,SubCategoryId)
Query1:To find product count for all CategoryId and SubCategoryId
select CategoryId,SubCategoryId,count(*) from Product group by CategoryId,SubCategoryId
Above query is not using index idxCategory and doing table scan which is very costly.
When I fire Query2: select count(*) from Product group by CategoryId,SubCategoryId
then it is properly using index idxCategory and very fast.
Even I specified hint in Query1 but it is not using hint.
Can anybody suggest why oracle is not using index in Query1 and what should I do so that Query1 will use Index.
Thanks in advance.user644199 wrote:
I am facing one query optimization related problem in group by query
Query1:To find product count for all CategoryId and SubCategoryId
select CategoryId,SubCategoryId,count(*) from Product group by CategoryId,SubCategoryId
Above query is not using index idxCategory and doing table scan which is very costly.
When I fire Query2: select count(*) from Product group by CategoryId,SubCategoryId
then it is properly using index idxCategory and very fast.
Even I specified hint in Query1 but it is not using hint.
Can anybody suggest why oracle is not using index in Query1 and what should I do so that Query1 will use Index.The most obvious reason that the table needs to be visited would be that the columns "CategoryId" / "SubCategoryId" can be NULL but then this should apply to both queries. You could try the following to check the NULL issue:
select CategoryId,SubCategoryId,count(*) from Product where CategoryId is not null and SubCategoryId is not null group by CategoryId,SubCategoryId
Does this query use the index?
Can you show us the hint you've used to force the index usage and the EXPLAIN PLAN output of the two queries including the "Predicate Information" section? Use DBMS_XPLAN.DISPLAY to get a proper output, and use the \ tag before and after when posting here to format it using fixed font. Use the "Quote" button in the message editor to see how I used the \ tag here.
Are above queries representing the actual queries used or did you omit some predicates etc. for simplicity?
By the way, VARCHAR2(38) and ...ID as name, are these columns storing number values?
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/ -
Hi All,
I was performing the steps mentioned in Oracle Tutorial"http://www.oracle.com/webfolder/technetwork/tutorials/obe/fmw/bi/bi11115/biadmin11g_02/biadmin11g.htm#t10"-BI RPD creation.
After Using the AGO function data in the Time series metric(Month Ago Revenue) was null always. I updated the DB features in RPD physical layers by selecting support for time series functions.
After that report started to fail with below error. Please let me know if its a bug and any option to fix it.
Thanks,
Sreekanth
Error
View Display Error
Odbc driver returned an error (SQLExecDirectW).
Error Details
Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 43113] Message returned from OBIS. [nQSError: 43119] Query Failed: [nQSError: 46008] Internal error: File server\Query\Optimizer\SmartScheduler\PhysicalRequestGenerator\Src\SQOSPMarkMultiTargetSupport.cpp, line 1680. (HY000)
SQL Issued: SELECT 0 s_0, "Sample Sales"."Time"."Year-L1" s_1, "Sample Sales"."Revenue"."Ago-Year Revenue" s_2, "Sample Sales"."Revenue"."Revenue" s_3 FROM "Sample Sales" FETCH FIRST 65001 ROWS ONLY
RefreshI know that there is no relation between "SampleApp Lite"."D3 Orders (Facts Attributes)"."Order Date", "SampleApp Lite"."D0 Time"."Calendar Date", it's also the same thing in my own RPD.
But as it's working with the 11.1.1.6.2 BP1 version I don't understand why it's not working with 11.1.1.6.9.
Implicit fact column is not set on my repository, but I don't have any request with only dimensional column, so if my understanding is correct I don't need to use it. Also, the problem appears during the check of the repository not in answers.
thanks anyway -
Hi Gurus,
I am preparing for an interview. I need to know about Query Optimization, explain plan, Cost analysis.
Can anyone please give me some reference link or site where i can get step by step details for the above..
It would be really helpfull.
Thanks in advance..
Ameya.RTFM [url http://oraclesvca2.oracle.com/docs/cd/B10501_01/server.920/a96533/toc.htm]Performance Tuning Guide and Reference
-
WHEN-TREE-NODE-SELECTED need 2 Execute-Query on Master-Detail data block
I optimize tree using this link
http://andreas.weiden.orcl.over-blog.de/article-29307730.html_+
For huge amount of data (Accountings)
All i need for now is
WHEN-TREE-NODE-SELECTED need 2 Execute-Query on the data block
DECLARE
htree ITEM;
node_value VARCHAR2(100);
BEGIN
IF :SYSTEM.TRIGGER_NODE_SELECTED = 'TRUE' THEN
-- Find the tree itself.
htree := FIND_ITEM ('BL_TREE.IT_TREE');
node_value := FTREE.GET_TREE_NODE_PROPERTY( htree, :SYSTEM.TRIGGER_NODE , ftree.node_value );
GO_BLOCK ('GL_ACCOUNTS');
set_block_property('GL_ACCOUNTS', DEFAULT_WHERE , 'ACCOUNT_ID ='|| node_value );
EXECUTE_QUERY;
END IF;
END;The above code is working fine 4 the detail block which is *'GL_ACCOUNTS'*
when i substitute is Master block which is 'GL_ACCOUNTS_TYPES' it doesn't display all data
Help is Appriciated pls.
Regards,
Abdetu...Hello
In WHEN-TREE-NODE-SELECTED i modified the following code :_
DECLARE
htree ITEM;
node_value VARCHAR2(100);
parent_node FTREE.NODE;
BEGIN
IF :SYSTEM.TRIGGER_NODE_SELECTED = 'TRUE' THEN
-- Find the tree itself.
htree := FIND_ITEM ('BL_TREE.IT_TREE');
-- Get the parent of the node clicked on.
parent_node := FTREE.GET_TREE_NODE_PARENT ( htree, :SYSTEM.TRIGGER_NODE );
GO_BLOCK('GL_TYPES');
set_block_property('GL_TYPES', DEFAULT_WHERE , 'TYPE_ID ='|| parent_node );
EXECUTE_QUERY;
-- Get the detail of the parent node
node_value := FTREE.GET_TREE_NODE_PROPERTY( htree, :SYSTEM.TRIGGER_NODE , ftree.node_value );
GO_BLOCK('GL_ACCOUNTS');
set_block_property('GL_ACCOUNTS', DEFAULT_WHERE , 'ACCOUNT_ID ='|| node_value );
EXECUTE_QUERY;
END IF;
END;
FRM-40350 : Query caused no records to be retrieved but i have records in the data base ...!
Well, Do u think that's because in ur package i retrieve only the detail block ?
Regards,
Abdetu... -
HFR - Data Query Optimization Settings
hi
In HFR, in a grid there are Data Query Optimization Settings, can you please help me on the settings property.
Our report fetches data using lot of attributes. When we don't use MDX setting, it fetches very fast, but the alias doesn't come.
However, when we use MDX setting, the alias comes, but the report takes lot of time to run(approx 1 min / row of data fetched)
Can you please guide on the same.
Thankspm wrote:
Hi ,
I am working on below query optimization/Tuning.
SELECT
c_date,
c1,
c2,
c3,
c4,
c5,
c6
FROM tab1
WHERE
ROWNUM <= ¶m
AND ( c_date BETWEEN &date1 AND &date2 )
AND c3 in (
select c3
from tab2
where xxx='abc')
ORDER BY c1, c_date;
Note : ¶m,&date1 ,&date2 are parameters runtime getting from UI code .
tab1 having huge data around 10lacs to crores. and it has range partition on c_date column and subpartiotion on c1 column.
To get best throughput in less time, what i need to do ?
Please do let me know steps to tune/optimize the sql query.Also which hint we can use on sql query to better results.
Thanks in advanced.
PMBefore you start worrying about performance tuning you should worry about the query being incorrect.
WHERE
ROWNUM <= ¶m
AND ( c_date BETWEEN &date1 AND &date2 )
AND c3 in (
select c3
from tab2
where xxx='abc')
ORDER BY c1, c_date;Presumably you want to limit the number of rows with the ROWNUM predicate AFTER the ORDER BY clause is applied.
Please read this and learn how queries are actually processed, I can almost guarantee you this query is not doing what you think it is doing at present.
http://www.oracle.com/technetwork/issue-archive/2006/06-sep/o56asktom-086197.html
Cheers, -
Hi All,
I'm doing some bit of study on that portion of Query Optimizer in Oracle9i that is autonomic (I mean it is dynamic and a self learning one).Can anyone give me some pointers to this topic(In fact I doubt whether something like this at all exists, or is still a topic of research); I need some more info on this topic.Some papers or articles may be handy.
Greetings,
Kaustav GhoshalI think u mean CBO (Cost Based Optimizer). If your database is running in "choose" mode so yes, CBO will automaticly optimize your query.
Check the doc here : http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96533/part1.htm
Fred -
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. -
Need Help to query Lync Database for User Information
Need Help to Query the lync database to retrieve below user information.
1. SIP Address of the registered user
2. Phone Number configured to the particular account.
3. IP Address
4. Last Logged in time.
I am trying to pull the above information from rtc database for all the registered users. Please let me know if this is possible and it would be great if you can throw some light on what tables to look for the data. Thank You.Hi,
For SIP address and Phone number you can check RTC database.
IP Address:
You can refer to the link below to query IP address:
http://h30499.www3.hp.com/t5/Business-Service-Management-BAC/Monitoring-Lync-with-the-User-Registrations-Viewer-Free-NMC-tool/ba-p/5961497#.UtOU43mIrwo
Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there.
Please make sure that you completely understand the risk before retrieving any suggestions from the above link.
Last Logged in time:
You can refer to the link below:
http://blogs.technet.com/b/dodeitte/archive/2011/05/11/how-to-get-the-last-time-a-user-registered-with-a-front-end.aspx
Best Regards,
Eason Huang
Eason Huang
TechNet Community Support -
Need guidance in displaying graphics shapes on image
I would like some help drawing a circle over an image which is displayed in JScrollpane through JLabel, The goal is, whe we click over the image, the image apperas with a small circle in the place we have clicked. I have used JLabel for displaying image in JScrollpane by using imageLabel.setIcon(new ImageIcon("default.jpg"));
I need to draw circle/rectangle when i click on image by this i need to select different points in the image by drawing circles/rectangles over the image.
If you understand my problem than please guide me for the same.
Thank youDon't post the same question multiple times. It's rude, as it leads to people wasting their time duplicating each others' answers.
http://forums.oracle.com/forums/message.jspa?messageID=9385315#9385315
http://forums.oracle.com/forums/message.jspa?messageID=9385314#9385314
Need guidance in displaying graphics shapes on image -
Need guidance on statspack report
Hello Friends, How are you. I hope you all will be fine.I need guidance on statspack report. I do not know how can i resolve wait events. Please help me and give me some time for considering statspack report. If any one willing to do my help its really honour for me. In reply just show me email address and i contact you for you kind consideration.
Thanks in advanceEither post the report here, or send it to me at [email protected], and I'll try to give my 2 cents on it.
Daniel -
What is query optimization and how to do it.
Hi
What is query optimization?
Any link can any one provide me so that i can read and learn the techniques.
Thanks
Elias MaliackalTHis is an excellent place to start: When your query takes too long ...
-
Reg Query Optimization - doubts..
Hi Experts,
This is related to Blog by Mr Prakash Darji regarding "Query Optimization" posted on Jan 26 2006.In this to optimize query Generation of Report is suggested.
I tried this, but I am not sure I am analyzing this correctly.
I collected Stats data before and after Generation of Report.But how to be sure that this is helping me? Did any one has tried this?
What to look for in Stats Data - duration?
But duration would not be absolute parameter as there is factor of "Wait Time, User", so duration may depend on this.
Please help me in this.
Thanks
Gaurav
Message was edited by: GauravAny ideas Experts?
Maybe you are looking for
-
How can I print a stream of characters to a printer device ?
If I want to write "Hello!" to a file, I can try the folliwing: BufferedWriter out = new BufferedWriter(new FileWriter("myFile.txt")); out.write("Hello!"); out.flush(); out.close(); What should I change in the above lines in order to write "Hello!" t
-
Error synchronizing subscribed folders in MS Outlook 2010
I get this error message when I open MS Outlook 2010 in Windows 7 after creating a new email profile ! Task 'Synchronizing subscribed folders for ( my email address )' reported error (0x800CCC0F) : 'Outlook cannot synchronize subscribed folders fo
-
ITunes 7 Lost Its Mac Touch+Some Problems I've Noticed
The glare effect isnt on any of the scroll bars except for album view. The Play/Pause/Stop and Next and Previous Buttons have a WINDOWS 98 kind of look The New Blue Music Symbol? A. Looks Dumb on the Doc B. Makes Front Row look plain and Boring [I to
-
I have a mac osx 10.5.8 I would like to know a good program to use to clean it up, one that does not cost an arm and a leg, free would be better.
-
Function module for Outbound Delivery
Dear ABAPers, Can anyone tell me the Function module for Out bound Delivery. Thanks & Regards, Ashok.