I have 2 tables, ie;
In TableA there is around 10million rows,
In TableB there is around 500k rows
TableA (10million rows) Url ------------------------------------------- http://www.example.com/data/tuesday-morning http://www.example.com/data/wednesday-evening TableB (500k rows) Keyword Value --------- ---------- Sunday 0 Monday 0 Tuesday 0 Wednesday 0 I want to search all keywords in TableB in TableA, and find the matches, which one matches to update their Value to 1.
I use MERGE, but the problem is it takes at least 10 hours to make that search.
I will make that search everyday, because the KEYWORDs are updating daily in TableB
MERGE INTO TableB As TB USING (Select Url From TableA) As TA ON TA.Url LIKE 'http://www.example.com/data/'+TB.Keyword+'-%' WHEN MATCHED THEN UPDATE SET TB.Value=1; What will be the best SQL query to make the fastest lookup between these 2 tables?
Many Thanks
(Select Url From TableA)that for sure slows down your query, use justTableAlike '%'+t2.keyword+'%'with language constructs specific to full-text indexes which are way faster.