MySQL optimization solution

Source: Internet
Author: User
SELECT * and SELECT fields are optimized. Let's test it. My test database contains 0.26 million records. Query the number of columns: SELECTCOUNT (*) FROMinformation_schema.columnsWHEREtable_schemalezhi_dataANDtable_namedemo_jobs_store; 43 columns are returned. This number is used as the number of tests.

SELECT * and SELECT fields are optimized. Let's test it. My test database contains 0.26 million records. Query the number of columns: select count (*) FROM information_schema.columns WHERE table_schema = lezhi_data 'AND table_name = 'demo _ jobs_store'; 43 columns are returned. This number is used as the number of tests.

SELECT * and SELECT fields are optimized.

Let's test it. My test database contains 0.26 million records.

Query the number of columns:

Select count (*) FROM information_schema.columns WHERE table_schema = "lezhi_data 'AND table_name = 'demo _ jobs_store ';

43 columns are returned. This number should have a preliminary effect as the test data.

Let's try to query a SELECT field to see the response time:

We can see that a field is executed for 7.724 seconds.

Let's execute two more fields to check the effect.

If there are two fields, the time is 15 seconds.

We can add more fields. <喎�"" target="_blank" class="keylink"> VcD4KPHA + pgltzybzcm9 "" alt = "">

We can see that the time is as long as 29 seconds.

From the above, we can see the huge difference in execution time. PS. The red box of my first image is incorrect.

Therefore, in the actual application process, we try to SELECT the fields we need as much as possible.

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.