On Thu, Nov 17, 2005 at 06:00:35PM +0000, Johannes <[EMAIL PROTECTED]> 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 ---------------------------(end of broadcast)--------------------------- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq