Re: Problem with slow query with WHERE conditions with OR clause on primary keys - Mailing list pgsql-performance

From Andreas Karlsson
Subject Re: Problem with slow query with WHERE conditions with OR clause on primary keys
Date
Msg-id 52B24CB6.6060507@proxel.se
Whole thread Raw
In response to Problem with slow query with WHERE conditions with OR clause on primary keys  (Krzysztof Olszewski <kolszew73@gmail.com>)
List pgsql-performance
On 12/11/2013 12:30 AM, Krzysztof Olszewski wrote:
> select g.gd_index, gd.full_name
> from gd g join gd_data gd on (g.id_gd = gd.id_gd)
> where gd.id_gd_data = 1111 OR g.id_gd = 1111;

Have you tried writing the query to filter on gd.id_gd rather than
g.id_gd? I am not sure if the query planner will realize that it can
replace g.id_gd with gd.id_gd in the where clause.

select g.gd_index, gd.full_name
from gd g join gd_data gd on (g.id_gd = gd.id_gd)
where gd.id_gd_data = 1111 OR gd.id_gd = 1111;

--
Andreas Karlsson


pgsql-performance by date:

Previous
From: David Johnston
Date:
Subject: Re: Problem with slow query with WHERE conditions with OR clause on primary keys
Next
From: Johann Spies
Date:
Subject: query not using index