1、select count(*) from table_name

比select count(主键列) from table_name和select count(1) from table_name 要快一些

但是对于千万级来说这还是很慢

 

2、非聚集索引比聚集索引要快

假如表里只有一个聚集索引,你在建立一个非聚集索引,然后查询时指定使用该非聚集索引,速度将会得到提高

如果聚集索引需要1800毫秒的话 用非聚集索引会降到1300毫秒

 select count(*) from tj_ClientActionIP with (index(IX_tj_ClientActionIP_2)) where dateandtime>='2013-2-2'

 

3、bit类型的非聚集索引要比其他数据类型的非聚集索引要快

假如你在该表中添加一个列,数据类型是bit ,不可为空,默认为0.然后为其创建非聚集索引,速度也将得到提到。

假如你用第二步的方法 耗时1300毫秒的话,使用BIT类型,会降到800毫秒。

 

耗时三天,总结出以上方案。立贴记录

 

 

相关文章:

  • 2022-02-14
  • 2022-12-23
  • 2021-10-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-29
  • 2022-12-23
猜你喜欢
  • 2021-06-19
  • 2021-11-13
  • 2021-12-29
  • 2022-03-08
  • 2021-06-16
  • 2021-12-26
相关资源
相似解决方案