LIKE conditions in PGSQL very, very slow!

Поиск
Список
Период
Сортировка
От .ep
Тема LIKE conditions in PGSQL very, very slow!
Дата
Msg-id 1186799769.611683.163150@x40g2000prg.googlegroups.com
обсуждение исходный текст
Ответы Re: LIKE conditions in PGSQL very, very slow!
Re: LIKE conditions in PGSQL very, very slow!
Список pgsql-general
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?

Here's the EXPLAIN output:


CUSTDB=# explain select id,name,start_date from customer where name
like 'eri%';
                           QUERY PLAN
----------------------------------------------------------------
 Seq Scan on customer  (cost=0.00..86032.18 rows=1 width=111)
   Filter: ((name)::text ~~ 'eri%'::text)
(2 rows)


Would appreciate any thoughts on how to make these kinds of queries
faster. I found a message (http://archives.postgresql.org/pgsql-sql/
1999-12/msg00218.php) but that's from 1999.

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.

Thanks!


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

Предыдущее
От: "Peter Marius"
Дата:
Сообщение: Re: CREATE RULE on VIEW with INSERT after UPDATE does not work
Следующее
От: "Scott Marlowe"
Дата:
Сообщение: Re: LIKE conditions in PGSQL very, very slow!