How MySQL stores URL strings

Source: Internet
Author: User

URL length varies, how does MySQL store it?

Because I need the URL as a unique index to use, later used as a query, short index I think the meaning is not very significant.
Is there a good way to turn long strings into short strings or numbers to store them (or otherwise), or is it a bad choice to use the MySQL store itself?

Reply content:

URL length varies, how does MySQL store it?

Because I need the URL as a unique index to use, later used as a query, short index I think the meaning is not very significant.
Is there a good way to turn long strings into short strings or numbers to store them (or otherwise), or is it a bad choice to use the MySQL store itself?

URLs do not have to be indexed, string index Some aspects if not good will be very slow, not to mention you are the URL.

If you still want URL storage and URL is very long, and want to shorten the string can use the short domain API interface, to shorten the URL

The access effect is the same.

原网址: http://music.baidu.com/song/124380645短网址: http://dwz.cn/Kn8Ep

No matter how long the URL will be shortened to a fixed length.

Baidu short URL (page with API): http://dwz.cn/

Short URL processing is good, save capacity, but it is recommended to store a short URL at the same time save a copy of the original URL,

The URL string you use as a unique index is a bad scenario.

You can try to maintain a key-value table, and then write the key to the field you need to guarantee the unique, field with int or bigint, plus a unique index

Add one more field url_md5 the value of the MD5 (URL) to this field, and set a unique index for the Url_md5 field. When querying, the URL to be queried takes md5:select * from table_name where URL_MD5=URL_MD5.
The point to note in this way is that the URL may be different, but the MD5 (URL) is the same, which only needs to be judged by whether the URL in the data table Recordset is the same as the URL you need.

  • 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.