提高订单源的查询速度
This commit is contained in:
@@ -46,21 +46,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</select>
|
||||
|
||||
<!-- 除大批量单号外的所有过滤条件(大批量单号走分批收集 selectMatchedOrderKeys) -->
|
||||
<!-- Customer + pickup first so CBO can use those indexes on month-range queries. -->
|
||||
<sql id="tabOrderFilterWhere">
|
||||
o.BL_PICKUP = 1
|
||||
AND o.ORDER_STATUS IN (3, 4, 5, 6, 7, 8, 11)
|
||||
<if test="query.customerCodes != null and query.customerCodes.size() > 0">
|
||||
AND o.CUSTOMER_CODE IN
|
||||
o.CUSTOMER_CODE IN
|
||||
<foreach collection="query.customerCodes" item="code" open="(" separator="," close=")">
|
||||
#{code}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="query.customerCodes == null or query.customerCodes.size() == 0">
|
||||
1 = 1
|
||||
</if>
|
||||
<if test="query.beginTime != null and query.beginTime != ''">
|
||||
AND o.PICKUP_DATE >= TO_TIMESTAMP(#{query.beginTime}, 'YYYY-MM-DD HH24:MI:SS')
|
||||
</if>
|
||||
<if test="query.endTime != null and query.endTime != ''">
|
||||
AND o.PICKUP_DATE <= TO_TIMESTAMP(#{query.endTime}, 'YYYY-MM-DD HH24:MI:SS')
|
||||
</if>
|
||||
AND o.BL_PICKUP = 1
|
||||
AND o.ORDER_STATUS IN (3, 4, 5, 6, 7, 8, 11)
|
||||
<if test="query.orderId != null and query.orderId != ''">
|
||||
AND o.ORDER_ID = #{query.orderId}
|
||||
</if>
|
||||
@@ -128,11 +132,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<include refid="tabOrderMonitorWhere"/>
|
||||
</select>
|
||||
|
||||
<select id="selectTabOrderMonitorPage" resultType="java.util.HashMap">
|
||||
SELECT * FROM (
|
||||
SELECT inner_q.*, ROWNUM AS rn FROM (
|
||||
<!-- 同步计费需要全行数据(toBillRequest 读取数十列),故取 o.* 而非展示列 -->
|
||||
SELECT o.*
|
||||
<!--
|
||||
Month-range list: sort only narrow keys, then Java loads display/full rows by ID.
|
||||
Avoids ORDER BY on o.* which gets very slow when pickup window is ~1 month.
|
||||
-->
|
||||
<select id="selectTabOrderMonitorKeyPage" resultType="java.util.HashMap">
|
||||
SELECT ID FROM (
|
||||
SELECT inner_q.ID AS ID, ROWNUM AS rn FROM (
|
||||
SELECT /*+ FIRST_ROWS(${endRow}) */ o.ID, o.PICKUP_DATE, o.ORDER_ID
|
||||
FROM ${orderTable} o
|
||||
WHERE
|
||||
<include refid="tabOrderMonitorWhere"/>
|
||||
@@ -143,6 +150,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
WHERE rn > #{startRow}
|
||||
</select>
|
||||
|
||||
<!-- List detail by primary keys (display columns only). -->
|
||||
<select id="selectTabOrderMonitorListByIds" resultType="java.util.HashMap">
|
||||
SELECT
|
||||
<include refid="tabOrderMonitorColumns"/>
|
||||
FROM ${orderTable} o
|
||||
WHERE o.ID IN
|
||||
<foreach collection="ids" item="mid" open="(" separator="," close=")">
|
||||
#{mid}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<!-- Distinct product codes under the same filters (no pagination). -->
|
||||
<select id="selectTabOrderProductCodes" resultType="java.util.HashMap">
|
||||
SELECT o.CUSTOMER_CODE AS CUSTOMER_CODE,
|
||||
|
||||
Reference in New Issue
Block a user