Re: Many left outer joins with limit performance

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Gerhard Wiesinger <lists(at)wiesinger(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Many left outer joins with limit performance
Date: 2009-05-01 16:14:10
Message-ID: 13700.1241194450@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Gerhard Wiesinger <lists(at)wiesinger(dot)com> writes:
> FROM
> log l
> -- Order is relevant here
> LEFT OUTER JOIN key_description k1 ON k1.description = 'Raumsolltemperatur'
> LEFT OUTER JOIN log_details d1 ON l.id = d1.fk_id AND d1.fk_keyid = k1.keyid

Surely this query is just plain broken? You're forming a cross product
of the relevant log lines with the k1 rows having description =
'Raumsolltemperatur' (I assume this isn't unique, else it's not clear
what the point is) and then the subsequent left join cannot get rid of
anything. I think probably you meant something different, like

FROM
log l
LEFT OUTER JOIN log_details d1 ON l.id = d1.fk_id
LEFT OUTER JOIN key_description k1 ON k1.description = 'Raumsolltemperatur' AND d1.fk_keyid = k1.keyid

regards, tom lane

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Scott Carey 2009-05-01 17:14:57 Re: Transparent table partitioning in future version of PG?
Previous Message James Nelson 2009-05-01 15:42:46 Re: bad plan and LIMIT