Java Web Lightweight Development Interview Tutorial reading notes: The factors we need to weigh when building an index

Source: Internet
Author: User

Scene one, the size of the data table is small, thousands of rows, even if the index is not built, the return time of the query statement is not long, then the significance of the index is not big. Of course, if the thousands of rows, the index occupies less space, so in this case, at most, belong to the "cost-effective" is not high.

Scene two, a product table has millions of items of information, at the same time every day at a point, to update about 100,000 of the product information, and now use the WHERE statement to query a particular product (such as WHERE name = ' XXX ') is very slow. Indexing can be built to improve query efficiency, but it is time-consuming to rebuild the index every day when data is updated.

This requires a comprehensive consideration, and even the ability to delete the index before updating, and then rebuilding it.

Scenario three, as can be seen in Figure 2.1, because the data table ID values are not the same, so the index can play a relatively large role. Conversely, if a field has a high repetition rate, such as a gender field, or if most of the value of a field is empty (null), it is not recommended to Jianjian the word index.

Please remember that there must be a business need to build the index. For example, in a commodity table, we often have to query according to name, if there is no index, query speed is very slow, then we need to build an index. However, in project development, it is not necessary to index a number if it is not often queried according to the product number.

Finally, the index is to pay a price, nothing to build, at the same time on a table also can not build too many indexes.

Read the Java Web Lightweight Development Interview tutorial for more information

https://baike.baidu.com/item/Java%20Web%E8%BD%BB%E9%87%8F%E7%BA%A7%E5%BC%80%E5%8F%91%E9%9D%A2%E8%AF%95%E6%95% 99%e7%a8%8b/22038502?fr=aladdin

Java Web Lightweight Development Interview Tutorial reading notes: The factors we need to weigh when building an index

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.