首页 > 解决方案 > Mysql数据库性能限制

问题描述

select 
    t.m_id as mId, t.box as box 
from 
    tb_features t 
where  
    t.m_id != #{mId} 
    and t.index_flag = 'Y' 
    and t.vector_index = 1  
    and (select sum(t1.vector * t2.vector) 
         from tb_features t1 
         left join tb_features t2 on t1.vector_index = t2.vector_index 
         where t1.m_id = #{mId} 
           and t1.vector_index != 1 
           and t2.m_id = t.m_id) > 
            (t.vector * (select t3.vector 
                         from tb_features t3 
                         where t3.m_id = #{mId} and t3.vector_index = 1) * 0.9)

向量vector_index是向量的索引,仅当索引相等时才相乘

几乎所有这些都需要全表扫描,而 MySQL 的性能并没有达到应有的水平。有什么方法可以优化它或以不同的方式存储它

标签: mysqldatabase

解决方案


推荐阅读