Jelajahi Sumber

订单查询 Using join buffer (Block Nested Loop)问题优化

wanxl 1 tahun lalu
induk
melakukan
a4c7352084
1 mengubah file dengan 4 tambahan dan 5 penghapusan
  1. 4 5
      src/main/resources/mapper/order/OrderMapper.xml

+ 4 - 5
src/main/resources/mapper/order/OrderMapper.xml

@@ -86,7 +86,8 @@
         shopPhone,
         tiu.user_name as riderNickName,tiu.phone as riderPhone,ti.indent_id as indentId,ti.is_rider as isRider,
         ti.rider_user_id as riderUserId, tcu.money as couponMoney,
-        apr.discount_amount as activityDiscountAmount, ai.title activityTitle,tiu.rider_station_id as riderStationId,rs.station_name as stationName
+        apr.discount_amount as activityDiscountAmount, ai.title activityTitle,tiu.rider_station_id as riderStationId,
+        (select rs.station_name from rider_station rs where  rs.id =tiu.rider_station_id ) as stationName
         from tb_order tor
         left join tb_user tu on tor.user_id = tu.user_id
         left join goods_shop gs on tor.shop_id = gs.shop_id
@@ -95,7 +96,6 @@
         left join tb_coupon_user tcu on tor.coupon_id = tcu.id
         left join activity_part_record apr on apr.order_id = tor.order_id
         left join activity ai on ai.id = apr.activity_id
-        left join rider_station rs on tiu.rider_station_id = rs.id
         where 1 = 1
         <if test="riderPhone!=null and riderPhone!=''">
             and tiu.phone =#{riderPhone}
@@ -153,7 +153,8 @@
         shopPhone,
         tiu.nick_name as riderNickName,tiu.phone as riderPhone,ti.indent_id as indentId,ti.is_rider as isRider,
         ti.rider_user_id as riderUserId, tcu.money as couponMoney,
-        apr.discount_amount as activityDiscountAmount, ai.title activityTitle,ogg.detail,ogg.sumPrice,rs.station_name as stationName
+        apr.discount_amount as activityDiscountAmount, ai.title activityTitle,ogg.detail,ogg.sumPrice,
+        (select rs.station_name from rider_station rs where  rs.id =tiu.rider_station_id ) as stationName
         from tb_order tor
         left join tb_user tu on tor.user_id = tu.user_id
         left join goods_shop gs on tor.shop_id = gs.shop_id
@@ -162,7 +163,6 @@
         left join tb_coupon_user tcu on tor.coupon_id = tcu.id
         left join activity_part_record apr on apr.order_id = tor.order_id
         left join activity ai on ai.id = apr.activity_id
-        left join rider_station rs on tiu.rider_station_id = rs.id
         left join (  select @a:=0,order_id ,group_concat(@a:=@a+1,".商品名:",goods_name,",数量:",goods_num,",规格:",sku_message) detail,sum(goods_num*goods_price) sumPrice  from order_goods og group by order_id
         ) ogg on ogg.order_id =tor.order_id
         where 1 = 1
@@ -217,7 +217,6 @@
         left join goods_shop gs on tor.shop_id = gs.shop_id
         left join tb_indent ti on tor.order_id = ti.order_id
         left join tb_user tiu on tiu.user_id = ti.rider_user_id
-        left join rider_station rs on tiu.rider_station_id = rs.id
         where 1 = 1
         <if test="riderPhone!=null and riderPhone!=''">
             and tiu.phone =#{riderPhone}