A better analysis of where temporary tables are used in mysql

Source: Internet
Author: User


Recently, I have been suffering from the storage process of returning to the peripheral list for a long time, because the sorting fields are obtained from other tables. Finally, by creating an additional record table, you can record the corresponding records when you sign in at ordinary times. Therefore, when you return to the peripheral list, these fields can be searched directly from the table, and the index is used, so it is very fast. However, another field is real-time, so it must be obtained when the stored procedure is executed. Start preparing to use a temporary table .. group by is used to obtain all the fields and insert them into the temporary table. This operation is indeed very fast. The next time you retrieve these values and sort them, you can directly obtain them from the temporary table based on a condition. -Www.2cto.com-
But it is still very slow. The heap table is used. Because the index cannot be created for a temporary table, the condition value is still relatively slow. Therefore, creating an index is better than creating a real table. A temporary table can be created to store all the data to be used for operations without selecting records based on the conditions. When creating a real table, you must pay attention to the concurrency issue. If the time is not long, we recommend that you use the lock table operation to ensure operation consistency. From the column of kofandlizi

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.