Re: Problem with slow query with WHERE conditions with OR clause on primary keys

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


--
Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance




[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux