如何替换查询中的like语句列表来优化它?

rpppsulh  于 2021-07-29  发布在  Java
关注(0)|答案(0)|浏览(231)

我必须用许多like and and语句优化查询,因为由于表中的数据量太大,搜索速度变得非常慢。
我读过一些关于索引和全文索引的书,但不知道如何使用它们。
下面是一个查询示例:

SELECT o.* 
FROM (
        (op INNER JOIN o on op.idordine=o.idordine) 
        INNER JOIN f on f.idfornitore=o.idfornitore
    ) 
    INNER JOIN u on u.idutente=o.idutente
WHERE f.ragsoc COLLATE UTF8_GENERAL_CI LIKE '%something%' 
AND u.idutente  COLLATE UTF8_GENERAL_CI LIKE '%somethingelse%' 
AND o.codice  COLLATE UTF8_GENERAL_CI LIKE '%something%' 
AND (o.autorizzazione  COLLATE UTF8_GENERAL_CI LIKE '%somethingelse%' 
    OR o.autorizzazione2  COLLATE UTF8_GENERAL_CI LIKE '%something%'
    ) 
AND (op.codice  COLLATE UTF8_GENERAL_CI LIKE '%somethingelse%' 
    OR op.descrizione  COLLATE UTF8_GENERAL_CI LIKE '%$something%'
    ) 
AND op.destinazione  COLLATE UTF8_GENERAL_CI LIKE '%$somethingelse%' 
AND (o.data BETWEEN '$ed' AND '$ea')

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题