select d.*,c.name AS couponName from pe_a d
left join pe_b r on r.id = d.ruleId
left join pe_c c on d.coupon_id = c.id
where 1=1 and r.`enable` = 1 and r.delete_flag = 0
and r.expity_start < now() and r.expity_end > now()
and d.status = 1 and d.expity_start < '2019-04-11 20:36:58' and d.expity_end > '2019-04-11 20:36:58'
and ( 1=2 or d.allocate_phone_number = '15201733860' or d.allocate_user_id = '420832473243164672' )
order by d.expity_end limit 0,100
数据库执行0.03秒,代码执行5秒
-------------------------原因-----------------------
builder.append(" or d.allocate_user_id &#
sql在数据库执行很快 放在代码中就相当慢
最新推荐文章于 2023-08-21 11:01:52 发布