postgre数据表数据比较多的情况下,使用模糊查询性能很差,但是使用函数反而快了,返回数据一致,有点不解
warning表2688133条数据,warning_message表6954788条数据
这个SQL执行老半天都没反映,耗时169904 ms
select count(1) from warning w
inner join warning_message wm on w.id = wm.warn_id and wm.user_id=2
and (w.title like '%严查%' or w.content like '%严查%' ) ;
这个SQL很快数据就出来了,耗时2931 ms
select count(1) from warning w
inner join warning_message wm on w.id = wm.warn_id and wm.user_id=2
and ( position('严查' in w.title) > 0 or position('严查' in w.content) > 0 );