Jean-Yves F. Barbier <12ukwn@gmail.com> wrote:
> Hi list,
>
> Simple test table w/ a varchar(32): if I create an index with
> 'varchar_pattern_ops' explain says it is NOT used in my query;
> if I create it without it is used (?!)
Please show more details and/or an example. I have one for you:
test=# create table words ( w text);
CREATE TABLE
Time: 5,829 ms
test=*# copy words from '/usr/share/dict/ngerman';
COPY 320577
Time: 458,902 ms
test=*# create index idx_words on words (w varchar_pattern_ops);
CREATE INDEX
Time: 1270,534 ms
test=*# explain select * from words where w = 'foo';
QUERY PLAN
----------------------------------------------------------------------------
Bitmap Heap Scan on words (cost=36.72..1781.30 rows=1603 width=32)
Recheck Cond: (w = 'foo'::text)
-> Bitmap Index Scan on idx_words (cost=0.00..36.32 rows=1603 width=0)
Index Cond: (w = 'foo'::text)
(4 rows)
Time: 0,467 ms
As you can see, there is an index WITH varchar_pattern_ops, and the
index used for the query.
Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect. (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly." (unknown)
Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889°