Re: Ignored btree indexes on particular tables. - Mailing list pgsql-general

From Richard Huxton
Subject Re: Ignored btree indexes on particular tables.
Date
Msg-id 475EA3F5.1040203@archonet.com
Whole thread Raw
In response to Ignored btree indexes on particular tables.  ("William Temperley" <willtemperley@gmail.com>)
Responses Re: Ignored btree indexes on particular tables.
List pgsql-general
William Temperley wrote:
> My problem is I have several text fields in the address data, for which
> postgres ignores the indexes (btree).

> "Index Scan using ap_idx_pc on ap  (cost= 0.00..15.30 rows=1 width=188)"
> "  Index Cond: (((pc_)::text >= 'OX2 0'::character varying) AND ((pc_)::text
> < 'OX2 1'::character varying))"
> "  Filter: ((pc_)::text ~~ 'OX2 0%'::text)"
>
> And the NEW:-
> "Seq Scan on ap  (cost=0.00..4652339.33 rows=1 width=189)"
> "  Filter: ((pc_)::text ~~ 'OX2 0%'::text)"

It's almost certainly a locale thing. Your old locale was "C" and the
new one is "en_GB.UTF-8" or similar. This means that simple sorting has
been replaced by something more library-like.

You can either dump the database, re-run initdb with the "C" locale and
restore, or read up on text_pattern_ops/varchar_pattern_ops in the
manual (11.8. Operator Classes). Basically it tags an index as working
with pattern-matching in the current locale.

> the strange thing is my btree indexes on the uk roads data work fine.

Do they use like, or explicit range-checks?

--
   Richard Huxton
   Archonet Ltd

pgsql-general by date:

Previous
From: "Keith Turner"
Date:
Subject: Hijack!
Next
From: Richard Huxton
Date:
Subject: Re: Hijack!