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

Поиск
Список
Период
Сортировка
От Andreas Karlsson
Тема Re: Problem with slow query with WHERE conditions with OR clause on primary keys
Дата
Msg-id 52B24CB6.6060507@proxel.se
обсуждение исходный текст
Ответ на Problem with slow query with WHERE conditions with OR clause on primary keys  (Krzysztof Olszewski <kolszew73@gmail.com>)
Список 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 по дате отправления:

Предыдущее
От: David Johnston
Дата:
Сообщение: Re: Problem with slow query with WHERE conditions with OR clause on primary keys
Следующее
От: Johann Spies
Дата:
Сообщение: query not using index