From: Scott Marlowe <smarlowe@g2switchworks.com>
To: Ibrahim Tekin <itekin@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: LIKE query on indexes
Date: Tue, 21 Feb 2006 10:18:00 -0600
Message-ID: <1140538679.5777.3.camel@state.g2switchworks.com> (raw)
In-Reply-To: <e4dcba670602210757n2caf7c15t2a93353c9081c51f@mail.gmail.com>
References: <e4dcba670602210757n2caf7c15t2a93353c9081c51f@mail.gmail.com>
On Tue, 2006-02-21 at 09:57, Ibrahim Tekin wrote:
> hi,
> i have btree index on a text type field. i want see rows which starts
> with certain characters on that field. so i write a query like this:
>
> SELECT * FROM mytable WHERE myfield LIKE 'john%'
>
> since this condition is from start of the field, query planner should
> use index to find such elements but explain command shows me it will
> do a sequential scan.
>
> is this lack of a feature or i am wrong somewhere?
This is an artifact of how PostgreSQL handles locales other than ASCII.
If you want such a query to use an index, you need to back up your
database, and re-initdb with --locale=C as an argument. Note that you
then will NOT get locale specific matching and sorting.
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: smarlowe@g2switchworks.com, itekin@gmail.com
Subject: Re: LIKE query on indexes
In-Reply-To: <1140538679.5777.3.camel@state.g2switchworks.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