X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 53FA9D1B2BD for ; Thu, 22 Jul 2004 04:38:47 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 75474-07 for ; Thu, 22 Jul 2004 07:38:44 +0000 (GMT) Received: from mail2.smarthost.net.au (unknown [203.63.194.30]) by svr1.postgresql.org (Postfix) with ESMTP id EAF6BD1B2A6 for ; Thu, 22 Jul 2004 04:38:36 -0300 (ADT) Received: from PHOENIX (unknown [10.0.0.81]) by mail2.smarthost.net.au (Postfix) with SMTP id 950FA114033 for ; Thu, 22 Jul 2004 17:35:57 +1000 (EST) Message-ID: <030e01c46fbe$e8baeb90$5100000a@PHOENIX> From: "Chris Cox" To: Subject: LIKE on index not working Date: Thu, 22 Jul 2004 17:38:28 +1000 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1409 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/169 X-Sequence-Number: 18421 Hi all, For some reason I just can't get this to use the index for the following query. I'm using PostgreSQL 7.3.4. Here's the details (let me know if you need anymore information to provide any assistance): Indexes: person_pkey primary key btree (personid), ix_person_active btree (bactive), ix_person_fullname btree (tsurname, tfirstname), ix_person_member btree (bmember), ix_person_supporter btree (bsupporter), ix_person_surname btree (lower(tsurname)) smartteamscouts=# explain analyze select * from person where bmember = 1 AND lower(tsurname) like lower('weaver'); QUERY PLAN ---------------------------------------------------------------------------- ------------------------------- Seq Scan on person (cost=0.00..12946.58 rows=310 width=416) (actual time=873.94..1899.09 rows=6 loops=1) Filter: ((bmember = 1) AND (lower((tsurname)::text) ~~ 'weaver'::text)) Total runtime: 1899.64 msec (3 rows) smartteamscouts=# explain analyze select * from person where bmember = 1 AND lower(tsurname) = lower('weaver'); QUERY PLAN ---------------------------------------------------------------------------- --------------------------------------------------- Index Scan using ix_person_surname on person (cost=0.00..1265.78 rows=310 width=416) (actual time=0.91..2.03 rows=6 loops=1) Index Cond: (lower((tsurname)::text) = 'weaver'::text) Filter: (bmember = 1) Total runtime: 2.36 msec (4 rows) As you can see, using the '=' operator it works just fine, but as soon as the 'like' operator comes into it, no good. Is this a bug in 7.3.4? Or is it something else I need to adjust? Thanks for your help! Chris