如题,公司系统有个存储过程每天早上第一次运行的时候都是Time Out,运行几次之后又很顺了,不知道是不是索引的问题,不知大家有没遇到这种情况,怎么检查解决?

解决方案 »

  1.   

    DBCC CHECKTABLE
    检查指定表或索引视图的数据、索引及 text、ntext 和 image 页的完整性。
      

  2.   

    查询结果不是很多,只是查询同一个表,这个表里有很多个索引.在内存中? 怎么知道是在内存中,怎么把它在内存中清除. 但不可能不在内存中就Time out的.
      

  3.   

    页面会运行下面的:
    declare @web_reg_id
    set @web_reg_id=102354
     exec sp_GetUserFactoryAccess @web_reg_id
     exec sp_GetINSPCreatedBy @web_reg_id
     exec sp_GetINSPLocation @web_reg_id
     exec sp_GetINSPFactories @web_reg_id
     exec sp_GetINSPDisposition @web_reg_id
    其中sp_GetINSPCreatedBy如下,其他的存储过程都有用到表INSPECTION 
    sp_helptext sp_GetINSPCreatedBy
    SELECT  Distinct
    I.CreatedBy,
    RTrim(W.UserId) + ' - ' + RTrim(W.FirstName) + ' ' + RTrim(W.LastName) AS CreatedByNm 
    FROM  INSPECTION I with(index=IX_ORDERIDPARTID)
    INNER JOIN OebOrder O ON (I.OrderId = O.OrderId AND I.PartId = O.PartId)
    INNER JOIN #temp_factory T ON (O.FactoryId = T.FactoryId)
               INNER Join SSORepl.dbo.WebUser  W ON (I.CreatedBy = w.RegId)
    ORDER BY CreatedBysp_helptext sp_GetINSPDisposition
    Select  Distinct
     D.InspDispCd,
     D.Description,
     D.SortSeq
    From  INSPECTION I with(index=IX_INSPDISPCD) 
       INNER JOIN OebOrder O ON (I.OrderId = O.OrderId AND I.PartId = O.PartId)
       INNER JOIN #temp_factory T ON (O.FactoryId = T.FactoryId)
       INNER Join InspDisposition D ON (I.InspDispCd = D.InspDispCd)
    Order By D.SortSeq
      

  4.   

    dbcc dbreindex('INSPECTION' )
    ---重建一下索引试一下