Comment 2 for bug 544437

Revision history for this message
Albert Cervera i Areny - http://www.NaN-tic.com (albert-nan) wrote :

The attached patch solves the problem by using two indexes:

- One of type btree for 'lang', 'type' and 'name' fields
- Another one of type hash for 'src' field

The reason is that hash indexes do not support multiple columns. Also note that AFAIK current indexes have no sense given that PostgreSQL can use an index composed of (lang, type, name, src) to search by (lang, type, name) only. So there was no reason for having both of them (indeed it's probably worse performance wise).

As stated by Borja, another option would be to use a partial index, but I think it complicates things a little bit and would affect performance negatively in databases with lots of large strings (ie. users with lots of large descriptions in products, for example).