LIKE and INDEX

From: "Jie Liang" <jie(at)stbernard(dot)com>
To: <pgsql(at)postgresql(dot)org>
Cc: <pgsql-performance(at)postgresql(dot)org>
Subject: LIKE and INDEX
Date: 2004-04-28 22:02:04
Message-ID: E7E213858379814A9AE48CA6754F5ECB36335D@mail01.stbernard.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

All,
This is old topic, when I use:
select url from urlinfo where url like 'http://www.lycos.de%';
it uses the index, good!

but if I use:
select url from urlinfo where url like 'http://%.lycos.de';
it won't use index at all, NOT good!
is there any way I can force secon query use index???

Thanks.

Jie Liang

QUERY PLAN
------------------------------------------------------------------------------------------------
Index Scan using urlinfo_ukey on urlinfo (cost=0.00..6.01 rows=1 width=33)
Index Cond: ((url >= 'http://www.lycos.de/'::text) AND (url < 'http://www.lycos.de0'::text))
Filter: (url ~ '^http://www\\.lycos\\.de/.*$'::text)
(3 rows)

QUERY PLAN
-------------------------------------------------------------
Seq Scan on urlinfo (cost=0.00..100440.48 rows=4 width=33)
Filter: (url ~ '^http://.*\\.lycos\\.de$'::text)
(2 rows)

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Robert Creager 2004-04-29 00:57:53 Re: Wierd context-switching issue on Xeon
Previous Message Jie Liang 2004-04-28 20:41:21 Re: [ADMIN] 7.4.2 out of memory