MySQL is the best data type for simple time with hours and minutes

I need to imagine the execution time of tasks in my MySQL 5 database.
Then I need to store such moments:
_ eighteen
_ 9:15
_ 12:00

Now I am in a dilemma whether to use a time data type or just a 4-digit integer, since I just need to store hours and minutes.
In the second case, I would save:
_ 1800
_ 0915
_ 1200

What are the implications of both approaches?
Which solution would you take, given that the most important requirement is high performance in a huge data set (millions of rows)?

The application code is written in PHP.

EDIT: I was thinking about an important point. If I use integers, I need to do some string manipulation with PHP when I show the time (to insert a semicolon), which probably resets the gain using integers

Thanks,
Dan

+7
performance mysql
source share
2 answers

Use time data type. The main advantage will be the reuse of the existing time function built into MySQL.

It will probably be more space-efficient with smallint (only 2 bytes), but you will lose the ability to use existing functions to work with fields whose semantics are time . I can think of formatting functions, time differences, time zones as examples of scenarios where you could use the time type right away.

+10
source share

MySQL TIME data type takes only 3 bytes. Use it.

http://dev.mysql.com/doc/refman/5.0/en/storage-requirements.html

+3
source share

All Articles