Re: Best way to use indexes for partial match at beginning - Mailing list pgsql-general

From Jaime Casanova
Subject Re: Best way to use indexes for partial match at beginning
Date
Msg-id c2d9e70e0511091315x715c9749k3ca5d316bc5417a3@mail.gmail.com
Whole thread Raw
In response to Re: Best way to use indexes for partial match at beginning  ("Andrus" <eetasoft@online.ee>)
List pgsql-general
On 11/9/05, Andrus <eetasoft@online.ee> wrote:
> > you can create two indexes:
> >
> > CREATE INDEX myindex_lc on mytable(col1 text_pattern_ops);
> > and
> > CREATE INDEX myindex_normal ON foo(col1);
> >
> > the first one will be used when using LIKE and the other for normal
> > comparisons .
>
> Jaime,
>
> CREATE INDEX myindex_normal ON foo(col1);
>
> Creates btree structure. In other dbm system btree structure can be used for
> searches where only some first characters in index key are known.
>

and the same is true for postgres when you use C LOCALE, but because
some implementation details i don't know so deep when using non-C
LOCALE you need the class operator in order to use the index with LIKE
'pattern%'

> So I see no reason to create second index using text_pattern_ops for this
> purpose.
>

the reason is that you want to use the index in the search... and, at
least you go and solve the problem with code, that's the way to do
it...


--
regards,
Jaime Casanova
(DBA: DataBase Aniquilator ;)

pgsql-general by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: Best way to use indexes for partial match at beginning
Next
From: "Dean Gibson (DB Administrator)"
Date:
Subject: Re: Best way to use indexes for partial match at beginning