Re: Optimizing query - Mailing list pgsql-performance

From Pierre C
Subject Re: Optimizing query
Date
Msg-id op.vmruq9jseorkce@apollo13
Whole thread Raw
In response to Optimizing query  (pasman pasmański <pasman.p@gmail.com>)
List 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"

pgsql-performance by date:

Previous
From: Ivan Voras
Date:
Subject: Re: Performance under contention
Next
From: Robert Klemme
Date:
Subject: Re: Which gives good performance? separate database vs separate schema