Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Choosing right datatype for a column

Status
Not open for further replies.

xcata

Programmer
Jun 27, 2001
39
FR
Hi,

I must design a Sql Server 7.0 database for a heavy loaded website. This database will receive 50k+ inserts/day and 10-20k+ selects.
All selects are time dependant. Initially the column had datetime type. For speed reasons I created another column (integer type). This column store the difference in hours regarding a past date. Of course, searching this column with a proper index is much faster than datetime. Now the specifications are changed, I don't need minutes and seconds any more. So, I can replace the datetime field with a smalldatetime one.

The question is, wich of the two variants are faster ?
1. Integer type
+: the fastest datatype in search
-: a)need an extra field, so the row gets larger and Sql server need to read more data pages
b) every time a small overhead is generated by the calcul of that integer (insert and select)
2. smalldatetime type
+: I already have this field so I don't need another one
-: I don't know if query speed on a smalldatetime(with index) regarding an integer (with index) are comparable
The both are 4 Bytes long (integer and 2 smallint).

Thanks.


 
What is the nature of the heaviest of the queries you do? If it is in the vein of selecting rows between this datetime and another datetime, then I would use only the smalldatetime value and make it a clustered index - assuming what I said about the nature of the queries you are doing is correct.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top