trivial like clauses and indexes question - Mailing list pgsql-novice

From jens
Subject trivial like clauses and indexes question
Date
Msg-id 43569E50.5070808@transversal.com
Whole thread Raw
List pgsql-novice
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


pgsql-novice by date:

Previous
From: Michael Fuhr
Date:
Subject: Re: Displaying current query - eliminating
Next
From: Benjamin Power
Date:
Subject: Postgresql installation - Cannot add postgres user (already in use)