Skip site navigation (1) Skip section navigation (2)

Re: Query is slower

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Sandro Joel Eller <sandro(at)tecsoft(dot)com(dot)br>
Cc: PGSQL <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Query is slower
Date: 2004-12-01 22:23:12
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
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.

In response to

pgsql-sql by date

Next:From: Karsten HilbertDate: 2004-12-01 22:43:11
Subject: Re: inserting values into types
Previous:From: Tom LaneDate: 2004-12-01 22:11:32
Subject: Re: inserting values into types

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group