mysql - 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 的性能并没有达到应有的水平。有什么方法可以优化它或以不同的方式存储它
解决方案
推荐阅读
- r - 将具有不同列名的多个csv组合成唯一的列名
- validation - 在 NestJS 中覆盖 ValidationPipe 错误消息不起作用
- flutter - 改变滚动控制器颤动的速度
- excel - 如何使用 VBA Selenium 单击隐藏的 Web 元素?
- c++ - 调用结果的复制初始化序列是否被认为是 GCC 和 Clang 的错误?
- c# - 如果找到特定的子字符串,我想在字符串中添加一些 html 标记
- java - 通过 JPA 存储库以双向链表的形式从数据库中检索项目
- java - 构造函数 JDABuilder(AccountType) 已弃用
- reactjs - 如何在反应 js 中使用正则表达式,以便我可以在 firestore 集合名称中使用它
- c# - 网格大小不绑定到父容器的大小