select count(*) from tb_reagent_trace_info t1 INNER join tb_reagent_inventory_info t2 INNER join sys_user t3 where t1.reagent_inventory_id = t2.reagent_inventory_id and t1.create_opr = t3.user_id and t3.user_id = 113 and t1.reagent_operation_type = 00 帮我优化这条sql
时间: 2023-04-03 14:04:41 浏览: 187
00-Mysql优化.ppt
我可以回答这个问题。您可以尝试使用以下 SQL 语句进行优化:
SELECT COUNT(*)
FROM tb_reagent_trace_info t1
INNER JOIN tb_reagent_inventory_info t2 ON t1.reagent_inventory_id = t2.reagent_inventory_id
INNER JOIN sys_user t3 ON t1.create_opr = t3.user_id
WHERE t3.user_id = 113 AND t1.reagent_operation_type = '00'
这个 SQL 语句将 INNER JOIN 子句放在了 ON 子句之后,这样可以提高查询效率。同时,将 t1.reagent_operation_type 的值改为字符串类型 '00',也可以提高查询效率。
阅读全文