Re: Strange workaround for slow query - Mailing list pgsql-performance

From Harald Fuchs
Subject Re: Strange workaround for slow query
Date
Msg-id pupr3cqgwq.fsf@srv.protecting.net
Whole thread Raw
In response to Strange workaround for slow query  (sverhagen@wps-nl.com)
List pgsql-performance
In article <OF6136AD9B.D40F3AF5-ONC12576E2.002D5763-C12576E2.002FBD70@imtechrelay.nl>,
sverhagen@wps-nl.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.

pgsql-performance by date:

Previous
From: Tom Lane
Date:
Subject: Re: Bad query plan inside EXISTS clause
Next
From: Benoit Delbosc
Date:
Subject: Re: Bad query plan inside EXISTS clause