Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

30 mins to run query

Status
Not open for further replies.

Johnsf

MIS
Apr 5, 2004
45
NZ
Hi,

The query below takes exceptionally long to run and I reckon its because of the last line in the where clause. Can someone advise on how to speed it up? What would you change the last line to?

Cheers,

John

Code:
SELECT DISTINCT 
  MGN.APTYID,
  MGN.APTYSUBACC,
  PTY.APTYNAM,
  MGN.AMKTCDE,
  SEC.ASECNAM,
  MGN.ASGDCLLSTKQTY,
  TO_CHAR(MGN.AMGNDTETME,'DD-Mon-YYYY HH24:MI:SS'),
  TO_CHAR(STT.ASTTDTE,'DD-Mon-YYYY')
FROM
  TMGN MGN,
  TPTY PTY,
  TSEC SEC,
  TSTT STT
WHERE
  MGN.APTYID = PTY.APTYID AND
  MGN.AMKTCDE = SEC.AMKTCDE AND 
  MGN.ASECCDE = SEC.ASECCDE AND 
  MGN.ASGDCLLSTKQTY <> 0 AND
  SEC.ASECCDE = STT.ASECCDE(+) AND
  SEC.AMKTCDE = STT.AMKTCDE(+) AND
  STT.ASTTDTE = (SELECT MAX(S.ASTTDTE) FROM TSTT S WHERE SEC.ASECCDE = S.ASECCDE(+) AND SEC.AMKTCDE = S.AMKTCDE(+))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top