我正在使用查询连接列,一个具有聚集索引,另一个具有非聚集索引。查询需要很长时间。这是我使用不同类型索引的原因吗?
SELECT @NoOfOldBills = COUNT(*)
FROM Billing_Detail D, Meter_Info m, Meter_Reading mr
WHERE D.Meter_Reading_ID = mr.id
AND m.id = mr.Meter_Info_ID
AND m.id = @Meter_Info_ID
AND BillType = 'Meter'
IF (@NoOfOldBills > 0) BEGIN
SELECT TOP 1 @PReadingDate = Bill_Date
FROM Billing_Detail D, Meter_Info m, Meter_Reading mr
WHERE D.Meter_Reading_ID = mr.id
AND m.id = mr.Meter_Info_ID
AND m.id = @Meter_Info_ID
AND billtype = 'Meter'
ORDER BY Bill_Date DESC
END