From: Marc Mitchell <marcm@eisolution.com>
To: pgsql-admin@postgresql.org
Subject: LIKE operator and indexes
Date: Fri, 31 May 2002 11:31:49 -0500
Message-ID: <01f301c208c0$a9b74ae0$7501050a@eisolution.com> (raw)
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: marcm@eisolution.com
Subject: Re: LIKE operator and indexes
In-Reply-To: <01f301c208c0$a9b74ae0$7501050a@eisolution.com>
References: <01f301c208c0$a9b74ae0$7501050a@eisolution.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox