Sql选择查询超时

时间:2016-11-05 18:18:42

标签: sql sql-server tsql sql-server-2012

大家好我正在处理一个查询,并且每件事都运行正常,除非我运行查询超过2-3次这个返回超时是我的查询有问题或者这是服务器错误,请提示我这里是我的查询

SELECT   
    Category_Feature_Mapping.Feature_ID,
    Category_Feature_Mapping.Category_ID, 
    Option_Table.Option_ID,  
    Option_Table.Title, 
    Feature_Table.Title AS featuretitle, 
    Feature_Table.Type
FROM 
    Category_Feature_Mapping 
    INNER JOIN Feature_Table 
        ON Category_Feature_Mapping.Feature_ID = Feature_Table.Feature_ID
    INNER JOIN Option_Table 
        ON Feature_Table.Feature_ID = Option_Table.Feature_ID 
WHERE 
    Category_Feature_Mapping.Category_ID = @catid
    AND Feature_Table.Feature_ID=@feid
    AND Feature_Table.Feature_ID not in (SELECT
                                             Feature_ID 
                                         FROM
                                             Vendor_Value_Table 
                                         WHERE
                                             Vendor_ID=@venid)                       
GROUP BY
    Category_Feature_Mapping.Feature_ID,
    Category_Feature_Mapping.Category_ID, 
    Option_Table.Option_ID, 
    Option_Table.Title, 
    Feature_Table.Title,
    Feature_Table.Type

2 个答案:

答案 0 :(得分:0)

可以通过性能问题,尝试将“不存在”替换为“不存在”,如此

 AND not exists (
 SELECT * FROM Vendor_Value_Table vvt
 WHERE Feature_Table.Feature_ID =vvt.Feature_ID and vvt.Vendor_ID=@venid
 )     

答案 1 :(得分:0)

尝试在连接字符串中附加“;连接超时= 100”以延长超时