我的SQL Server表中有大约820,000条记录,从表中选择数据需要5秒钟。该表在时间列上有一个聚集索引,该时间列可能为NULL (到目前为止,它不包含任何NULL值)。为什么只获取这么多记录需要5到6秒?
发布于 2019-05-26 01:01:02
你说的“选择数据”是什么意思?如果您要在management studio中获取如此多的记录(显示所有记录),那么这6秒中的大部分时间都会被显示所有行所占用。如果是这样,只需将记录插入到临时表中。它会快得多。
发布于 2019-05-29 11:22:14
我建议你这样做:
1.Check if you are using Clustered and Non-Clustered in you columns (best way I think with a sp_help NameTable).
2.When you using comand "select" specific always all name columns (never use Select * From ..... ).
3.If you are using SSMS check in tools SQL Execution Plan , with this tool you can make simple review your TSQL (you can see cost
each query you make.
4.Dont use "convert(...." in clause WHERE , for example .. Where Convert(int,NameColum)=100.https://stackoverflow.com/questions/56306862
复制相似问题