query performance [message #671775] |
Wed, 19 September 2018 01:55  |
annu-agi
Messages: 238 Registered: July 2005 Location: Karachi
|
Senior Member |
 
|
|
Dear experts
I have a query where i am using where clause with
this clause make my query dead slow. The relevant table contain more then 30 Ml records and index isnt a solution. Please guide me if anyone know the solution
regards
Anwer
[Updated on: Wed, 19 September 2018 01:57] Report message to a moderator
|
|
|
Re: query performance [message #671776 is a reply to message #671775] |
Wed, 19 September 2018 01:59   |
John Watson
Messages: 8836 Registered: January 2010 Location: Global Village
|
Senior Member |
|
|
You need to provide a lot more information. THe query would be a good start. And the execution plan. And why you think indexes are not relevant.
By the way, I wish you would not say "records" when you mean "rows".
|
|
|
|
Re: query performance [message #671778 is a reply to message #671777] |
Wed, 19 September 2018 02:44   |
John Watson
Messages: 8836 Registered: January 2010 Location: Global Village
|
Senior Member |
|
|
Come on, man. Execution plans? With and without the unit_selling_price filter?
There are however two basic errors. First, your use of SELECT * is insane. Consider that ONT.OE_ORDER_LINES_ALL has 360 columns (the others are not quite so bad) why would you want to transfer hundreds of columns? That will be limiting the optimizer'soptions hugely. You should project only the columns you want. Second your filter on ordered_date is comparing a a date to strings. Don't do that.
|
|
|
|
|
|
|
Re: query performance [message #672681 is a reply to message #671780] |
Tue, 23 October 2018 22:39   |
 |
Barbara Boehmer
Messages: 9005 Registered: November 2002 Location: California, USA
|
Senior Member |
|
|
annu-agi wrote on Wed, 19 September 2018 01:11Dear watson,
as advice i have change the query as below
select OOL.ORDERED_QUANTITY from oe_Order_lines_all ool, oe_order_headers_All ooh , oe_transaction_types_all ott
where ooh.org_id=225
and ool.LINE_CATEGORY_CODE='RETURN'
and ooh.header_id=ool.header_id
--and trunc(ooh.ordered_Date) between '01-aug-2018' and '31-aug-2018'
and ooh.ordered_Date between to_Date('01-aug-2018','dd-mon-yyyy') and to_DAte('31-aug-2018','dd-mon-yyyy')
and ooh.order_type_id=ott.transaction_type_id
and ott.attribute1='NPD Shan FBA 1'
and ool.unit_selling_price=0
...
Your query looks fine now. Try creating indexes on the columns used in join conditions and filter conditions. For example:
create index ool_idx on oe_Order_lines_all (header_id, line_category, unit_selling_price);
create index ooh_idx on oe_order_headers_All (header_id, order_type, org_id, ordered_date);
create index ott_idx on oe_transaction_types_all (transaction_type, attribute1);
|
|
|
|