重现步骤
反馈人:王凯
数据库:zhcxkj-center-warehouse
查询时间:37.846
执行次数: 28
扫描行数:1465570
发送行数:1348.89
指纹SQL: select id , customer_id , card_no , box_no , sku , order_code , list_no , list_time , list_num , bad_num , task_state , channel , sorting_user_id , sorting_user_name , sorting_date , receive_user_id , receive_user_name , shelf_num , shelf_time , shelf_user_id , shelf_user_name , receive_time , recommend_position_id , shelf_position_id , shelf_type , refer_no , package_id , move_out_box_no , first_shelf_time , is_need_add_stockpile_data , pause_tag , return_good_task_no , order_list_id , ware_house_id , abnormal_number , operate_status , tally_admin_id , tally_user_name , tally_time , two_tally_admin_id , two_tally_user_name , two_tally_time , now ( ) StarRocksUpdateTime FROM ? where ( customer_id = ? AND ( sorting_date >= DATE_SUB ( NOW ( ) , interval ? HOUR ) OR shelf_time >= DATE_SUB ( NOW ( ) , interval ? HOUR ) ) ) ;
真实SQL:select id,customer_id,card_no,box_no,sku,order_code,list_no,list_time,list_num,bad_num,task_state,channel,sorting_user_id,sorting_user_name,sorting_date,receive_user_id,receive_user_name,shelf_num,shelf_time,shelf_user_id,shelf_user_name,receive_time,recommend_position_id,shelf_position_id,shelf_type,refer_no,package_id,move_out_box_no,first_shelf_time,is_need_add_stockpile_data,pause_tag,return_good_task_no,order_list_id,ware_house_id,abnormal_number,operate_status,tally_admin_id,tally_user_name,tally_time,two_tally_admin_id,two_tally_user_name,two_tally_time,now() StarRocksUpdateTime from t_stk_moving_putin_task where (customer_id = 1 AND (sorting_date >= DATE_SUB(NOW(), interval 2 HOUR) OR shelf_time >= DATE_SUB(NOW(), interval 2 HOUR)));
无人工修改
AISQL修改建议:SELECT id,customer_id,card_no,box_no,sku,order_code,list_no,list_time,list_num,bad_num,task_state,channel,sorting_user_id,sorting_user_name,sorting_date,receive_user_id,receive_user_name,shelf_num,shelf_time,shelf_user_id,shelf_user_name,receive_time,recommend_position_id,shelf_position_id,shelf_type,refer_no,package_id,move_out_box_no,first_shelf_time,is_need_add_stockpile_data,pause_tag,return_good_task_no,order_list_id,ware_house_id,abnormal_number,operate_status,tally_admin_id,tally_user_name,tally_time,two_tally_admin_id,two_tally_user_name,two_tally_time,now() StarRocksUpdateTime
FROM t_stk_moving_putin_task
WHERE customer_id = 1
AND (sorting_date >= DATE_SUB(NOW(), INTERVAL 2 HOUR) OR shelf_time >= DATE_SUB(NOW(), INTERVAL 2 HOUR))
ORDER BY GREATEST(IFNULL(sorting_date,0), IFNULL(shelf_time,0)) DESC
LIMIT 1000;

建议添加:
1. 复合索引 (customer_id, sorting_date, shelf_time)
2. 时间字段降序排序并限制结果集大小
3. 使用GREATEST函数避免多次计算DATE_SUB
explain表:






id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t_stk_moving_putin_task None ref idx_uniq_boxNo,idx_customer_id_task_state,idx_shelf_time_task_state,idx_customer_id_sorting_date,idx_customerid_box_no_sorting_date,idx_customerid_shelftime idx_uniq_boxNo 9 const 700401 55.55 Using where

额外建议:
索引建议:
取出表 【t_stk_moving_putin_task】 where条件字段 【customer_id】 100000 条记录,重复的数据有:【100000】 条,没有必要为该字段创建索引。

建议添加索引:ALTER TABLE t_stk_moving_putin_task ADD INDEX idx_sorting_date_shelf_time(sorting_date,shelf_time);


