Re: Index on substring - Mailing list pgsql-general

From Szymon Guz
Subject Re: Index on substring
Date
Msg-id BANLkTinjUhGMc985QhDHKunHadM0MsGhjg@mail.gmail.com
Whole thread Raw
In response to Index on substring  (Håvard Wahl Kongsgård <haavard.kongsgaard@gmail.com>)
List pgsql-general


2011/6/5 Håvard Wahl Kongsgård <haavard.kongsgaard@gmail.com>
Hi, my database performance badly on substring comparison between two very large tables. 
In postgresql 8.4 is it possible to create a index on a substring, or must I create an new field for the substring match ( and then create a new index for that field)?

--
Håvard Wahl Kongsgård

http://havard.security-review.net/



Hi,
I've checked that for 9.0, however for 8.4 should work as well:

CREATE INDEX  i_test_sbstr ON test( substring(t, 5, 3) );

It is important that the substring() parameters in the index definition are the same as you use in your query.

regards
Szymon

pgsql-general by date:

Previous
From: Håvard Wahl Kongsgård
Date:
Subject: Index on substring
Next
From: Toby Corkindale
Date:
Subject: Re: Question about configuration and SSD