订单数据源数据速度优化
This commit is contained in:
@@ -728,10 +728,26 @@ public class TabOrderMonitorService
|
|||||||
return s == null ? "" : s;
|
return s == null ? "" : s;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 已排序主键的内存分页切片,并按切片顺序回查明细(VO)。 */
|
/** 已排序主键的内存分页切片,并按切片顺序回查明细(VO)。
|
||||||
|
* 列表页只需展示列:走窄列 ListByIds,避免公网传输 o.* 全行宽表(同步专用)拖慢列表。 */
|
||||||
private List<TabOrderMonitorVo> doPageByKeys(String table, List<MatchedOrderKey> orderedKeys, int pn, int ps)
|
private List<TabOrderMonitorVo> doPageByKeys(String table, List<MatchedOrderKey> orderedKeys, int pn, int ps)
|
||||||
{
|
{
|
||||||
return toVoList(doRowsByKeys(table, orderedKeys, pn, ps));
|
if (orderedKeys == null || orderedKeys.isEmpty())
|
||||||
|
{
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
int from = (pn - 1) * ps;
|
||||||
|
if (from >= orderedKeys.size())
|
||||||
|
{
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
List<MatchedOrderKey> slice = orderedKeys.subList(from, Math.min(from + ps, orderedKeys.size()));
|
||||||
|
List<String> ids = new ArrayList<String>(slice.size());
|
||||||
|
for (MatchedOrderKey key : slice)
|
||||||
|
{
|
||||||
|
ids.add(key.getId());
|
||||||
|
}
|
||||||
|
return loadListVosByIds(table, ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 已排序主键的内存分页切片,按切片顺序回查全行(VO + Oracle 原始行)。 */
|
/** 已排序主键的内存分页切片,按切片顺序回查全行(VO + Oracle 原始行)。 */
|
||||||
|
|||||||
@@ -58,10 +58,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
1 = 1
|
1 = 1
|
||||||
</if>
|
</if>
|
||||||
<if test="query.beginTime != null and query.beginTime != ''">
|
<if test="query.beginTime != null and query.beginTime != ''">
|
||||||
AND o.PICKUP_DATE >= TO_TIMESTAMP(#{query.beginTime}, 'YYYY-MM-DD HH24:MI:SS')
|
<!-- PICKUP_DATE 是 DATE 列:必须用 TO_DATE 比较;TO_TIMESTAMP 会触发
|
||||||
|
INTERNAL_FUNCTION(列) 使 (CUSTOMER_CODE, PICKUP_DATE) 复合索引失效,
|
||||||
|
客户+提货时间查询从 1s 恶化到 200s+ -->
|
||||||
|
AND o.PICKUP_DATE >= TO_DATE(#{query.beginTime}, 'YYYY-MM-DD HH24:MI:SS')
|
||||||
</if>
|
</if>
|
||||||
<if test="query.endTime != null and query.endTime != ''">
|
<if test="query.endTime != null and query.endTime != ''">
|
||||||
AND o.PICKUP_DATE <= TO_TIMESTAMP(#{query.endTime}, 'YYYY-MM-DD HH24:MI:SS')
|
AND o.PICKUP_DATE <= TO_DATE(#{query.endTime}, 'YYYY-MM-DD HH24:MI:SS')
|
||||||
</if>
|
</if>
|
||||||
AND o.BL_PICKUP = 1
|
AND o.BL_PICKUP = 1
|
||||||
AND o.ORDER_STATUS IN (3, 4, 5, 6, 7, 8, 11)
|
AND o.ORDER_STATUS IN (3, 4, 5, 6, 7, 8, 11)
|
||||||
@@ -135,11 +138,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<!--
|
<!--
|
||||||
Month-range list: sort only narrow keys, then Java loads display/full rows by ID.
|
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.
|
Avoids ORDER BY on o.* which gets very slow when pickup window is ~1 month.
|
||||||
|
TO_DATE 比较(勿改回 TO_TIMESTAMP):索引可 sargable 走 (CUSTOMER_CODE, PICKUP_DATE) 复合索引。
|
||||||
-->
|
-->
|
||||||
<select id="selectTabOrderMonitorKeyPage" resultType="java.util.HashMap">
|
<select id="selectTabOrderMonitorKeyPage" resultType="java.util.HashMap">
|
||||||
SELECT ID FROM (
|
SELECT ID FROM (
|
||||||
SELECT inner_q.ID AS ID, ROWNUM AS rn FROM (
|
SELECT inner_q.ID AS ID, ROWNUM AS rn FROM (
|
||||||
SELECT /*+ FIRST_ROWS(${endRow}) */ o.ID, o.PICKUP_DATE, o.ORDER_ID
|
SELECT o.ID, o.PICKUP_DATE, o.ORDER_ID
|
||||||
FROM ${orderTable} o
|
FROM ${orderTable} o
|
||||||
WHERE
|
WHERE
|
||||||
<include refid="tabOrderMonitorWhere"/>
|
<include refid="tabOrderMonitorWhere"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user