MySQL int storage time

Source: Internet
Author: User


Time is widely used in our development. In most development, we will use the datetime format of MySQL for storage. However, for applications that frequently use time to sort or query, we need to set the time
Indexing is highly related to our query efficiency. At an occasional opportunity, when I saw the database of the discuz forum, I found that it was stored using Int, not responding at first, most
And found that it has many benefits.
1. First, we analyze that the datetime length is 8 bytes, the int length is 4 bytes, and the storage space is less than that of datatime.
2.int stores less index space than datetime, with high sorting efficiency and fast query speed. (The javaeye Q & A channel is sorted by time. This type should also be used)
3. Easy to calculate. UNIX timestamps are easy to calculate. Freight expert
There is also an example of comparing Timestamp and INT on the Internet. The timestamp efficiency is not inferior to that of int, and timestamp has the automatic update function.
Location
Address: <
Href = 'HTTP: // imysql.cn/2008_07_17_timestamp_vs_int_and_datetime'> http://imysql.cn/2008_07_17_timestamp_vs_int_and_datetime </a>
Let's see what types are used for storage!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.