我提出了一个查询,其中我必须从评论中找到关键字。我有超过400万个关键字。特殊字符可以在评论中的任何关键字之后/之前出现,因此我必须制作超过50种模式才能找到关键字。这是查询:
[SELECT DISTINCT a.keywords,a.productID,oproduct_name
FROM review1_filter_keyword_comment as a where ("16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('% ', LCASE(a.keywords), ' %') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('% ', LCASE(a.keywords), '') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('', LCASE(a.keywords), ' %') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('', LCASE(a.keywords), '') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('% ', LCASE(a.keywords), '.%') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('%/', LCASE(a.keywords), '.%') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('%,', LCASE(a.keywords), '.%') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('%:', LCASE(a.keywords), '.%') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('%-', LCASE(a.keywords), '.%') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('', LCASE(a.keywords), '.%') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('', LCASE(a.keywords), '-%') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('%-', LCASE(a.keywords), ' %') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('%-', LCASE(a.keywords), '') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('% ', LCASE(a.keywords), '-%') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('%(', LCASE(a.keywords), '-%') OR "16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('%-', LCASE(a.keywords), ')%') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('%/', LCASE(a.keywords), '-%') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('%-', LCASE(a.keywords), '/%') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('%-', LCASE(a.keywords), ',%') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('%,', LCASE(a.keywords), '-%') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('%:', LCASE(a.keywords), '-%') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('%-', LCASE(a.keywords), ':%') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('%-', LCASE(a.keywords), '') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('%(', LCASE(a.keywords), ' %') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('% ', LCASE(a.keywords), ')%') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('%(', LCASE(a.keywords), ')%') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('%(', LCASE(a.keywords), '/%') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('%/', LCASE(a.keywords), ')%') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('%(', LCASE(a.keywords), ',%') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('%,', LCASE(a.keywords), ')%') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('%(', LCASE(a.keywords), ':%') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('%:', LCASE(a.keywords), ')%') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('% ', LCASE(a.keywords), '/%') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('', LCASE(a.keywords), '/%') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('%/', LCASE(a.keywords), '') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('%/', LCASE(a.keywords), '/%') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('%/', LCASE(a.keywords), ',%') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('%,', LCASE(a.keywords), '/%') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('%/', LCASE(a.keywords), ':%') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('%:', LCASE(a.keywords), '/%') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('% ', LCASE(a.keywords), ',%') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('%,', LCASE(a.keywords), '') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('', LCASE(a.keywords), ',%') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('%:', LCASE(a.keywords), ',%') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('%,', LCASE(a.keywords), ',%') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('%,', LCASE(a.keywords), ':%') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('', LCASE(a.keywords), ':%') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('%:', LCASE(a.keywords), ':%') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('% ', LCASE(a.keywords), ':%') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('%:', LCASE(a.keywords), ' %') OR
"16540221 AM-OH-AGC-UP64050-2-1" LIKE CONCAT('%:', LCASE(a.keywords), '')) and
a.keywords<>'' and a.keywords IS NOT NULL and LENGTH(a.keywords)>2 and
isActive='1' and productID<>'' and productID IS NOT NULL order by keywords][1]
当我单次运行此查询时,需要6021 ms。但如果我多次运行50次以上就会崩溃并显示500内部服务器错误(链接:enter image description here)。我知道我的查询需要很长时间才能运行,因为这会发生错误。所以我想知道有没有办法优化我的查询。
谢谢