I have a query (stored proc) that uses a LIKE statement on a Varchar column and it takes 6 seconds to run. As this is returning a results set to an application, this performance is unnacceptable.
Query :
The @Variable is obviously passed in to the stored proc!
If i take out the Wildcard character that comes before the variable it only takes about 1 second to run (which is fine), but i would really rather not do this, as users WILL Want to be able to do partial matches on both sides of the entered word.
e.g. entering 'Brown' would return ( for the Client Name Column)
1 Brown Associates
2 Brown & Jones
3 Mithell Brown Group
4 Davis, Brown & Partners
instead of
1 Brown Associates
2 Brown & Jones
So is thier any other way to speed up this type of query ??
Any help will be greatly appricated as i have spent all day looking at this and got nowhere !!!
Regards
Richard
Query :
Code:
SELECT m.m_mat_id, m.m_clt_code, m.m_mat_num, m.m_clt_name,
m_mat_desc, t.at_desc, a.add_type_id, a.add_id
FROM matters m, addresstypes t, addresses a, mat_addr_lnk l WITH (NOLOCK)
WHERE (m.m_clt_name LIKE '%' + @Variable + '%')
and m.m_mat_id = l.mat_id
and a.add_id = l.add_id
and a.add_type_id = t.at_type_id
ORDER BY m.m_clt_code, m.m_mat_num ASC
If i take out the Wildcard character that comes before the variable it only takes about 1 second to run (which is fine), but i would really rather not do this, as users WILL Want to be able to do partial matches on both sides of the entered word.
e.g. entering 'Brown' would return ( for the Client Name Column)
1 Brown Associates
2 Brown & Jones
3 Mithell Brown Group
4 Davis, Brown & Partners
instead of
1 Brown Associates
2 Brown & Jones
So is thier any other way to speed up this type of query ??
Any help will be greatly appricated as i have spent all day looking at this and got nowhere !!!
Regards
Richard