Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
139 views
in Technique[技术] by (71.8m points)

sql server - Does record size affect SQL performance?

Our team is using Microsoft SQL Server, accessed using Entity Framework Core.

We have a table with 5-40 million records anticipated, which we want to optimize for high-velocity record create, read and update.

Each record is small and efficient:

  • 5 integer (one of which is the indexed primary key)
  • 3 bit
  • 1 datetime

plus 2 varchar(128) - substantially larger than the other columns.

The two varchar columns are populated during creation, but used in only a tiny minority of subsequent reads, and never updated. Assume 10 reads and 4 updates per create.

Our question is: does it improve performance to put these larger columns in a different table (imposing a join penalty for create, but only a tiny minority of reads) versus writing two stored procedures, using one which retrieves the non-varchar columns for the majority of queries, and one which retrieves all columns when required?

Put another way: how much does individual record size affect SQL performance?

question from:https://stackoverflow.com/questions/65837073/does-record-size-affect-sql-performance

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

does it improve performance to put these larger fields in a different table (imposing a join penalty for create, but only a tiny minority of reads)

A much better alternative is to create indexes which exclude the larger columns and which support frequent access patterns.

The larger columns on the row will have very little cost on single-row operations on the table, but will substantially reduce the row density on the clustered index. So if you have to scan the clustered index, the having large, unused columns drives up the IO cost of your queries. That's where an appropriate non-clustered index can offload any scanning operations away from the clustered index.

But, as always, you should simply test. 40M rows is simple to generate, and then write your top few queries and test their performance with different combinations of indexes.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...