mysql-indexing technique for left-prefixed columns that are not easily distinguishable

Source: Internet
Author: User
Tags crc32

Example: http://www.sina.com,http://www.baidu.com

The first 10 characters are the same, indexing starts with the 11th character and is a waste of resources. Here are two tips to solve this problem:

1. Reverse

Sort data in reverse order: moc.anis.www//:p TTH, so the invalid length is reduced when indexing is established.

2. Pseudo-hashing techniques

The IP address we stored in the database is as follows,

ID URL

1 http://www.baidu.com

Now change the table structure to the following:

ID URL URLCRC

1 http://www.baidu.com 9900090-90-8

Where URLCRC is the value computed from the PHP built-in function CRC32. Where CRC32 is a hashing algorithm that can count strings as 32-bit integers.

mysql-indexing technique for left-prefixed columns that are not easily distinguishable

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.