Re: is it normal behavior of index? - Mailing list pgsql-novice

From Andreas Kretschmer
Subject Re: is it normal behavior of index?
Date
Msg-id 20120101115204.GA5297@tux
Whole thread Raw
In response to is it normal behavior of index?  ("Jean-Yves F. Barbier" <12ukwn@gmail.com>)
Responses Re: is it normal behavior of index?
List pgsql-novice
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°

pgsql-novice by date:

Previous
From: Sara Harris
Date:
Subject: How to declare a variable in a postgresql query in sql language ?
Next
From: "Jean-Yves F. Barbier"
Date:
Subject: Re: is it normal behavior of index?