Answer the question
In order to leave comments, you need to log in
How would you store the date, time?
There is a date and 2 marks inside the date (start and end). For example 2015-11-10 from 10:00 to 16:00
You can make 2 datetime fields and spend 16 bytes.
You can make 2 timestamp fields and spend 8 bytes, but it’s just that the date 2015-11-10 is not searched for by the timestamp field, then you have to select the date using the <> operators, I don’t know how long the selection will take
You can make 1 date field and 2 timestamp fields, I’ll spend 11 bytes, or 2 times I'll spend 9 bytes, but it's convenient to choose the date and time.
Which option is the best in your opinion?
UP If you have any information or links on the topic of comparing the speed of samples for different fields date, timestamp, datetime, etc., then I will be grateful.
Answer the question
In order to leave comments, you need to log in
Do you count bytes because your program will run on a refrigerator?
Or maybe you will have trillions of ranges?
Or will the number of samples be a billion per day?
Purely from the point of view of self-development, your question is interesting, but I recommend that you immediately put some practical considerations and micro-optimizations out of your head if you do not have a real, pre-real highload project.
Relatively speaking, the bar of RAM now costs in proportion to the hour of the programmer's work. Therefore, if you spent an hour more time during the design of the project and made an "optimized" but inconvenient solution, the support of which will eat up another hour a month - you have done the project a disservice.
I must say right away that I do not call for writing unoptimized shit code and closing holes in it with an increase in iron. But what you are talking about cannot even be called savings on matches.
premature optimization is an antipattern.
Plus, databases are usually well optimized for sampling by standard data types.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question