有张表tbFlight_data_chengxing数据量在100-200万,且随时有新数据写入,查询 SQL语句如下:
select a.ID,a.flight_no,a.passenger_cn_name,
a.passenger_en_name,a.credent_no,a.Flight_Time,
a.flight_takeoff_place_code,a.flight_arrive_place_code
from dbo.tbFlight_data_chengxing a,
(select max(id) ID from dbo.tbFlight_data_chengxing
where Flight_Date='2012/1/31 0:00:00'
AND (flight_arrive_place_code='HAK' orflight_arrive_place_code='SYX')
group by Passenger_EN_Name,Credent_No)b
where a.id=b.id
查询结果大概在4-6万,查询时间在7-20秒(有时速度在7秒,有时在20秒,不知道什么原因),其中ID是主键,创建了聚集索引,flight_no、Flight_Date索引,Flight_Date和flight_arrive_place_code组合索引,这条语句能否还能继续优化或者如何提高查询速度
|