How does Mysql store Url strings?

Source: Internet
Author: User
How does Mysql store different URLs? Because I need to use the url as the only index and use it for query later, it is of little significance to add a short index. Is there a good way to convert a long string into a short string or number for storage (or other methods), or use Mysq...

How does Mysql store different URLs?

Because I need to use the url as the only index and use it for query later, it is of little significance to add a short index.
Is there a good way to convert a long string into a short string or number for storage (or other methods), or is it a wrong choice to use Mysql storage itself?

Reply content:

How does Mysql store different URLs?

Because I need to use the url as the only index and use it for query later, it is of little significance to add a short index.
Is there a good way to convert a long string into a short string or number for storage (or other methods), or is it a wrong choice to use Mysql storage itself?

The Url should not have been indexed. If the string index is not completed properly, it will be very slow. What's more, you still need the Url.

If you still want to store URLs with a long Url and want to shorten the string, you can use the short domain name Api to shorten the Url

The access effect is the same.

Original Web site: http://music.baidu.com/song/124380645short Web site: http://dwz.cn/Kn8Ep

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

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

The short website can be processed to save the capacity. However, it is recommended that you store the short website and save a copy of the original website,

Using a Url string as a unique index is an error.

You can try to maintain a key-value table, and then write the key into a unique field that you need to ensure. Use int or bigint to add a unique index to the field.

Add the url_md5 field to save the md5 (url) value to this field and set a unique index for the url_md5 field. When querying, the url to be queried is md5: select * from table_name where url_md5 = URL_MD5.
Note that the url may be different, but the md5 (url) is the same. In this case, you only need to determine whether the url in the data table record set 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.