Re: Planner should use index on a LIKE 'foo%' query

Поиск
Список
Период
Сортировка
От Dimitri Fontaine
Тема Re: Planner should use index on a LIKE 'foo%' query
Дата
Msg-id 200806301220.43392.dfontaine@hi-media.com
обсуждение исходный текст
Ответ на Planner should use index on a LIKE 'foo%' query  (Moritz Onken <onken@houseofdesign.de>)
Список pgsql-performance
Hi,

Le samedi 28 juin 2008, Moritz Onken a écrit :
> select count(*)
>   from result
>   where exists
>     (select * from item where item.url LIKE result.url || '%' limit 1);
>
> which basically returns the number of items which exist in table
> result and match a URL in table item by its prefix.

It seems you could benefit from the prefix project, which support indexing
your case of prefix searches. Your query would then be:
  SELECT count(*) FROM result r JOIN item i ON r.url @> i.url;

The result.url column would have to made of type prefix_range, which casts
automatically to text when needed.

Find out more about the prefix projects at those urls:
  http://pgfoundry.org/projects/prefix
  http://prefix.projects.postgresql.org/README.html

Regards,
--
dim

Вложения

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

Предыдущее
От: Matthew Wakeling
Дата:
Сообщение: Re: Planner should use index on a LIKE 'foo%' query
Следующее
От: John Beaver
Дата:
Сообщение: Re: sequence scan problem