sql - Speed Up Text Search Query Large Data Set -


hi i'm hoping has tip me. have query below filters detail field in #templogins table. details field text field contains many types of text strings, containing urls have parts "resultid=5" contained in resultidsearch , resultsetidsearch fields. records entries "resultid=5" ones i'm trying filter for.

the problem have query takes way long run. templogin table has around 200 k records , tempsearch table has around 80 k records.

any tips on how rewrite or speed query appreciated.

enter code here: select * #templogins exists                       (select 1 #tempsearch t1                                   a.detail '%' + t1.resultidsearch + '%'                                  or                                   a.detail '%' + t1.resultsetidsearch + '%') 

this join version problem % going table scan
index on #templogins.detail may doubt it

select distinct a.*    #templogins   join #tempsearch t1      on a.detail '%' + t1.resultidsearch + '%'     or a.detail '%' + t1.resultsetidsearch + '%'; 

this might better

select a.*    #templogins   join #tempsearch t1      on a.detail '%' + t1.resultidsearch + '%' union select a.*    #templogins   join #tempsearch t1      on a.detail '%' + t1.resultsetidsearch + '%' 

if can parse terms out of resultidsearch , resultsetidsearch , join on =


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -