Re: Does postgresql 9.0.4 use index on PREFIX%SUFFIX queries?

From: Filip Rembiałkowski <plk(dot)zuber(at)gmail(dot)com>
To: Edson Carlos Ericksson Richter <richter(at)simkorp(dot)com(dot)br>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Does postgresql 9.0.4 use index on PREFIX%SUFFIX queries?
Date: 2011-09-26 18:58:00
Message-ID: CAP_rww=LDnszcuie2eqSab2F4x+W+P0HZeL6AVncBzOXY9A5ew@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Edson,

1. PostgreSQL IS able to use btree index to execute this query.
More generally, it is able to use btree index for all PREFIX search.

2. You will need a special (NOT spatial) index for it
CREATE INDEX notafiscal_numeroctc_tpo_idx ON notafiscal (numeroctc
text_pattern_ops);
( see http://www.postgresql.org/docs/9.0/interactive/indexes-opclass.htmlfor
explanation).

Hope this helped.

2011/9/26 Edson Carlos Ericksson Richter <richter(at)simkorp(dot)com(dot)br>

> Dear experts,****
>
> ** **
>
> I have the following query:****
>
> ** **
>
> select * from notafiscal where numeroctc like ‘POA%34345’;****
>
> ** **
>
> Prefix is normally 3 characters, suffix varyies.****
>
> ** **
>
> Is Postgresql 9.0.4 able to use an BTREE index on notafiscal.numeroctc to
> execute this query?****
>
> ** **
>
> Should I create GIST index or something else to speed up the query?****
>
> ** **
>
> ** **
>
> Thanks,****
>
> ** **
>
> *Edson Carlos Ericksson Richter*
> *SimKorp Infomática Ltda *****
>
> Fone:****
>
> (51) 3366-7964 ****
>
> Celular:****
>
> (51) 8585-0796****
>
> [image: Embedded Image]****
>
> www.simkorp.com.br****
>
> ** **
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Merlin Moncure 2011-09-26 19:13:17 Re: "all" not inclusive of "replication" in pg_hba.conf
Previous Message Guillaume Lelarge 2011-09-26 18:47:06 Re: "all" not inclusive of "replication" in pg_hba.conf