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.