MySQL Multi-table association query with indexed and not indexed gaps

Source: Internet
Author: User

Here is a simple example to introduce, index in the multi-table query how key!

One, the data is synchronized when there is no index:

1, the query code is as follows (Associated nine times):

2, run time (2 minutes, data about 10,000):

1 Start sync mysqldata:---------------------------Time:£ º 2 : Success sync mysqldata:-------------------------sync data successfully! :-£º

Second: Synchronizing Data when indexed

1. Index Database Scripts

1 KEY ' v_ur_sys_dict_val_dict_id ' (' dict_id ') USING BTREE

Note:key is the index keyword, ' v_ur_sys_dict_val_dict_id ' is the name of the index, ' dict_id ' is the primary key, and the last use of the tree-structured index using BTREE

2, run time-consuming (or run the same script, associated with 9 tables, 1w data, only used for 14 seconds)

1 Start sync mysqldata:---------------------------Time:£ º £ º2 Success sync mysqldata:-------------------------sync data successfully! :-£º

Third, Summary: the use of indexes in the database is critical, otherwise if the data on the millions, then the multi-table query may consume too much resources cause the server to hang up.

MySQL Multi-table association query with indexed and not indexed gaps

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.