Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Like %keyword% performance problem

Author  Topic 

arkhon13
Starting Member

2 Posts

Posted - 2009-06-05 : 05:38:00
Hello
I have a table that has 2 columns; int "OID" and nvarchar(Max)"Metin"
"Metin" holds data approximately 60.000-100.000 chars long
Ihave around 3000 rows

My Query test:
SELECT OID FROM IhaleMetni
WHERE ( IhaleMetni.Metin LIKE '%aa%')
I check clientStatistics; this query takes around 1.2 seconds

But when i change it to:
SELECT OID FROM IhaleMetni
WHERE ( IhaleMetni.Metin LIKE '%aaa%')
Wait time on server is significantly changed (11seconds)

(I think my data is not that big i heard someones had 800k rows etc..)
So is Like queries always this slow?? Or i miss a point?

Thank you very much for your advices..

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2009-06-05 : 11:35:49
Yeah, they are generaly slow. Since you have a wild card (%) in front of the string sql cannot use an index, thus it will scan the entire table. If you need to increase performance, you might look into Full-Text Indexes.
Go to Top of Page
   

- Advertisement -