Просмотр исходного кода

一个慢查询的SQL优化调整

王苗苗 1 неделя назад
Родитель
Сommit
c99be97ebb

+ 3 - 3
ruoyi-system/src/main/resources/mapper/business/ZAssayResultMapper.xml

@@ -239,19 +239,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             de.device_no deviceNo,
             r.assay_no AS assayNo,
             r.result_concentration AS resultConcentration,
-            ds.name itemName,
+            <!-- ds.name itemName, -->
             t.name AS assayName,
             r.assay_item assayItem
         FROM
             z_assay_result AS r
                 INNER JOIN t_assay_item AS t ON t.code = r.assay_item
-                INNER JOIN t_position AS ds ON  r.sample_post = ds.code and  r.device_no = ds.remark
+                <!-- INNER JOIN t_position AS ds ON  r.sample_post = ds.code and  r.device_no = ds.remark -->
                 LEFT OUTER JOIN biz_device de ON r.device_no = de.device_no
         WHERE <!-- todo 这里待确认是否只要连续监测的 并且是有点位的数据 -->
             r.sample_post IS NOT NULL
           AND de.type = 2
           AND r.result_date BETWEEN #{timeBegin} AND #{timeEnd}
-        <if test="deviceNo != null  and deviceNo != ''"> AND de.device_no = #{deviceNo}</if>
+        <if test="deviceNo != null  and deviceNo != ''"> AND r.device_no = #{deviceNo}</if>
     </select>