pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Cédric Villemain <cedric@2ndquadrant.com>
To: pgsql-performance@postgresql.org
Cc: Guillaume Cottenceau <gc@mnc.ch>
Subject: Re: non index use on LIKE on a non pattern string
Date: Fri, 8 Jun 2012 13:51:50 +0200
Message-ID: <201206081351.54589.cedric@2ndquadrant.com> (raw)
In-Reply-To: <m3mx4eys6o.fsf@mnc.ch>
References: <m3mx4eys6o.fsf@mnc.ch>

> I have noticed that with a SELECT query containing the following
> constraint:
> 
>     column LIKE ?
> 
> and an index on that column, PostgreSQL will not use the index
> even if the parameter doesn't contain special pattern characters
> such as %.

you should have a postgresql 8.3,isn't it ?
 like is equal to "=" in your case, since 8.4

Also you probably want to have a look at
 http://www.postgresql.org/docs/9.1/static/indexes-opclass.html 
about your index definition (add the "text_pattern_ops" when required)

-- 
Cédric Villemain +33 (0)6 20 30 22 52
http://2ndQuadrant.fr/
PostgreSQL: Support 24x7 - Développement, Expertise et Formation

Attachments:

  signature.asc (application/pgp-signature, 489B) download

view thread (4+ messages)  latest in thread

Message-ID: <201206081351.54589.cedric@2ndquadrant.com>
Permalink:  ../201206081351.54589.cedric@2ndquadrant.com/
Also on:    postgresql.org/message-id/201206081351.54589.cedric@2ndquadrant.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: cedric@2ndquadrant.com, gc@mnc.ch
  Subject: Re: non index use on LIKE on a non pattern string
  In-Reply-To: <201206081351.54589.cedric@2ndquadrant.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