Skip to main content
Tweeted twitter.com/StackDBAs/status/1176058757337571329
Formatting and language improvements
Source Link
Paul White
  • 90.3k
  • 30
  • 424
  • 663

SQL dateTime2 datetime2(0) vs dateTime2datetime2(2)

According to this articlethe documentation https://msdn.microsoft.com/en-us/library/bb677335.aspx.datetime2 (Transact-SQL):

Storage size 6Storage size
6 bytes for precisions less than 3; 73.
7 bytes for precisions 3 and 4. All
All other precisions require 8 bytes.

The size of dateTime2datetime2(0), dateTime2datetime2(1), dateTime2datetime2(2)use use the same amount of storage. (6 Bytesbytes).

Would I be correct in saying that I might as well go with dateTime2datetime2(2) and gain the benefit of the precision without any additional size costs.?

Please note:

  • This column is indexed with the PKPK to form a compound Clustered Index.clustered index (used for table partitioning)
  • I do-not not care about milliseconds

Would 'dateTime2(0)'datetime2(0) be more cpu efficient when being used in ana where queryclause, or when seeking through an index.?

This is a massive table, so the smallest optimization will make a big difference.

SQL dateTime2(0) vs dateTime2(2)

According to this article https://msdn.microsoft.com/en-us/library/bb677335.aspx.

Storage size 6 bytes for precisions less than 3; 7 bytes for precisions 3 and 4. All other precisions require 8 bytes.

The size of dateTime2(0), dateTime2(1), dateTime2(2)use the same amount of storage. (6 Bytes)

Would I be correct in saying that I might as well go with dateTime2(2) and gain the benefit of the precision without any additional size costs.

Please note:

  • This column is indexed with the PK to form a compound Clustered Index. (used for table partitioning)
  • I do-not care about milliseconds

Would 'dateTime2(0)' be more cpu efficient when being used in an where query or when seeking through an index.

This is a massive table so the smallest optimization will make a big difference.

datetime2(0) vs datetime2(2)

According to the documentation datetime2 (Transact-SQL):

Storage size
6 bytes for precisions less than 3.
7 bytes for precisions 3 and 4.
All other precisions require 8 bytes.

The size of datetime2(0), datetime2(1), datetime2(2) use the same amount of storage (6 bytes).

Would I be correct in saying that I might as well go with datetime2(2) and gain the benefit of the precision without any additional size costs?

Please note:

  • This column is indexed with the PK to form a compound clustered index (used for table partitioning)
  • I do not care about milliseconds

Would datetime2(0) be more cpu efficient when used in a where clause, or when seeking through an index?

This is a massive table, so the smallest optimization will make a big difference.

deleted 20 characters in body; edited title
Source Link
Zapnologica
  • 779
  • 4
  • 9
  • 19

SQL dateTime2(0) vs dateTime2(32)

According to this article https://msdn.microsoft.com/en-us/library/bb677335.aspx.

Storage size 6 bytes for precisions less than 3; 7 bytes for precisions 3 and 4. All other precisions require 8 bytes.

The size of dateTime2(0), dateTime2(1), dateTime2(2), dateTime2(3) useuse the same amount of storage.  (6 Bytes)

Would I be correct in saying that I might as well go with dateTime2(32) and gain the benefit of the precision without any additional size costs.

Please note:

  • This column is indexed with the PK to form a compound Clustered Index. (used for table partitioning)
  • I do-not care about milliseconds

Would 'dateTime2(0)' be more cpu efficient when being used in an where query or when seeking through an index.

This is a massive table so the smallest optimization will make a big difference.

SQL dateTime2(0) vs dateTime2(3)

According to this article https://msdn.microsoft.com/en-us/library/bb677335.aspx.

Storage size 6 bytes for precisions less than 3; 7 bytes for precisions 3 and 4. All other precisions require 8 bytes.

The size of dateTime2(0), dateTime2(1), dateTime2(2), dateTime2(3) use the same amount of storage.  (6 Bytes)

Would I be correct in saying that I might as well go with dateTime2(3) and gain the benefit of the precision without any additional size costs.

Please note:

  • This column is indexed with the PK to form a compound Clustered Index. (used for table partitioning)
  • I do-not care about milliseconds

Would 'dateTime2(0)' be more cpu efficient when being used in an where query or when seeking through an index.

This is a massive table so the smallest optimization will make a big difference.

SQL dateTime2(0) vs dateTime2(2)

According to this article https://msdn.microsoft.com/en-us/library/bb677335.aspx.

Storage size 6 bytes for precisions less than 3; 7 bytes for precisions 3 and 4. All other precisions require 8 bytes.

The size of dateTime2(0), dateTime2(1), dateTime2(2)use the same amount of storage. (6 Bytes)

Would I be correct in saying that I might as well go with dateTime2(2) and gain the benefit of the precision without any additional size costs.

Please note:

  • This column is indexed with the PK to form a compound Clustered Index. (used for table partitioning)
  • I do-not care about milliseconds

Would 'dateTime2(0)' be more cpu efficient when being used in an where query or when seeking through an index.

This is a massive table so the smallest optimization will make a big difference.

added 185 characters in body
Source Link
Zapnologica
  • 779
  • 4
  • 9
  • 19

According to this article https://msdn.microsoft.com/en-us/library/bb677335.aspx.

Storage size 6 bytes for precisions less than 3; 7 bytes for precisions 3 and 4. All other precisions require 8 bytes.

The size of dateTime2(0), dateTime2(1), dateTime2(2), dateTime2(3) use the same amount of storage. (6 Bytes)

Would I be correct in saying that I might as well go with dateTime2(3) and gain the benefit of the precision without any additional size costs.

Please not that this column is indexed with the PK to form a compound Clustered Index.note:

  • This column is indexed with the PK to form a compound Clustered Index. (used for table partitioning)
  • I do-not care about milliseconds

Would 'dateTime2(0)' be more cpu efficient when being used in an where query /or when seeking through an index.

This is a massive table so the smallest optimization will make a big difference.

According to this article https://msdn.microsoft.com/en-us/library/bb677335.aspx.

Storage size 6 bytes for precisions less than 3; 7 bytes for precisions 3 and 4. All other precisions require 8 bytes.

The size of dateTime2(0), dateTime2(1), dateTime2(2), dateTime2(3) use the same amount of storage. (6 Bytes)

Would I be correct in saying that I might as well go with dateTime2(3) and gain the benefit of the precision without any additional size costs.

Please not that this column is indexed with the PK to form a compound Clustered Index.

Would 'dateTime2(0)' be more efficient when being used in an where query / index.

According to this article https://msdn.microsoft.com/en-us/library/bb677335.aspx.

Storage size 6 bytes for precisions less than 3; 7 bytes for precisions 3 and 4. All other precisions require 8 bytes.

The size of dateTime2(0), dateTime2(1), dateTime2(2), dateTime2(3) use the same amount of storage. (6 Bytes)

Would I be correct in saying that I might as well go with dateTime2(3) and gain the benefit of the precision without any additional size costs.

Please note:

  • This column is indexed with the PK to form a compound Clustered Index. (used for table partitioning)
  • I do-not care about milliseconds

Would 'dateTime2(0)' be more cpu efficient when being used in an where query or when seeking through an index.

This is a massive table so the smallest optimization will make a big difference.

Source Link
Zapnologica
  • 779
  • 4
  • 9
  • 19
Loading