等待内存资源在资源池“internal”(1)中执行查询时发生超时。重新运行查询

时间:2016-03-03 08:31:44

标签: sql sql-server sql-server-2008

当我运行此查询时

Select         
-- Generate the row number        
ROW_NUMBER() over(order by MenuOrder) as 'rownum',        
-- get the minimum data from query        
(Select top 1 ROW_NUMBER()over(order by MenuOrder)          
from SitePage where ActiveFlag='true' AND SiteId=1083 and LanguageId=159 AND ChildOf=0 order by MenuOrder asc) as 'min',        
-- get the maximum data from query        
(Select top 1 ROW_NUMBER()over(order by MenuOrder)  from SitePage where ActiveFlag='true' and LanguageId=159 AND SiteId=1083 AND ChildOf=0         
order by MenuOrder desc) as 'max',        
-- get rest of all details        
,(case when exists(select from SitePage where ChildOf = AP.SitePageId and ActiveFlag =1  ) then 'Y' else 'N' end) as [Type]  from SitePage AP 
where ActiveFlag=1 AND SiteId=1083 AND ChildOf=0 and LanguageId=159 order by MenuOrder

然后我收到以下错误

“等待内存资源在资源池'internal'中执行查询时发生超时(1)。重新运行查询。”

我使用的是Sql Server 2008 R2 版本10.50.4000.0

查询等待时间为1

最大服务器内存为12288 MB

1 个答案:

答案 0 :(得分:0)

试试这个 -

SELECT
      t.rownum
    , t.[Type]
    , [min] = MIN(t.rownum) OVER ()
    , [max] = MAX(t.rownum) OVER ()
FROM (
    SELECT
          rownum = ROW_NUMBER() OVER (ORDER BY MenuOrder)   
        , [Type] = (
            CASE
                WHEN EXISTS (
                        SELECT 1
                        FROM SitePage c
                        WHERE c.ChildOf = AP.SitePageId
                            AND c.ActiveFlag = 1
                    )
                    THEN 'Y'
                ELSE 'N'
            END
        )
    FROM SitePage a
    WHERE a.ActiveFlag = 1
        AND a.SiteId = 1083
        AND a.ChildOf = 0
        AND a.LanguageId = 159
) t