pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Christopher Browne <cbbrowne@acm.org>
To: pgsql-performance@postgresql.org
Subject: Re: is it possible to get the optimizer to use indexes with a like clause
Date: Thu, 18 Dec 2003 22:22:38 -0500
Message-ID: <m34qvxij9d.fsf@wolfe.cbbrowne.com> (raw)
References: <3FE1F5A1.6080908@geizhals.at>
	<60n09q9bqg.fsf@dev6.int.libertyrms.info>
	<1071789528.1629.10.camel@localhost.localdomain>

pg@fastcrypt.com (Dave Cramer) wrote:
> It appears that the optimizer only uses indexes for = clause? 

It can use indices only if there is a given prefix.

Thus:
   where text_field like 'A%'

can use the index, essentially transforming this into the clauses

   where text_field >= 'A' and
         text_field < 'B'.

You can't get much out of an index for
   where text_field like '%SOMETHING'
-- 
(reverse (concatenate 'string "moc.enworbbc" "@" "enworbbc"))
http://www3.sympatico.ca/cbbrowne/wp.html
"When the grammar checker identifies an error, it suggests a
correction and can even makes some changes for you."  
-- Microsoft Word for Windows 2.0 User's Guide, p.35:



view thread (11+ messages)  latest in thread

Message-ID: <m34qvxij9d.fsf@wolfe.cbbrowne.com>
Permalink:  ../m34qvxij9d.fsf@wolfe.cbbrowne.com/
Also on:    postgresql.org/message-id/m34qvxij9d.fsf@wolfe.cbbrowne.com

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: cbbrowne@acm.org
  Subject: Re: is it possible to get the optimizer to use indexes with a like clause
  In-Reply-To: <m34qvxij9d.fsf@wolfe.cbbrowne.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