Subject RE: [firebird-support] Query doen't want to use index
Author Nigel Weeks
Don't put the '%' at the beginning - then it'll use the index.

If you've got wildcards at the beginning and the end, it has no choice but
to do a brute-force scan of the entire table.

N.

> -----Original Message-----
> From: adiw_db [mailto:adiw_db@...]
> Sent: Tuesday, 18 January 2005 6:03 AM
> To: firebird-support@yahoogroups.com
> Subject: [firebird-support] Query doen't want to use index
>
>
>
>
>
> Hi, I have one table that contains 110.000 records.
>
> I ran a query to this table :
> select knokat from lib_judul where k245a like '%MATEMATIKA%'
> But it doesn't use available indexes (both fields are indexed).
> PLAN (LIB_JUDUL NATURAL)
> It took almost 14 seconds to finish.
>
> If I changed the query :
> select knokat from lib_judul where k245a like 'MATEMATIKA'
> or
> select knokat from lib_judul where k245a = 'MATEMATIKA'
> It used index, and finished less than a second.
> PLAN (LIB_JUDUL INDEX (IDX_LIB_JUDUL_K245A))
>
> I tried at FB1.0 on linux and FB1.5 on WinXP Pro.
>
> Can someone explain to me how to use index?
>
> Thank you.
> Adi.
>
>
>
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
>
> __________ NOD32 1.974 (20050117) Information __________
>
> This message was checked by NOD32 antivirus system.
> http://www.nod32.com
>
>