Re: BUG #2050: Bad plan by using of LIKE
| От | Bernhard Weisshuhn |
|---|---|
| Тема | Re: BUG #2050: Bad plan by using of LIKE |
| Дата | |
| Msg-id | 20051118145251.GA10668@weisshuhn.de обсуждение исходный текст |
| Ответ на | BUG #2050: Bad plan by using of LIKE ("Johannes" <postgres@arltus.de>) |
| Список | pgsql-bugs |
On Thu, Nov 17, 2005 at 06:00:35PM +0000, Johannes <postgres@arltus.de> wrote: > SELECT title FROM content WHERE title LIKE 'teane%'; > > It uses to long time, I compare this with sybase > and I was disappointed, but explain shows the reason. > > > EXPLAIN SELECT title FROM content WHERE title LIKE 'teane%'; > Seq Scan on content (cost=0.00..75647.59 rows=1 width=68) > Filter: (title ~~ 'teane%'::text) > > Now I change this SQL to: > SELECT title FROM content WHERE title >= 'teane' AND title < 'teanez'; > > I think it means the same but it works very fast by using my index. > (1600 ms up to 2 ms !! sybase uses 4 ms) You might want to take a look at http://www.postgresql.org/docs/8.1/interactive/indexes-opclass.html and build your indexes on text fields with *_pattern_ops from now on. Does the trick. cheers, bkw
В списке pgsql-bugs по дате отправления: