liurunyu
2025-07-29 9c4100d5a1ada3f8539d80199b3d8da534f9a982
优化SQL语句,以提高查询速度
1个文件已修改
20 ■■■■ 已修改文件
pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmOpenCloseValveHistoryMapper.xml 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmOpenCloseValveHistoryMapper.xml
@@ -789,17 +789,17 @@
        SELECT COUNT(*)
        FROM se_client cli
        inner join (
        SELECT client_id, COUNT(*) AS openCount
        FROM rm_open_close_valve_history
        <where>
            <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != ''">
                op_dt BETWEEN #{timeStart} AND #{timeStop}
            SELECT client_id, COUNT(*) AS openCount
            FROM rm_open_close_valve_history
            <where>
                <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != ''">
                    op_dt BETWEEN #{timeStart} AND #{timeStop}
                </if>
            </where>
            group by client_id
            <if test="openCount != null and openCount > 0">
                having openCount &lt; #{openCount}
            </if>
        </where>
        group by client_id
        <if test="openCount != null and openCount > 0">
            having openCount &lt; #{openCount}
        </if>
        ) as his on his.client_id = cli.id
    </select>
    <!-- 2025-07-29 下面SQL查询太慢,废弃  -->