Обсуждение: trivial like clauses and indexes question

Поиск
Список
Период
Сортировка

trivial like clauses and indexes question

От
jens
Дата:
Hello,

I'm trying to do a simple select with a like clause,

explain select * from test where name like '_100_100_100%';
                       QUERY PLAN
-------------------------------------------------------
  Seq Scan on test  (cost=0.00..589.54 rows=1 width=68)
    Filter: ((name)::text ~~ '_100_100_100%'::text)

but it's not using any key though

explain select * from test where name = '_100_100_100';
                                QUERY PLAN
-------------------------------------------------------------------------
  Index Scan using idx_nrm on test  (cost=0.00..360.11 rows=104 width=68)
    Index Cond: ((name)::text = '_100_100_100'::text)

is and my keys are defined as

              Table "public.test"
  Column |          Type          | Modifiers
--------+------------------------+-----------
  name   | character varying(100) |
Indexes:
     "idx" btree (name varchar_pattern_ops)
     "idx_nrm" btree (name)

What's the problem here? My locale isn't C, if this makes some difference.

Thanks for any help,

Jens