Re: LIKE conditions in PGSQL very, very slow!

Поиск
Список
Период
Сортировка
От Scott Marlowe
Тема Re: LIKE conditions in PGSQL very, very slow!
Дата
Msg-id dcc563d10708102006k1871eec9k95cc0a6f5e6909e9@mail.gmail.com
обсуждение исходный текст
Ответ на LIKE conditions in PGSQL very, very slow!  (".ep" <erick.papa@gmail.com>)
Список pgsql-general
On 8/10/07, .ep <erick.papa@gmail.com> wrote:
> Hi,
>
> I'm moving from the mysql camp and quite liking things like functions
> and such, but a lot of my functionality depends on queries such as
>
>    SELECT id, name, start_date
>    FROM customer
>    WHERE name LIKE 'eri%';
>
> These kinds of queries are super fast in MySQL because "eri%" type
> conditions also use the index. Is this not the case with PG?

See http://www.postgresql.org/docs/faqs.FAQ.html#item4.6
and  http://www.postgresql.org/docs/8.2/static/indexes-opclass.html

> While we're at it, are compound indexes ok in PGSQL as well? In MySQL,
> the order of columns is important if it reflects my WHERE conditions
> in SQL. Should I follow the same structure in PGSQL? I tried looking
> at the manual but did not find a section that talks about indexing in
> detail. Would appreciate pointers.

Yes, order is important.  This is true for most any database and
multi-column indexes.
See http://www.postgresql.org/docs/8.2/static/indexes-multicolumn.html

Also read the rest of the docs on indexes here:
http://www.postgresql.org/docs/8.2/static/indexes.html

You can do some interesting things with indexes in pgsql, like partial
and expression based indexes.

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

Предыдущее
От: ".ep"
Дата:
Сообщение: LIKE conditions in PGSQL very, very slow!
Следующее
От: Julio Cesar Sánchez González
Дата:
Сообщение: Re: Unable to connect to PostgreSQL server via PHP