From: | "Pierre C" <lists(at)peufeu(dot)com> |
---|---|
To: | pgsql-performance(at)postgresql(dot)org, pasman pasmański <pasman(dot)p(at)gmail(dot)com> |
Subject: | Re: Optimizing query |
Date: | 2010-11-26 09:46:11 |
Message-ID: | op.vmruq9jseorkce@apollo13 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
Note that your LEFT JOIN condition is probably quite slow...
Please post EXPLAIN ANALYZE for this simplified version :
SELECT
R."Osoba weryfikuj?ca",
R."LP",
A."NKA",
A."NTA",
Sum("Ile")
FROM "NumeryA" A
LEFT JOIN "Rejestr stacji do naprawy" R ON (
A."NKA" = R."Numer kierunkowy"
and A."NTA" like R."Numer stacji"
and substr(A."NTA",1,5) = substr(R."Numer stacji",1,5)
)
WHERE
A."DataPliku" >= current_date-4*30
and A."KodB??du"=74::text
and R."Data weryfikacji" >= current_date-4*30
GROUP BY R."Osoba weryfikuj?ca",R."LP",A."NKA", A."NTA"
ORDER BY Sum("Ile") DESC
LIMIT 5000
And also post EXPLAIN ANALYZE for this :
SELECT
A."NKA",
A."NTA",
Sum("Ile") AS ss -- if it's in this table
FROM "NumeryA" A
WHERE
A."DataPliku" >= current_date-4*30
and A."KodB??du"=74::text
GROUP BY A."NKA", A."NTA"
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Klemme | 2010-11-26 11:38:44 | Re: Which gives good performance? separate database vs separate schema |
Previous Message | Ivan Voras | 2010-11-26 02:08:30 | Re: Performance under contention |