I have database with around 50.000 records. Let say that I have this query (it is just a part) in stored procedure (using c# + sqlserver):
SELECT ....
FROM
Table1 t1
LEFT JOIN Table2 t2 ON t1.ID=t2.ID
LEFT JOIN Table3 t3 ON t2.ColumnName=t3.ColumnName
WHERE
ISNULL(t1.ColumnName,'') LIKE @arg1 //FAST
ISNULL(t2.ColumnName2,'') LIKE @arg2//SLOW
ISNULL(t3.ColumnName,'') LIKE @arg3 //SLOW
If I search after t3.Column2 a Query is slow. If I look after some t1 column (where is not left join), then it works like a charm, very fast. What is the problem? How can I speed up this? I tried to not use joins but it's not possible. Can I put some index on tables? On which in this particiular case?