//取得记录数
public int getCount() {
String sql = "select count(1) from blog";
try {
result = (Integer) qr.query(sql,new ScalarHandler(1));
} catch (SQLException e) {
e.printStackTrace();
}
System.out.println("result:"+result);
return result;
}
数据量达到几百万上千万以上好象就有点慢了,而且在页面中首次加载的速度也很慢
8 个解决方案
#1
快速得到数据库中所有用户表的记录数(行数)
SELECT A.NAME AS 表名,B.ROWCNT AS 记录数
FROM SYSOBJECTS A
JOIN SYSINDEXES B
ON A.ID=B.ID AND A.XTYPE='U'
AND B.INDID<2
#2
强!学习
#3
SELECT B.ROWCNT AS 记录数你那个改为这样试试
FROM SYSOBJECTS A
JOIN SYSINDEXES B
ON A.ID=B.ID AND A.XTYPE='U'
AND B.INDID<2
WHERE A.NAME='blog'
#4
SYSINDEXES
#5
--2005 2008
SELECT SUM (row_count) AS total_number_of_rows
FROM sys.dm_db_partition_stats
where object_id=object_id('HumanResources.EmployeeAddress')
AND (index_id=0 or index_id=1);
SELECT SUM (row_count) AS total_number_of_rows
FROM sys.dm_db_partition_stats
where object_id=object_id('HumanResources.EmployeeAddress')
AND (index_id=0 or index_id=1);
#6
'HumanResources.EmployeeAddress' 这是你的表名
#7
select ROWCNT from SYSINDEXES where id =OBJECT_ID('tb_B') and INDID<2
#8
学习了!谢谢!
#1
快速得到数据库中所有用户表的记录数(行数)
SELECT A.NAME AS 表名,B.ROWCNT AS 记录数
FROM SYSOBJECTS A
JOIN SYSINDEXES B
ON A.ID=B.ID AND A.XTYPE='U'
AND B.INDID<2
#2
强!学习
#3
SELECT B.ROWCNT AS 记录数你那个改为这样试试
FROM SYSOBJECTS A
JOIN SYSINDEXES B
ON A.ID=B.ID AND A.XTYPE='U'
AND B.INDID<2
WHERE A.NAME='blog'
#4
SYSINDEXES
#5
--2005 2008
SELECT SUM (row_count) AS total_number_of_rows
FROM sys.dm_db_partition_stats
where object_id=object_id('HumanResources.EmployeeAddress')
AND (index_id=0 or index_id=1);
SELECT SUM (row_count) AS total_number_of_rows
FROM sys.dm_db_partition_stats
where object_id=object_id('HumanResources.EmployeeAddress')
AND (index_id=0 or index_id=1);
#6
'HumanResources.EmployeeAddress' 这是你的表名
#7
select ROWCNT from SYSINDEXES where id =OBJECT_ID('tb_B') and INDID<2
#8
学习了!谢谢!