SELECT
B.tblBooking_id,
F.M_Merged_CustomerId,
B.depart_date,
B.cancellation,
B.booking_num,
B.end_date,
B.date_booked,
B.booking_price,
B.tblBooking_Id as SOURCE_RES_ID ,
B.agentid,
B.is_insert_date,
B.is_update_date is_update_date,
A.Agent_Email_Address as agent_email,
A.Agent_Email_Address as agent_email_system
FROM tblBooking B
JOIN tblAgent A
ON B.agentid=A.agentid
LEFT JOIN tblFactCustomers F
ON B.booking_num = F.raw_booking_num
WHERE B.agentid !=0 or B.agentid IS NOT NULL
GROUP BY B.tblBooking_id;
使用表格 : tblBooking , tblAgent , tblFactCustomers索引存在于预订编号和原始预订编号中
我怀疑脚本是否会成功执行,因为有分组依据子句并且没有使用聚合函数。但是,对于性能度量,请检查字段值B.agentID
,如果没有负值,则替换WHERE B.agentid !=0 or B.agentid IS NOT NULL
WHERE B.agentid >0
并在 agentID
上创建非聚集索引。