From: | Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com> |
---|---|
To: | Josh Berkus <josh(at)agliodbs(dot)com> |
Cc: | Reece Hart <reece(at)harts(dot)net>, SF PostgreSQL <sfpug(at)postgresql(dot)org> |
Subject: | Re: Arg! PG not using index on an analyzed table |
Date: | 2005-02-02 19:55:29 |
Message-ID: | 20050202115427.G65380@megazone.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | sfpug |
On Wed, 2 Feb 2005, Josh Berkus wrote:
> Stephen,
>
> > You may also be able to get away with another index on the column using
> > text_pattern_ops as the operator class if you need/want other en_US
> > features.
>
> Huh. Can you give me an example?
template1=# show LC_COLLATE;
lc_collate
------------
en_US
(1 row)
template1=# create table test(a text);
CREATE TABLE
template1=# create index testindex1 on test(a);
CREATE INDEX
-- fill table in here
template1=# explain select * from test where a='a';
QUERY PLAN
----------------------------------------------------------------------------
Index Scan using testindex1 on test (cost=0.00..814.09 rows=264
width=32)
Index Cond: (a = 'a'::text)
(2 rows)
template1=# explain select * from test where a ~ '^a';
QUERY PLAN
----------------------------------------------------------
Seq Scan on test (cost=0.00..1136.80 rows=276 width=32)
Filter: (a ~ '^a'::text)
(2 rows)
template1=# create index testindex2 on test(a text_pattern_ops);
CREATE INDEX
template1=# explain select * from test where a ~ '^a';
QUERY PLAN
---------------------------------------------------------------------------
Index Scan using testindex2 on test (cost=0.00..294.85 rows=79 width=32)
Index Cond: ((a ~>=~ 'a'::text) AND (a ~<~ 'b'::text))
Filter: (a ~ '^a'::text)
(3 rows)
From | Date | Subject | |
---|---|---|---|
Next Message | Reece Hart | 2005-02-02 20:08:09 | Re: Arg! PG not using index on an analyzed table |
Previous Message | Josh Berkus | 2005-02-02 19:15:53 | Re: Arg! PG not using index on an analyzed table |