Re: mysterious difference in speed when combining two queries with OR

Поиск
Список
Период
Сортировка
От Gregory Stark
Тема Re: mysterious difference in speed when combining two queries with OR
Дата
Msg-id 873apcu284.fsf@oxford.xeocode.com
обсуждение исходный текст
Ответ на Re: mysterious difference in speed when combining two queries with OR  (Hans Ekbrand <hans.ekbrand@sociology.gu.se>)
Список pgsql-performance
"Hans Ekbrand" <hans.ekbrand@sociology.gu.se> writes:

> No, I just wanted to show the time differences, I haven't used join
> before. Now that you have adviced me to, I have tried your suggestion
> to rewrite B as a union and it works good! Just as fast as the A Query!

You can even do better. If you know the two sets of mid are disjoint you can
use UNION ALL. If not you could remove the two DISTINCTs as the UNION will
take care of removing duplicates.

--
  Gregory Stark
  EnterpriseDB          http://www.enterprisedb.com
  Ask me about EnterpriseDB's On-Demand Production Tuning

В списке pgsql-performance по дате отправления:

Предыдущее
От: PFC
Дата:
Сообщение: Re: mysterious difference in speed when combining two queries with OR
Следующее
От: "Jeffrey Baker"
Дата:
Сообщение: Re: SELECT 'DBD::Pg ping test'