我现在有 200 万条记录的表,它将每天增加 05 万条记录,所以我想优化这个查询
Select * from Forex where Id in
(SELECT MAX(Id) FROM Forex GROUP BY Symbol having Symbol in
(Select Distinct Symbol from Forex) )
我创建了 NONCLUSTERED INDEX,所以这个查询所用的时间是 673 毫秒。我已将查询修改为
Select * from Forex where Id in
(SELECT MAX(Id) FROM Forex GROUP BY Symbol having Symbol in
('AUDCAD','AUDCHF','AUDJPY','AUDNZD','AUDUSD','CADCHF','CHFJPY',
'EURAUD','EURCAD','EURCHF','EURGBP','EURJPY','EURNOK','EURNZD',
'EURUSD','GBPCAD','GBPCHF','GBPJPY','GBPUSD','NZDJPY','NZDUSD',
'USDCAD','USDCHF','USDJPY','USDNOK','USDSEK'))
现在花费的时间是 391 毫秒
是否有可能使少于 100 毫秒?或有人帮助优化此查询