From: Stephan Szabo <sszabo@megazone.bigpanda.com>
To: Sandro Joel Eller <sandro@tecsoft.com.br>
Cc: PGSQL <pgsql-sql@postgresql.org>
Subject: Re: Query is slower
Date: Wed, 1 Dec 2004 14:23:12 -0800 (PST)
Message-ID: <20041201142001.M66421@megazone.bigpanda.com> (raw)
In-Reply-To: <41AE1B03.50205@tecsoft.com.br>
References: <41AE1B03.50205@tecsoft.com.br>
On Wed, 1 Dec 2004, Sandro Joel Eller wrote:
> I have a query using "like" operator (select * from name like 'JOHN%'),
> but the table has about 500 hundred records. The has a index (create
> index ixcontract_name on contract (name)) , but it is very slow because
> it is not using index. How do I do the query to use index?
Well, there are two possibilities. The more likely one is that the
database is not in "C" locale so it won't use the index described (it
would need an index with a <type>_pattern_ops operator class). If this is
the case, the two options are making the pattern_ops index or re-initdb
with "C" locale.
The other, less likely, option is that it's expecting a large percentage
of rows to match which you can check with EXPLAIN.
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-sql@postgresql.org
Cc: sszabo@megazone.bigpanda.com, sandro@tecsoft.com.br
Subject: Re: Query is slower
In-Reply-To: <20041201142001.M66421@megazone.bigpanda.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