Size matters – I don’t care what your girlfriend says.
When creating tables, deciding on what data types to use is important in regards to long term performance from your SQL Server. In this post we will be comparing tinyint, smallint, int and bigint.
We will be looking at how storage size and memory usage differs between the data types, and how this impacts performance.
I created four tables for each data type, each with five columns and five million records. Below is an example of one of those tables, using tinyint.
CREATE TABLE [Tinyint] (
Col1 tinyint,
Col2 tinyint,
Col3 tinyint,
Col4 tinyint,
Col5 tinyint
)
This isn’t a ‘real world’ example, but the purpose of this post is to showcase the impact on performance between the data types – at scale, the difference will become more apparent.
Continue reading “TinyInt vs SmallInt vs int vs BigInt, does size matter?” →