Subject | Re: Query speed is going down |
---|---|
Author | jjochoa75 |
Post date | 2005-07-01T22:17:27Z |
> SELECT M.OPIS AS MAGAZYN,AS
> CAST(T.KODKRESKOWY AS INTEGER) AS KOD,T.NAZWA AS NAZWA,SUM(p.ILOSC)
> ILOSC,AS
> CAST(P.CZNETTO AS DECIMAL(18,2)) AS CZNETTO,
> CAST(SUM(P.CZNETTO*P.ILOSC) AS DECIMAL(18,2)) AS WZNETTO,
> CAST(P.CSBRUTTO AS DECIMAL(18,2)) AS CSBRUTTO,
> CAST(SUM(P.CSNETTO*P.ILOSC) AS DECIMAL(18,2)) AS WSNETTO,
> CAST(SUM(P.CSBRUTTO*P.ILOSC) AS DECIMAL(18,2)) AS WSBRUTTO,
> CAST((100*(SUM(P.CSNETTO*P.ILOSC) -
> SUM(P.CZNETTO*P.ILOSC))/(SUM(P.CSNETTO*P.ILOSC))) AS DECIMAL(4,2))
> PROC_MARZY,(18,2))
> CAST((SUM(P.CSNETTO*P.ILOSC) - SUM(P.CZNETTO*P.ILOSC)) AS DECIMAL
> AS MARZAJust some questions:
> FROM POZSPRZEDAZ P
> INNER JOIN SPRZEDAZ Z ON (P.IDSPR = Z.ID AND
> Z.DATASPRZEDAZY BETWEEN '2005-02-01' AND '2005-02-01'
> AND ((Z.GODZINA BETWEEN 8 AND 8) OR Z.GODZINA=0))
> INNER JOIN TOWARY T ON (P.IDTOW=T.ID)
> INNER JOIN MAGAZYNY M ON (Z.IDMAG=M.ID)
> GROUP BY M.OPIS,T.KODKRESKOWY,T.NAZWA,P.CZNETTO,P.CSBRUTTO
> HAVING SUM(P.ILOSC*P.CSNETTO) <> 0
> ORDER BY M.OPIS,T.NAZWA
1. How many reads (indexed and not indexed if any) you get on:
P:
Z:
T:
M:
2. How many records you get at the end?
3. How many records do you get and P INNER JOIN Z?
4. Is Z.GODZINA=0 an allowed value?
I suppose: ((Z.GODZINA BETWEEN 8 AND 8) OR Z.GODZINA=0)) is a trick
to use the right indexes.
5. Do you get significant performance improvement if you remove the
ORDER BY Clause?
Thanks
Juan Jose