Re: [repost] partial index / funxtional idx or bad sql?

Поиск
Список
Период
Сортировка
От Josh Berkus
Тема Re: [repost] partial index / funxtional idx or bad sql?
Дата
Msg-id 200305121713.38449.josh@agliodbs.com
обсуждение исходный текст
Ответ на [repost] partial index / funxtional idx or bad sql?  (csajl <csajl@yahoo.com>)
Ответы Re: [repost] partial index / funxtional idx or bad sql?  (csajl <csajl@yahoo.com>)
Список pgsql-performance
Seth,

> SELECT p.id, p.areacode, p.content
> FROM posts p
> WHERE p.type_id = ?
> AND p.areacode in (
>   select areacode from areacodes
>    where site_id = ?
>  )

Unless you're using 7.4 from CVS, you want to get rid of that IN:

 SELECT p.id, p.areacode, p.content
 FROM posts p
 WHERE p.type_id = ?
 AND EXISTS (
  select areacode from areacodes
    where site_id = ?
    and p.areacode = areacodes.areacode
  );

See how that works, and if it's still slow, post the EXPLAIN ANALYZE.


--
-Josh Berkus
 Aglio Database Solutions
 San Francisco


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

Предыдущее
От: csajl
Дата:
Сообщение: [repost] partial index / funxtional idx or bad sql?
Следующее
От: csajl
Дата:
Сообщение: Re: [repost] partial index / funxtional idx or bad sql?