我有一系列联接,这些联接使用运算符LIKE,CASE和通配符将通讯录与交易表合并。该查询的执行速度非常慢:1 m 4 s 244 ms并提取:677 ms。我将如何提高该查询的性能?
from contacts left join deals on deals.associated_vids like
Case
when canonical_vid = split_part(associated_vids, ',', 1)
then concat(canonical_vid,'%')
when canonical_vid =
split_part(associated_vids, ',', (CHAR_LENGTH(associated_vids) - CHAR_LENGTH(REPLACE(associated_vids, ',', ''))) / CHAR_LENGTH(',')+1)
then concat('%',canonical_vid)
when canonical_vid is not null
then concat('%,', concat(canonical_vid,',%')) End
我希望尽可能减少整个运行时间,最好少于一分钟。