Is there a performance advantage for storing dates as int in MS SQL Server

Or in terms of space or speed of queries and field comparisons?

+3
source share
4 answers

Datetime columns are already stored in SQL Server as 8-byte binary values ​​— 4 bytes for the date part and 4 for the time part. Any other view that you see is just a look to make them more accessible to humans.

, (, , , 2008), , , , .

, , .

+5

ints , , 20090230 SQl 2008, DATE, 3

+2

MS SQL 2008 . int.

0

Keeping dates as ints will be bad because you will always need to recreate the data as a date in order to match the date or date. This will negatively affect performance. In addition, to store dates as ints, you will need to write a trigger to ensure that no dates are added to the field. If you do not, you will have problems with the integrity of the date when invalid dates, such as 2302009, are indicated in your field.

0
source

Source: https://habr.com/ru/post/1703687/


All Articles