【t_stk_moving_putin_task】表 【sorting_date,shelf_time】字段,索引分析:
+-------------------------+--------------------------------+---------------+---------------+
| TABLE_NAME | INDEX_NAME | COLUMN_NAME | CARDINALITY |
+=========================+================================+===============+===============+
| t_stk_moving_putin_task | idx_customer_id_sorting_date | sorting_date | 1326066 |
+-------------------------+--------------------------------+---------------+---------------+
| t_stk_moving_putin_task | idx_customerid_box_no_sorting_ | sorting_date | 1400802 |
| | date | | |
+-------------------------+--------------------------------+---------------+---------------+
| t_stk_moving_putin_task | idx_customerid_shelftime | shelf_time | 1347981 |
+-------------------------+--------------------------------+---------------+---------------+
| t_stk_moving_putin_task | idx_shelf_time_task_state | shelf_time | 1380454 |
+-------------------------+--------------------------------+---------------+---------------+


历史记录  
  1. 2025-09-01 15:28:07, 由 李乐同 创建。
  2. 2025-09-01 16:05:12, 由 余效檀 确认Bug。
    修改了 Bug类型 ,旧值为 "",新值为 "feibug"。
    修改了 是否确认,旧值为 "0",新值为 "1"。
  3. 2025-09-01 16:05:23, 由 余效檀 解决,方案为 非BUG-纯属误判 。
    修改了 解决方案,旧值为 "",新值为 "feibug"。
    修改了 解决日期,旧值为 "",新值为 "2025-09-01 16:05:14"。
    修改了 指派给 ,旧值为 "yuxiaotan",新值为 "liletong"。
    修改了 Bug状态 ,旧值为 "active",新值为 "resolved"。
    修改了 解决者 ,旧值为 "",新值为 "yuxiaotan"。
  4. 2025-09-01 16:44:27, 由 袁慧斌 激活。
    修改了 指派给 ,旧值为 "liletong",新值为 "yuxiaotan"。
    修改了 Bug状态 ,旧值为 "resolved",新值为 "active"。
    修改了 激活日期,旧值为 "",新值为 "2025-09-01 16:44:27"。
    修改了 激活次数,旧值为 "0",新值为 "1"。
    修改了 解决方案,旧值为 "feibug",新值为 ""。
    修改了 解决日期,旧值为 "2025-09-01 16:05:14",新值为 "0000-00-00"。
    修改了 解决者 ,旧值为 "yuxiaotan",新值为 ""。
    修改了 关闭日期,旧值为 "",新值为 "0000-00-00"。
    把or 改成 union 

    select id,customer_id,card_no,box_no,sku,order_code,list_no,list_time,list_num,bad_num,task_state,channel,sorting_user_id,sorting_user_name,sorting_date,receive_user_id,receive_user_name,shelf_num,shelf_time,shelf_user_id,shelf_user_name,receive_time,recommend_position_id,shelf_position_id,shelf_type,refer_no,package_id,move_out_box_no,first_shelf_time,is_need_add_stockpile_data,pause_tag,return_good_task_no,order_list_id,ware_house_id,abnormal_number,operate_status,tally_admin_id,tally_user_name,tally_time,two_tally_admin_id,two_tally_user_name,two_tally_time,now() StarRocksUpdateTime from t_stk_moving_putin_task where (customer_id = 1 AND (sorting_date >= DATE_SUB(NOW(), interval 2 HOUR) ));
    union
    select id,customer_id,card_no,box_no,sku,order_code,list_no,list_time,list_num,bad_num,task_state,channel,sorting_user_id,sorting_user_name,sorting_date,receive_user_id,receive_user_name,shelf_num,shelf_time,shelf_user_id,shelf_user_name,receive_time,recommend_position_id,shelf_position_id,shelf_type,refer_no,package_id,move_out_box_no,first_shelf_time,is_need_add_stockpile_data,pause_tag,return_good_task_no,order_list_id,ware_house_id,abnormal_number,operate_status,tally_admin_id,tally_user_name,tally_time,two_tally_admin_id,two_tally_user_name,two_tally_time,now() StarRocksUpdateTime from t_stk_moving_putin_task where (customer_id = 1 AND (shelf_time >= DATE_SUB(NOW(), interval 2 HOUR)));
  5. 2025-09-01 19:30:57, 由 余效檀 解决,方案为 程序BUG 。
    修改了 解决方案,旧值为 "",新值为 "code"。
    修改了 解决版本,旧值为 "",新值为 "trunk"。
    修改了 解决日期,旧值为 "",新值为 "2025-09-01 19:30:27"。
    修改了 指派给 ,旧值为 "yuxiaotan",新值为 "liletong"。
    修改了 Bug状态 ,旧值为 "active",新值为 "resolved"。
    修改了 解决者 ,旧值为 "",新值为 "yuxiaotan"。
    分离成了2个DATAX数据
  6. 2025-09-01 20:09:29, 由 李乐同 编辑。
    修改了 所属模块 ,旧值为 "0",新值为 "1934"。
    修改了 业务部门 ,旧值为 "0",新值为 "2"。
    修改了 开发责任人,旧值为 "",新值为 "yuxiaotan"。
    修改了 测试责任人,旧值为 "",新值为 "yuxiaotan"。
    修改了 解决时效 ,旧值为 "0",新值为 "4.04"。
    修改了 重现步骤 ,区别为:
    001- 反馈人:王凯
    001+ 反馈人:王凯 数据库:zhcxkj-center-warehouse 查询时间:37.846 执行次数: 28 扫描行数:1465570 发送行数:1348.89 指纹SQL: select id , customer_id , card_no , box_no , sku , order_code , list_no , list_time , list_num , bad_num , task_state , channel , sorting_user_id , sorting_user_name , sorting_date , receive_user_id , receive_user_name , shelf_num , shelf_time , shelf_user_id , shelf_user_name , receive_time , recommend_position_id , shelf_position_id , shelf_type , refer_no , package_id , move_out_box_no , first_shelf_time , is_need_add_stockpile_data , pause_tag , return_good_task_no , order_list_id , ware_house_id , abnormal_number , operate_status , tally_admin_id , tally_user_name , tally_time , two_tally_admin_id , two_tally_user_name , two_tally_time , now ( ) StarRocksUpdateTime FROM ? where ( customer_id = ? AND ( sorting_date >= DATE_SUB ( NOW ( ) , interval ? HOUR ) OR shelf_time >= DATE_SUB ( NOW ( ) , interval ? HOUR ) ) ) ; 真实SQL:select id,customer_id,card_no,box_no,sku,order_code,list_no,list_time,list_num,bad_num,task_state,channel,sorting_user_id,sorting_user_name,sorting_date,receive_user_id,receive_user_name,shelf_num,shelf_time,shelf_user_id,shelf_user_name,receive_time,recommend_position_id,shelf_position_id,shelf_type,refer_no,package_id,move_out_box_no,first_shelf_time,is_need_add_stockpile_data,pause_tag,return_good_task_no,order_list_id,ware_house_id,abnormal_number,operate_status,tally_admin_id,tally_user_name,tally_time,two_tally_admin_id,two_tally_user_name,two_tally_time,now() StarRocksUpdateTime from t_stk_moving_putin_task where (customer_id = 1 AND (sorting_date >= DATE_SUB(NOW(), interval 2 HOUR) OR shelf_time >= DATE_SUB(NOW(), interval 2 HOUR))); 无人工修改 AISQL修改建议:SELECT id,customer_id,card_no,box_no,sku,order_code,list_no,list_time,list_num,bad_num,task_state,channel,sorting_user_id,sorting_user_name,sorting_date,receive_user_id,receive_user_name,shelf_num,shelf_time,shelf_user_id,shelf_user_name,receive_time,recommend_position_id,shelf_position_id,shelf_type,refer_no,package_id,move_out_box_no,first_shelf_time,is_need_add_stockpile_data,pause_tag,return_good_task_no,order_list_id,ware_house_id,abnormal_number,operate_status,tally_admin_id,tally_user_name,tally_time,two_tally_admin_id,two_tally_user_name,two_tally_time,now() StarRocksUpdateTime FROM t_stk_moving_putin_task WHERE customer_id = 1 AND (sorting_date >= DATE_SUB(NOW(), INTERVAL 2 HOUR) OR shelf_time >= DATE_SUB(NOW(), INTERVAL 2 HOUR)) ORDER BY GREATEST(IFNULL(sorting_date,0), IFNULL(shelf_time,0)) DESC LIMIT 1000; 建议添加: 1. 复合索引 (customer_id, sorting_date, shelf_time) 2. 时间字段降序排序并限制结果集大小 3. 使用GREATEST函数避免多次计算DATE_SUB explain表:id
    002- 数据库:zhcxkj-center-warehouse
    002+ select_type
    003- 查询时间:37.846
    003+ table
    004- 执行次数: 28
    004+ partitions
    005- 扫描行数:1465570
    005+ type
    006- 发送行数:1348.89
    006+ possible_keys
    007- 指纹SQL: select id , customer_id , card_no , box_no , sku , order_code , list_no , list_time , list_num , bad_num , task_state , channel , sorting_user_id , sorting_user_name , sorting_date , receive_user_id , receive_user_name , shelf_num , shelf_time , shelf_user_id , shelf_user_name , receive_time , recommend_position_id , shelf_position_id , shelf_type , refer_no , package_id , move_out_box_no , first_shelf_time , is_need_add_stockpile_data , pause_tag , return_good_task_no , order_list_id , ware_house_id , abnormal_number , operate_status , tally_admin_id , tally_user_name , tally_time , two_tally_admin_id , two_tally_user_name , two_tally_time , now ( ) StarRocksUpdateTime FROM ? where ( customer_id = ? AND ( sorting_date >= DATE_SUB ( NOW ( ) , interval ? HOUR ) OR shelf_time >= DATE_SUB ( NOW ( ) , interval ? HOUR ) ) ) ;
    007+ key
    008- 真实SQL:select id,customer_id,card_no,box_no,sku,order_code,list_no,list_time,list_num,bad_num,task_state,channel,sorting_user_id,sorting_user_name,sorting_date,receive_user_id,receive_user_name,shelf_num,shelf_time,shelf_user_id,shelf_user_name,receive_time,recommend_position_id,shelf_position_id,shelf_type,refer_no,package_id,move_out_box_no,first_shelf_time,is_need_add_stockpile_data,pause_tag,return_good_task_no,order_list_id,ware_house_id,abnormal_number,operate_status,tally_admin_id,tally_user_name,tally_time,two_tally_admin_id,two_tally_user_name,two_tally_time,now() StarRocksUpdateTime from t_stk_moving_putin_task where (customer_id = 1 AND (sorting_date >= DATE_SUB(NOW(), interval 2 HOUR) OR shelf_time >= DATE_SUB(NOW(), interval 2 HOUR)));
    008+ key_len
    009- 无人工修改
    009+ ref
    010- AISQL修改建议:SELECT id,customer_id,card_no,box_no,sku,order_code,list_no,list_time,list_num,bad_num,task_state,channel,sorting_user_id,sorting_user_name,sorting_date,receive_user_id,receive_user_name,shelf_num,shelf_time,shelf_user_id,shelf_user_name,receive_time,recommend_position_id,shelf_position_id,shelf_type,refer_no,package_id,move_out_box_no,first_shelf_time,is_need_add_stockpile_data,pause_tag,return_good_task_no,order_list_id,ware_house_id,abnormal_number,operate_status,tally_admin_id,tally_user_name,tally_time,two_tally_admin_id,two_tally_user_name,two_tally_time,now() StarRocksUpdateTime
    010+ rows
    011- FROM t_stk_moving_putin_task
    011+ filtered
    012- WHERE customer_id = 1
    012+ Extra
    013- AND (sorting_date >= DATE_SUB(NOW(), INTERVAL 2 HOUR) OR shelf_time >= DATE_SUB(NOW(), INTERVAL 2 HOUR))
    013+ 1
    014- ORDER BY GREATEST(IFNULL(sorting_date,0), IFNULL(shelf_time,0)) DESC
    014+ SIMPLE
    015- LIMIT 1000;
    015+ t_stk_moving_putin_task
    016-
    016+ None
    017- 建议添加:
    017+ ref
    018- 1. 复合索引 (customer_id, sorting_date, shelf_time)
    018+ idx_uniq_boxNo,idx_customer_id_task_state,idx_shelf_time_task_state,idx_customer_id_sorting_date,idx_customerid_box_no_sorting_date,idx_customerid_shelftime
    019- 2. 时间字段降序排序并限制结果集大小
    019+ idx_uniq_boxNo
    020- 3. 使用GREATEST函数避免多次计算DATE_SUB
    020+ 9
    021- explain表:
    021+ const
    022-
    022+ 700401
    023-
    023+ 55.55
    024-
    024+ Using where
    025-
    025+
    026-
    026+ 额外建议: 索引建议: 取出表 【t_stk_moving_putin_task】 where条件字段 【customer_id】 100000 条记录,重复的数据有:【100000】 条,没有必要为该字段创建索引。 建议添加索引:ALTER TABLE t_stk_moving_putin_task ADD INDEX idx_sorting_date_shelf_time(sorting_date,shelf_time); 【t_stk_moving_putin_task】表 【sorting_date,shelf_time】字段,索引分析: +-------------------------+--------------------------------+---------------+---------------+ | TABLE_NAME | INDEX_NAME | COLUMN_NAME | CARDINALITY | +=========================+================================+===============+===============+ | t_stk_moving_putin_task | idx_customer_id_sorting_date | sorting_date | 1326066 | +-------------------------+--------------------------------+---------------+---------------+ | t_stk_moving_putin_task | idx_customerid_box_no_sorting_ | sorting_date | 1400802 | | | date | | | +-------------------------+--------------------------------+---------------+---------------+ | t_stk_moving_putin_task | idx_customerid_shelftime | shelf_time | 1347981 | +-------------------------+--------------------------------+---------------+---------------+ | t_stk_moving_putin_task | idx_shelf_time_task_state | shelf_time | 1380454 | +-------------------------+--------------------------------+---------------+---------------+
    027-
    028-
    029-
    030-
    031-
    032- id
    033-
    034-
    035- select_type
    036-
    037-
    038- table
    039-
    040-
    041- partitions
    042-
    043-
    044- type
    045-
    046-
    047- possible_keys
    048-
    049-
    050- key
    051-
    052-
    053- key_len
    054-
    055-
    056- ref
    057-
    058-
    059- rows
    060-
    061-
    062- filtered
    063-
    064-
    065- Extra
    066-
    067-
    068-
    069-
    070-
    071-
    072- 1
    073-
    074-
    075- SIMPLE
    076-
    077-
    078- t_stk_moving_putin_task
    079-
    080-
    081- None
    082-
    083-
    084- ref
    085-
    086-
    087- idx_uniq_boxNo,idx_customer_id_task_state,idx_shelf_time_task_state,idx_customer_id_sorting_date,idx_customerid_box_no_sorting_date,idx_customerid_shelftime
    088-
    089-
    090- idx_uniq_boxNo
    091-
    092-
    093- 9
    094-
    095-
    096- const
    097-
    098-
    099- 700401
    100-
    101-
    102- 55.55
    103-
    104-
    105- Using where
    106-
    107-
    108-
    109-
    110-
    111- 额外建议:
    112- 索引建议:
    113- 取出表 【t_stk_moving_putin_task】 where条件字段 【customer_id】 100000 条记录,重复的数据有:【100000】 条,没有必要为该字段创建索引。
    114-
    115- 建议添加索引:ALTER TABLE t_stk_moving_putin_task ADD INDEX idx_sorting_date_shelf_time(sorting_date,shelf_time);
    116-
    117- 【t_stk_moving_putin_task】表 【sorting_date,shelf_time】字段,索引分析:
    118- +-------------------------+--------------------------------+---------------+---------------+
    119- | TABLE_NAME | INDEX_NAME | COLUMN_NAME | CARDINALITY |
    120- +=========================+================================+===============+===============+
    121- | t_stk_moving_putin_task | idx_customer_id_sorting_date | sorting_date | 1326066 |
    122- +-------------------------+--------------------------------+---------------+---------------+
    123- | t_stk_moving_putin_task | idx_customerid_box_no_sorting_ | sorting_date | 1400802 |
    124- | | date | | |
    125- +-------------------------+--------------------------------+---------------+---------------+
    126- | t_stk_moving_putin_task | idx_customerid_shelftime | shelf_time | 1347981 |
    127- +-------------------------+--------------------------------+---------------+---------------+
    128- | t_stk_moving_putin_task | idx_shelf_time_task_state | shelf_time | 1380454 |
    129- +-------------------------+--------------------------------+---------------+---------------+
    130-
    131-
    001- 反馈人:王凯<br />
    001+ 反馈人:王凯<br /> 数据库:zhcxkj-center-warehouse<br /> 查询时间:37.846<br /> 执行次数: 28<br /> 扫描行数:1465570<br /> 发送行数:1348.89<br /> 指纹SQL: select id , customer_id , card_no , box_no , sku , order_code , list_no , list_time , list_num , bad_num , task_state , channel , sorting_user_id , sorting_user_name , sorting_date , receive_user_id , receive_user_name , shelf_num , shelf_time , shelf_user_id , shelf_user_name , receive_time , recommend_position_id , shelf_position_id , shelf_type , refer_no , package_id , move_out_box_no , first_shelf_time , is_need_add_stockpile_data , pause_tag , return_good_task_no , order_list_id , ware_house_id , abnormal_number , operate_status , tally_admin_id , tally_user_name , tally_time , two_tally_admin_id , two_tally_user_name , two_tally_time , now ( ) StarRocksUpdateTime FROM ? where ( customer_id = ? AND ( sorting_date &gt;= DATE_SUB ( NOW ( ) , interval ? HOUR ) OR shelf_time &gt;= DATE_SUB ( NOW ( ) , interval ? HOUR ) ) ) ;<br /> 真实SQL:select id,customer_id,card_no,box_no,sku,order_code,list_no,list_time,list_num,bad_num,task_state,channel,sorting_user_id,sorting_user_name,sorting_date,receive_user_id,receive_user_name,shelf_num,shelf_time,shelf_user_id,shelf_user_name,receive_time,recommend_position_id,shelf_position_id,shelf_type,refer_no,package_id,move_out_box_no,first_shelf_time,is_need_add_stockpile_data,pause_tag,return_good_task_no,order_list_id,ware_house_id,abnormal_number,operate_status,tally_admin_id,tally_user_name,tally_time,two_tally_admin_id,two_tally_user_name,two_tally_time,now() StarRocksUpdateTime from t_stk_moving_putin_task where (customer_id = 1 AND (sorting_date &gt;= DATE_SUB(NOW(), interval 2 HOUR) OR shelf_time &gt;= DATE_SUB(NOW(), interval 2 HOUR)));<br /> 无人工修改<br /> AISQL修改建议:SELECT id,customer_id,card_no,box_no,sku,order_code,list_no,list_time,list_num,bad_num,task_state,channel,sorting_user_id,sorting_user_name,sorting_date,receive_user_id,receive_user_name,shelf_num,shelf_time,shelf_user_id,shelf_user_name,receive_time,recommend_position_id,shelf_position_id,shelf_type,refer_no,package_id,move_out_box_no,first_shelf_time,is_need_add_stockpile_data,pause_tag,return_good_task_no,order_list_id,ware_house_id,abnormal_number,operate_status,tally_admin_id,tally_user_name,tally_time,two_tally_admin_id,two_tally_user_name,two_tally_time,now() StarRocksUpdateTime <br /> FROM t_stk_moving_putin_task <br /> WHERE customer_id = 1 <br /> AND (sorting_date &gt;= DATE_SUB(NOW(), INTERVAL 2 HOUR) OR shelf_time &gt;= DATE_SUB(NOW(), INTERVAL 2 HOUR))<br /> ORDER BY GREATEST(IFNULL(sorting_date,0), IFNULL(shelf_time,0)) DESC<br /> LIMIT 1000;<br /><br /> 建议添加:<br /> 1. 复合索引 (customer_id, sorting_date, shelf_time)<br /> 2. 时间字段降序排序并限制结果集大小<br /> 3. 使用GREATEST函数避免多次计算DATE_SUB<br /> explain表:<br /><br /><br /><br /><br /><br /><br /><table><tbody><tr><th>id</th>
    002- 数据库:zhcxkj-center-warehouse<br />
    002+ <th>select_type</th>
    003- 查询时间:37.846<br />
    003+ <th>table</th>
    004- 执行次数: 28<br />
    004+ <th>partitions</th>
    005- 扫描行数:1465570<br />
    005+ <th>type</th>
    006- 发送行数:1348.89<br />
    006+ <th>possible_keys</th>
    007- 指纹SQL: select id , customer_id , card_no , box_no , sku , order_code , list_no , list_time , list_num , bad_num , task_state , channel , sorting_user_id , sorting_user_name , sorting_date , receive_user_id , receive_user_name , shelf_num , shelf_time , shelf_user_id , shelf_user_name , receive_time , recommend_position_id , shelf_position_id , shelf_type , refer_no , package_id , move_out_box_no , first_shelf_time , is_need_add_stockpile_data , pause_tag , return_good_task_no , order_list_id , ware_house_id , abnormal_number , operate_status , tally_admin_id , tally_user_name , tally_time , two_tally_admin_id , two_tally_user_name , two_tally_time , now ( ) StarRocksUpdateTime FROM ? where ( customer_id = ? AND ( sorting_date &gt;= DATE_SUB ( NOW ( ) , interval ? HOUR ) OR shelf_time &gt;= DATE_SUB ( NOW ( ) , interval ? HOUR ) ) ) ;<br />
    007+ <th>key</th>
    008- 真实SQL:select id,customer_id,card_no,box_no,sku,order_code,list_no,list_time,list_num,bad_num,task_state,channel,sorting_user_id,sorting_user_name,sorting_date,receive_user_id,receive_user_name,shelf_num,shelf_time,shelf_user_id,shelf_user_name,receive_time,recommend_position_id,shelf_position_id,shelf_type,refer_no,package_id,move_out_box_no,first_shelf_time,is_need_add_stockpile_data,pause_tag,return_good_task_no,order_list_id,ware_house_id,abnormal_number,operate_status,tally_admin_id,tally_user_name,tally_time,two_tally_admin_id,two_tally_user_name,two_tally_time,now() StarRocksUpdateTime from t_stk_moving_putin_task where (customer_id = 1 AND (sorting_date &gt;= DATE_SUB(NOW(), interval 2 HOUR) OR shelf_time &gt;= DATE_SUB(NOW(), interval 2 HOUR)));<br />
    008+ <th>key_len</th>
    009- 无人工修改<br />
    009+ <th>ref</th>
    010- AISQL修改建议:SELECT id,customer_id,card_no,box_no,sku,order_code,list_no,list_time,list_num,bad_num,task_state,channel,sorting_user_id,sorting_user_name,sorting_date,receive_user_id,receive_user_name,shelf_num,shelf_time,shelf_user_id,shelf_user_name,receive_time,recommend_position_id,shelf_position_id,shelf_type,refer_no,package_id,move_out_box_no,first_shelf_time,is_need_add_stockpile_data,pause_tag,return_good_task_no,order_list_id,ware_house_id,abnormal_number,operate_status,tally_admin_id,tally_user_name,tally_time,two_tally_admin_id,two_tally_user_name,two_tally_time,now() StarRocksUpdateTime <br />
    010+ <th>rows</th>
    011- FROM t_stk_moving_putin_task <br />
    011+ <th>filtered</th>
    012- WHERE customer_id = 1 <br />
    012+ <th>Extra</th>
    013- AND (sorting_date &gt;= DATE_SUB(NOW(), INTERVAL 2 HOUR) OR shelf_time &gt;= DATE_SUB(NOW(), INTERVAL 2 HOUR))<br />
    013+ </tr></tbody><tbody><tr><td>1</td>
    014- ORDER BY GREATEST(IFNULL(sorting_date,0), IFNULL(shelf_time,0)) DESC<br />
    014+ <td>SIMPLE</td>
    015- LIMIT 1000;<br />
    015+ <td>t_stk_moving_putin_task</td>
    016- <br />
    016+ <td>None</td>
    017- 建议添加:<br />
    017+ <td>ref</td>
    018- 1. 复合索引 (customer_id, sorting_date, shelf_time)<br />
    018+ <td>idx_uniq_boxNo,idx_customer_id_task_state,idx_shelf_time_task_state,idx_customer_id_sorting_date,idx_customerid_box_no_sorting_date,idx_customerid_shelftime</td>
    019- 2. 时间字段降序排序并限制结果集大小<br />
    019+ <td>idx_uniq_boxNo</td>
    020- 3. 使用GREATEST函数避免多次计算DATE_SUB<br />
    020+ <td>9</td>
    021- explain表:<br />
    021+ <td>const</td>
    022- <br />
    022+ <td>700401</td>
    023- <br />
    023+ <td>55.55</td>
    024- <br />
    024+ <td>Using where</td>
    025- <br />
    025+ </tr></tbody></table><br />
    026- <br />
    026+ 额外建议:<br /> 索引建议:<br /> 取出表 【t_stk_moving_putin_task】 where条件字段 【customer_id】 100000 条记录,重复的数据有:【100000】 条,没有必要为该字段创建索引。<br /><span style="color:#FFA500;"><br /> 建议添加索引:ALTER TABLE t_stk_moving_putin_task ADD INDEX idx_sorting_date_shelf_time(sorting_date,shelf_time);</span><br /><br /> 【t_stk_moving_putin_task】表 【sorting_date,shelf_time】字段,索引分析:<br /> +-------------------------+--------------------------------+---------------+---------------+<br /> | TABLE_NAME | INDEX_NAME | COLUMN_NAME | CARDINALITY |<br /> +=========================+================================+===============+===============+<br /> | t_stk_moving_putin_task | idx_customer_id_sorting_date | sorting_date | 1326066 |<br /> +-------------------------+--------------------------------+---------------+---------------+<br /> | t_stk_moving_putin_task | idx_customerid_box_no_sorting_ | sorting_date | 1400802 |<br /> | | date | | |<br /> +-------------------------+--------------------------------+---------------+---------------+<br /> | t_stk_moving_putin_task | idx_customerid_shelftime | shelf_time | 1347981 |<br /> +-------------------------+--------------------------------+---------------+---------------+<br /> | t_stk_moving_putin_task | idx_shelf_time_task_state | shelf_time | 1380454 |<br /> +-------------------------+--------------------------------+---------------+---------------+<br /><br /><br />
    027- <br />
    028- <table>
    029- <tbody>
    030- <tr>
    031- <th>
    032- id
    033- </th>
    034- <th>
    035- select_type
    036- </th>
    037- <th>
    038- table
    039- </th>
    040- <th>
    041- partitions
    042- </th>
    043- <th>
    044- type
    045- </th>
    046- <th>
    047- possible_keys
    048- </th>
    049- <th>
    050- key
    051- </th>
    052- <th>
    053- key_len
    054- </th>
    055- <th>
    056- ref
    057- </th>
    058- <th>
    059- rows
    060- </th>
    061- <th>
    062- filtered
    063- </th>
    064- <th>
    065- Extra
    066- </th>
    067- </tr>
    068- </tbody>
    069- <tbody>
    070- <tr>
    071- <td>
    072- 1
    073- </td>
    074- <td>
    075- SIMPLE
    076- </td>
    077- <td>
    078- t_stk_moving_putin_task
    079- </td>
    080- <td>
    081- None
    082- </td>
    083- <td>
    084- ref
    085- </td>
    086- <td>
    087- idx_uniq_boxNo,idx_customer_id_task_state,idx_shelf_time_task_state,idx_customer_id_sorting_date,idx_customerid_box_no_sorting_date,idx_customerid_shelftime
    088- </td>
    089- <td>
    090- idx_uniq_boxNo
    091- </td>
    092- <td>
    093- 9
    094- </td>
    095- <td>
    096- const
    097- </td>
    098- <td>
    099- 700401
    100- </td>
    101- <td>
    102- 55.55
    103- </td>
    104- <td>
    105- Using where
    106- </td>
    107- </tr>
    108- </tbody>
    109- </table>
    110- <br />
    111- 额外建议:<br />
    112- 索引建议:<br />
    113- 取出表 【t_stk_moving_putin_task】 where条件字段 【customer_id】 100000 条记录,重复的数据有:【100000】 条,没有必要为该字段创建索引。<br />
    114- <span style="color:FFA500;"><br />
    115- 建议添加索引:ALTER TABLE t_stk_moving_putin_task ADD INDEX idx_sorting_date_shelf_time(sorting_date,shelf_time);</span><br />
    116- <br />
    117- 【t_stk_moving_putin_task】表 【sorting_date,shelf_time】字段,索引分析:<br />
    118- +-------------------------+--------------------------------+---------------+---------------+<br />
    119- | TABLE_NAME | INDEX_NAME | COLUMN_NAME | CARDINALITY |<br />
    120- +=========================+================================+===============+===============+<br />
    121- | t_stk_moving_putin_task | idx_customer_id_sorting_date | sorting_date | 1326066 |<br />
    122- +-------------------------+--------------------------------+---------------+---------------+<br />
    123- | t_stk_moving_putin_task | idx_customerid_box_no_sorting_ | sorting_date | 1400802 |<br />
    124- | | date | | |<br />
    125- +-------------------------+--------------------------------+---------------+---------------+<br />
    126- | t_stk_moving_putin_task | idx_customerid_shelftime | shelf_time | 1347981 |<br />
    127- +-------------------------+--------------------------------+---------------+---------------+<br />
    128- | t_stk_moving_putin_task | idx_shelf_time_task_state | shelf_time | 1380454 |<br />
    129- +-------------------------+--------------------------------+---------------+---------------+<br />
    130- <br />
    131- <br />
  7. 2025-09-01 20:38:36, 由 李乐同 关闭。
    修改了 Bug状态 ,旧值为 "resolved",新值为 "closed"。
    修改了 指派给 ,旧值为 "liletong",新值为 "closed"。
    修改了 由谁关闭,旧值为 "",新值为 "liletong"。
    修改了 关闭日期,旧值为 "",新值为 "2025-09-01 20:38:36"。
所属项目 技术中心-需求池
所属模块 数据智能   数据工程
所属计划
所属迭代
Bug类型 非BUG-纯属误判
严重程度 一般
优先级 P2
Bug状态 已关闭
业务部门 总经办
影响功能
开发责任人 余效檀
测试责任人 余效檀
解决时效 4.04
激活次数 1
激活日期 2025-09-01 16:44:27
是否确认 是
当前指派 Closed 于 2025-09-01 20:38:36
截止日期 0000-00-00
上线时间 2025-09-01 20:09:00
上线时效 4.68
操作系统
浏览器
关键词
抄送给
所属迭代
相关需求
相关任务
由谁创建 李乐同 于 2025-09-01 15:28:07
影响环境 生产环境-业务反馈
由谁解决 余效檀 于 2025-09-01 19:30:27
解决版本 主干
解决方案 程序BUG
由谁关闭 李乐同 于 2025-09-01 20:38:36
最后修改 李乐同 于 2025-09-01 20:38:36
相关Bug