From: | Andreas Kretschmer <akretschmer(at)spamfence(dot)net> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: is it normal behavior of index? |
Date: | 2012-01-01 11:52:04 |
Message-ID: | 20120101115204.GA5297@tux |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Jean-Yves F. Barbier <12ukwn(at)gmail(dot)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°
From | Date | Subject | |
---|---|---|---|
Next Message | Jean-Yves F. Barbier | 2012-01-01 12:44:37 | Re: is it normal behavior of index? |
Previous Message | Sara Harris | 2012-01-01 10:56:14 | How to declare a variable in a postgresql query in sql language ? |