sum(1)或:select a.name 表名,b.rows 记录数 from sysobjects a join sysindexes b on a.xtype='U' and a.status>0 and a.id=b.id and b.indid<2
那么大的数据量,没有必要作 count 啊,无论左右处理,count 的算法都是一样的。
真的要做统计吗??? 那就通过读系统表做吧主要是sysIndexes表里信息。 相信你很快会解决
select count(1) from a1
try: select count(*) from tablename (index=clusteredindex,nolock)
以查询条件中的字段建立索引!或者 select top 1 * from table 呵呵
用sum(1)快 518195(数据) set noexec off set parseonly off SQL:StmtCompleted 0 0 0 0 select IS_SRVROLEMEMBER ('sysadmin') SQL:StmtCompleted 0 0 0 0 SET STATISTICS PROFILE ON SQL:StmtCompleted 0 0 0 0 select sum(1) from a SQL:StmtCompleted 89 65 104 0 select count(*) from a SQL:StmtCompleted 32 180 104 0 select count(cfh) from a SQL:StmtCompleted 211 180 104 0 SET STATISTICS PROFILE OFF SQL:StmtCompleted 0 0 0 0
那就通过读系统表做吧主要是sysIndexes表里信息。
相信你很快会解决
select count(*) from tablename (index=clusteredindex,nolock)
呵呵
518195(数据)
set noexec off set parseonly off SQL:StmtCompleted 0 0 0 0
select IS_SRVROLEMEMBER ('sysadmin') SQL:StmtCompleted 0 0 0 0
SET STATISTICS PROFILE ON SQL:StmtCompleted 0 0 0 0
select sum(1) from a SQL:StmtCompleted 89 65 104 0
select count(*) from a SQL:StmtCompleted 32 180 104 0
select count(cfh) from a SQL:StmtCompleted 211 180 104 0
SET STATISTICS PROFILE OFF SQL:StmtCompleted 0 0 0 0
select count(*) from forumtopic
select count(forumid) from forumtopic
select count(topicid) from forumtopic
select sum(1) from forumtopicIO:
(1 row(s) affected)Table 'ForumTopic'. Scan count 1, logical reads 868, physical reads 0, read-ahead reads 0.(1 row(s) affected)Table 'ForumTopic'. Scan count 1, logical reads 868, physical reads 0, read-ahead reads 0.(1 row(s) affected)Table 'ForumTopic'. Scan count 1, logical reads 868, physical reads 0, read-ahead reads 0.(1 row(s) affected)Table 'ForumTopic'. Scan count 1, logical reads 868, physical reads 0, read-ahead reads 0.