【已解决】多字段 like 查询性能分析

Viewed 38

分别查询 a b c 三个字段,查询时间都是 0.3 s,如果同时查的差,应该是大约 1s,为什么实际上同时查询花了 6s,大了 6 倍?

查询 a 响应时间 0.3 s

select *
from full_text_tale
where a like '%apple%'

查询 b 响应时间 0.3 s

select *
from full_text_tale
where b like '%apple%'

查询 c 响应时间 0.3 s

select *
from full_text_tale
where c like '%apple%'

同时查询 a b c 响应时间 6 s

select *
from full_text_tale
where  a like '%apple%'
   and b like '%apple%'
   and c like '%apple%'
1 Answers

咱们是1.2的版本,可能性能上有些问题,like 这块在后续的版本中是有过针对性的性能优化的,比如下推和利用词典等的一些优化,您可以尝试升级到2.0/2.1最新的版本上进行测试。

目前针对这种场景,其实可以在2.0+ 版本上使用到拍索引,这三个字段创建倒排索引的方式加速查询,效率会比like 高很多。

倒排索引