我从数据库中提取数据,一张表约500W条数据,有19列, 按人员标识来查询的话正常2秒能出来结果 ,如果select *来绑定到datagridview的话,就会连接超时,但有时也能查出结果来. 因为一些需求 不用分页和虚拟模式显示,求一些 解决超时问题的经验?
解决方案 »
- 序列化问题。。
- 求助大虾关于c# 中remoting服务器和客户端文件传输
- 在c#程序中查询oracle中返回的结果集中的数组?
- 如何判断一个字符是否是中文?
- ★★★★★有点难度的问题(关于操纵clipboard,会的不会的,进来看看,牛人们秀秀你得功力,谢了★★★★★
- C#中ICS端口设置问题?
- vs2010新建和打开解决方案时告警,大哥大姐们帮我看看下,谢谢!
- c#项目外包
- 求救!更改Active Directory用户密码问题
- Timer控件和System.Threading.Timer有什麽区别?用那个更好??
- wpf富文本框编辑器怎么做?
- ASP.NET未将对象引用设置到对象的实例(C#)
添加索引
一是内存占用大,二是网络负载也大,三是CPU也受不了,四是数据库的IO也难受
create proc PageNum
@PageSize int, --每页显示条数
@PageIndex int, --当前是第几页
@totalRows int output, --总行数
@totalPages int output --总页数
as
declare @startId int
declare @endId int
set @startId = @PageSize*(@PageIndex-1)+1
set @endId = @startId+@PageSize-1
select @totalRows=COUNT(*) from Books
set @totalPages=@totalRows/@PageSize
if(@totalRows%@PageSize != 0) --如果总行数除每页显示数据量的值不等于0,则总页数得加1
begin
set @totalPages=@totalPages+1
end
declare @IndexTable table(Id int identity(1,1) ,nId int)
insert into @IndexTable select Id from Books
select * from @IndexTable as t ,Books as b where t.Id>=@startId and t.Id<=@endId and t.nId=b.Id
go
declare @tr int --总行数
declare @tp int --总页数
exec PageNum 4,2,@tr output ,@tp output
print '这是总页数'+convert(varchar,@tp) --数据转换
print @tr