Re: Strange workaround for slow query

From: Harald Fuchs <hari(dot)fuchs(at)gmail(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: Strange workaround for slow query
Date: 2010-03-10 16:29:25
Message-ID: pupr3cqgwq.fsf@srv.protecting.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

In article <OF6136AD9B(dot)D40F3AF5-ONC12576E2(dot)002D5763-C12576E2(dot)002FBD70(at)imtechrelay(dot)nl>,
sverhagen(at)wps-nl(dot)com writes:
> SELECT * FROM events_events LEFT OUTER JOIN events_event_types ON eventType_id=
> events_event_types.id WHERE severity=70 AND (eventType_id IN (71)) ORDER BY
> datetime DESC LIMIT 50;
> Now I have at least two possibilities:
> - Implementing the dummy value as shown above in my source code to improve
> query performance (dirty but effective)
> - Further investigating what is going on, which at this point is something I
> need help with

First I'd change the query. You build an OUTER JOIN and immediately
convert it to an INNER JOIN by referencing the "severity" column.

Then show us what EXPLAIN ANALYZE says to the problem.

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Benoit Delbosc 2010-03-10 16:59:38 Re: Bad query plan inside EXISTS clause
Previous Message Tom Lane 2010-03-10 15:44:20 Re: Bad query plan inside EXISTS clause