我有一个有1,000,000条记录的数据库和这样的查询:“SELECT COUNT()”是非常缓慢
select count(code) from table1
它运作良好,在本地系统上,而是成为在网络上很慢。其他查询如select * from table
执行得很快,但select count(code) from table1
非常慢。我无法更改数据库的结构。我的数据库是Foxpro,我使用VB.NET。
有没有解决方案?
编辑:我应该这样写代码吗?
dim ds as new dataset
dim da as new datadapter("select count(*) from table ", connection)
da.fill(ds,"tbl1")
那么我怎样才能从数据集中获得select count(code) from table1
?
还是我必须使用LINQ?
编辑2:我的意思是select count(*)
和select count(code)
之间的比较。
解决方案是什么?
如已经说过,当你需要澄清你的问题,请编辑它而不是发布答案。谢谢! – 2010-07-19 19:34:57