Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id CAFCA4766D0 for ; Fri, 31 May 2002 12:33:12 -0400 (EDT) Received: from dg.eisolution.com (dsl-209-81-146-10.dsl.iwc.net [209.81.146.10]) by postgresql.org (Postfix) with ESMTP id 9EFB0476655 for ; Fri, 31 May 2002 12:27:01 -0400 (EDT) Received: from marcmdelltop (dg117 [10.5.1.117]) (authenticated) by dg.eisolution.com (8.11.6/8.11.6) with ESMTP id g4VGUFU29765 for ; Fri, 31 May 2002 11:30:15 -0500 Message-ID: <01f301c208c0$a9b74ae0$7501050a@eisolution.com> From: "Marc Mitchell" To: Subject: LIKE operator and indexes Date: Fri, 31 May 2002 11:31:49 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2919.6600 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600 X-Archive-Number: 200205/258 X-Sequence-Number: 4433 Can anyone provide definitive information and/or points of reference within the documentation about the ability of the query optimizer to use indexes when processing a "LIKE" operator on a String column? My assumption is that "SELECT * FROM customer WHERE name LIKE 'GENERAL%';" should benefit from the existence of a BTREE index on the "customer.name" column. I know this is the case is most other RDBMS's I've used including Postgres's ancestor Ingres. However, experiments with EXPLAIN seem to always result in Seq Scans. Furthermore, per the documentation: "7.2. Index Types... In particular, the PostgreSQL query optimizer will consider using a B-tree index whenever an indexed column is involved in a comparison using one of these operators: <, <=, =, >=, > ", the LIKE operator is conspicuously missing. However, I've yet to find a reference specifically talking about LIKE and query plans. There is no reference in "4.6.1. Pattern Matching with LIKE" . I'd like to know if indexes can be used and I've go something else setup wrong or if indexes and LIKEs don't mix. Marc Mitchell - Senior Application Architect Enterprise Information Solutions, Inc. marcm@eisolution.com