Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Make Query Faster!!

Author  Topic 

dalmada
Starting Member

12 Posts

Posted - 2006-01-06 : 12:14:19
How could I make this query faster?

SELECT
F4311LA.PDANI ACCOUNT,
'0'COLOCADO,
'0'EJECUTADO,
sum(F4311LA.PDAOPN/100) PENDIENTE,
'0'RECIBIDO,
'0'PENDIENTE_AUTOR
FROM
MOMTY01.JNTPUNFDT.F0101 F0101,
MOMTY01.JMXPMEXDT.F0901 F0901,
MOMTY01.JMXPMEXDT.F4311LA F4311LA,
MOMTY01.JMXPMEXDT.F1Z01 F1Z01
WHERE
F4311LA.PDDCTO = F1Z01.QTDCTO
AND F4311LA.PDDOCO = F1Z01.QTDOCO
AND F4311LA.PDOMCU = F0901.GMMCU
AND F4311LA.PDAN8 = F0101.ABAN8
AND F4311LA.PDNXTR<'790'
AND F4311LA.PDDCTO In ('AI','AO','CE','CF','CS','OA','OC','OI','ON','OS')
AND (F0901.GMPEC<>'N')
AND (F0901.GMSUB<>'99999000')
AND F4311LA.PDOBJ = F0901.GMOBJ
AND F4311LA.PDOMCU between '100000000000' and '265999999999'
AND F4311LA.PDSUB = F0901.GMSUB
AND F4311LA.PDSFXO ='000'
GROUP BY
F4311LA.PDANI

MichaelP
Jedi Yak

2489 Posts

Posted - 2006-01-06 : 14:21:14
Well, I'd first get away from the style of joins you are using, and move to an ANSI JOIN syntax (INNER JOIN, LEFT JOIN etc).

From the looks of this statement it looks like you'll be scanning a LOT of rows.
AND F4311LA.PDOMCU between '100000000000' and '265999999999'
AND F4311LA.PDDCTO In ('AI','AO','CE','CF','CS','OA','OC','OI','ON','OS')


So, that being said, what indexes do you have on these tables?
That's about the only suggestion that I have is to create or improve your indexes.

How many reads does this query currently generate? What sort of disk subsystem is this database on?


Michael


<Yoda>Use the Search page you must. Find the answer you will. Cursors, path to the Dark Side they are. Avoid them, you must. Use Order By NewID() to get a random record you will.</Yoda>
Go to Top of Page
   

- Advertisement -