日期:2014-05-18  浏览次数:20424 次

求高手解决T-sql问题-出现内存泄漏的现象
我现在遇到的问题
View_table 600W条数据
执行它之后sqlserver占用大量内存不释放->select top 100010 row_number() over(order by pagetable_id) from View_table

请问的我的语法有什么问题吗



------解决方案--------------------
楼主为何直接要查询10W多条数据,是前台分页用???
看下执行计划,order by后的字段加索引试试,先把现在查询窗口的进程KILL掉。
------解决方案--------------------
select top 1000 row_number() over(order by pagetable_id) from View_table

如果直接是查询,那么没多大问题,如果是做子查询,楼主要把别名加上

select top 1000 row_number() over(order by pagetable_id) as tid from View_table
------解决方案--------------------
SQL code
with T  as
(select row_number() over(order by pagetable_id) from View_table
)
select top 1000 *  from T

------解决方案--------------------
看一下视图

估计是数据量过大,内存太小或可用资源太少时