日期:2014-05-17  浏览次数:20542 次

帮忙优化下sql语句
signstationid,reachdatetime,signmachineid,cp是联合主键, 这是个分页的语句,才几千条数据,在数据库中查询居然要10秒,请大家帮忙优化下.
SELECT   TOP 10 *
FROM     (SELECT t1.signstationid,
                 t1.reachdatetime,
                 t1.signmachineid,
                 t1.cp,
                 t1.direction,
                 t1.imageindex,
                 t1.isupload,
                 t1.vehiclecount,
                 t1.vehiclespeed,
                 t1.lanenum,
                 t1.iscorrect,
                 t1.vehiclelenth,
                 t1.vehicletype,
                 t2.signstationname,
                 t3.signmachinename,
                 t3.signmachineip
          FROM   cpvehiclepass t1
                 LEFT JOIN (SELECT signstationid,
                                   signstationname
                            FROM   signstation) t2
                   ON t1.signstationid = t2.signstationid
                 LEFT JOIN (SELECT signmachineid,
                                   signmachinename,
                                   signstationid,
                                   signmachineip
                            F