Subject Re: [firebird-support] CONTAINING in SELECT statement and indexes
Author Helen Borrie
At 10:07 PM 2/12/2007, you wrote:
>Hello folks,
>
>First of all thank you for setting up this group.
>
>Second, I have a question regarding indexes and the CONTAINING in a
>SELECT. I think I have reade somewhere (not quite sure where or if I
>read it correctly), but I want to confirm if using CONTAINING, it
>makes use of indexes we create.
>I know that like does not use index. But, if we, for example, use like
>with '%text', then it gets translated to STARTS WITH 'text', which
>uses indexes.
>
>I know that CONTAINING is case insensitive, and I was wondering if we
>can use indexes with it.

CONTAINING cannot use an index.

>If not, than what is the alternative solution we can use?

Store keywords, index those and search on the keywords? The trick is to store each keyword once, uniquely and also case-insensitively if you want, in a separate table. Create an intersection table with foreign keys to the document record and the keyword record. Then your SELECT will find the ids of documents containing the matching keyword or STARTING WITH a stub string, both of which can make use of the indexes.

./heLen