Adding a bit to what others have said.
At first, you cannot use an index based on a value in the middle of a row. Indexes are usually tree searches, and you cannot find out if your search will be faster than just scanning the table, so PostgreSQL will perform seq scanning by default. Indexes will only be used if they match the first part of the string. So:
SELECT * FROM invoice WHERE invoice_number like 'INV-2012-435%'
can use the index, but like '%44354456%' cannot.
In general, in LedgerSMB we use both options, depending on what kind of search we do. You can see the search, for example:
select * from parts WHERE partnumber ilike ? || '%' and plainto_tsquery(get_default_language(), ?) @@ description;
So these are very different things. Use each where it makes sense.
source share