Link to home
Start Free TrialLog in
Avatar of Jbancr1
Jbancr1Flag for United States of America

asked on

How to get a query to run faster

I have a query that takes a while to run and sometimes times out. Is there a better way to write the query below to run faster?
SELECT a.confirm_date, a.so_br_id, a.so_id, a.so_line_nbr, a.confirm_qty, a.orig_assign_qty,
           b.qty_backordered, b.qty_ordered, b.qty_shipped, a.bo_reason_code, a.part_id, c.cust_id, b.vendor_code 
  FROM CSI.SO_CARTON_DETAIL a, csi.or_line b, csi.or_header c
    WHERE a.CONFIRM_DATE >= @variable ('Start Date')
   and a.CONFIRM_DATE <= @variable ('End Date')
  and a.CONFIRM_QTY <> a.ORIG_ASSIGN_QTY
  and a.so_br_id = b.so_br_id
  and a.so_id = b.so_id
  and a.so_line_nbr = b.so_line_nbr
  and a.so_br_id = c.so_br_id
  and a.so_id = c.so_id
  and b.qty_backordered > 0 
ORDER BY a.confirm_date, c.cust_id, a.so_br_id, a.so_id

Open in new window

SOLUTION
Avatar of RgGray3
RgGray3

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jbancr1

ASKER

RgGray3,
To tell you the truth my knowledge hasn't reached the point of indexing but I do know it helps with the speed which is about what I know for indexing.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jbancr1

ASKER

dbmullen,

I have ability to change the query, I ran your query above and got a error stating 'ORA-01008  Not all variables bound :- 1008'
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial