Regular Expression Interconnection

I have an inner join on regular expressions - it is very slow. Is there an easy way to speed this up? I am using postgres.

FROM A
inner join B ON trim(lower(replace(replace(replace(B.enginequery,',',' '),'"',' '),'+',' '))) = trim(lower(A.keyphrase))
             OR trim(lower(replace(replace(replace(B.enginequery,',',' '),'"',' '),'+',' '))) ~ (trim(lower(A.keyphrase)) || '$')
             OR trim(lower(replace(replace(replace(B.enginequery,',',' '),'"',' '),'+',' '))) ~ (trim(lower(A.keyphrase)) || ' ')
0
source share
2 answers

Is there an easy way to speed this up?

The reason for performance is all operations, not to mention regular expressions, which must be performed only in order to make a match. You need to simplify the relationship so that it does not need to be performed.

+3
source

I would start by posting the results:

 trim (lower (replace (replace (replace (B.enginequery, ',', ''), '"', ''), '+', '')))

. , . postgres, . Ms sql server , B.enginequery .

, , .

+1

All Articles