How much of a difference does using tinyint
or smallint
(when applicable) instead of just int
do? Or restricting a char
field to the minimum characters needed?
Do these choices affect performance or just allocated space?
A data type determines the type of data that can be stored in a database table column. When you create a table, you must decide on the data type to be used for the column definitions. You can also use data types to define variables and store procedure input and output parameters.
Choosing the right data types when you're designing your columns, tables, and indexes is really critical. Using the wrong data type can cause more space to be required, affecting data density in memory, database and backup size, transaction log efficiency, and more.
A data type tells the database what functions can be performed with the data. The second important reason to define the data type is so that the proper amount of storage space is allocated for the data.
The smallest data type is a byte, which is 8 bits. Each bit can be a 0 or 1.
On an Indexed field with a significantly large table the size of your field can make a large affect on performance. On a nonindexed field its not nearly as important bit it still has to write the extra data.
That said, the downtime of a resize of a large table can be several minutes or several hours even, so don't make them smaller than you'd imagine ever needing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With