Reputation: 145
What MySQL data type suits best for storing average rating values, like movie ratings on IMDB? FLOAT, DECIMAL? Or maybe it will work faster if I round actual values to two decimal places in PHP and save it like INT (8.323243 -> 8.32 -> 832)?
Upvotes: 3
Views: 2031
Reputation: 75699
You don't care about precision, so it is not necessary to use decimal. If you want to only use whole numbers, use an int. Else, use a float or double.
Rounding it first in PHP gains you nothing. Converting it in PHP between int and double will be slower than storing doubles in the database.
Upvotes: 3
Reputation: 4439
The most performant, fast and small data type will indeed be INT
.
Sorting, searching, etc. will be the best with this data type, vs. decimal
and/or float
.
Upvotes: 0