Re: Postgres case insensitive searches - Mailing list pgsql-general

From Albe Laurenz
Subject Re: Postgres case insensitive searches
Date
Msg-id A737B7A37273E048B164557ADEF4A58B17BC1C74@ntex2010a.host.magwien.gv.at
Whole thread Raw
In response to Postgres case insensitive searches  (bhanu udaya <udayabhanu1984@hotmail.com>)
Responses Re: Postgres case insensitive searches  (bhanu udaya <udayabhanu1984@hotmail.com>)
List pgsql-general
bhanu udaya wrote:
> What is the best way of doing case insensitive searches in postgres using Like.

      Table "laurenz.t"
 Column |  Type   | Modifiers
--------+---------+-----------
 id     | integer | not null
 val    | text    | not null
Indexes:
    "t_pkey" PRIMARY KEY, btree (id)


CREATE INDEX t_val_ci_ind ON t ((upper(val) text_pattern_ops);

ANALYZE t;

EXPLAIN SELECT id FROM t WHERE upper(val) LIKE 'AB%';

                                  QUERY PLAN
------------------------------------------------------------------------------
 Index Scan using t_val_ci_ind on t  (cost=0.01..8.28 rows=1 width=4)
   Index Cond: ((upper(val) ~>=~ 'AB'::text) AND (upper(val) ~<~ 'AC'::text))
   Filter: (upper(val) ~~ 'AB%'::text)
(3 rows)

Yours,
Laurenz Albe

pgsql-general by date:

Previous
From: David Greco
Date:
Subject: Re: auto_explain & FDW
Next
From: David Greco
Date:
Subject: AFTER triggers and constraints