在mysql中像这样的sql
SELECT record.id,
record.create_time AS finishTime,
record.money,
record.real_money AS realMoney,
record.money-record.real_money AS discountMoney,
record.out_flow_num AS outFlowNum,
record.user_id AS userId,
mp_order.order_number AS orderNum,
mp_order.teacher_id AS teacherId,
stc.small_type_name AS smallTypeName
FROM mp_bill_record record
JOIN
(
SELECT bill_type, small_type, channel, small_type_name
FROM mp_bill_small_type_channel
WHERE type= 'CASH_CONSUME'
AND is_delete= 0
AND id= 60) stc
ON record.bill_type= stc.bill_type
AND record.small_type= stc.small_type
AND record.channel= stc.channel
LEFT JOIN mp_order ON record.common_id= mp_order.id
WHERE record.is_delete= 0
AND record.create_time>= '2018-12-24 00:00:00'
AND record.create_time< '2018-12-25 00:00:00'
使用ORDER BY record.id desc
花费的时间超过30000ms。如果没有ORDER BY record.id desc
,则需要300毫秒。
而且,结果只有8行。