16. Simple SQL optimization of MySQL partition 1

Source: Internet
Author: User

1. Use the Show session status like '%com_%'; You can view the execution frequency of each SQL currently connected show global status like '%com_%'; You can see how often SQL has been executed since the last time MySQL server was booted up to date2. ExplainSelect *  fromtmp; MySQL>ExplainSelect *  fromZi_empwhereTid=  +\g*************************** 1. Row***************************ID:1Select_type:simpleTable: zi_emp Type: AllPossible_keys:NULL              Key:NULLKey_len:NULLRef:NULLrows:2extra:usingwhere    1Rowinch Set(0.00sec)         Ps::type type, all is the least efficient because it means a full table scan index type is indexed full scan range for index range Scan ref for non-unique index or unique index prefix scan eq_ref unique index Scan Const/there is only one matching row in the System single table, such as a user tableNULLNo access to tables or indexes such as:Select 1=1;3. Haha, find a good thing explain extendedSelect *  fromZi_emp; Before looking at the Execute SQL statement, the MySQL optimizer did something about show warnings; MySQL>Show Warnings\g*************************** 1. Row***************************       Level: note Code:1003Message:Select' Bin '. ' zi_emp '. ' Tid ' as' Tid ', ' bin '. ' zi_emp '. ' Tname ' as' Tname ' from' bin '. ' Zi_emp '1Rowinch Set(0.00sec) PS: Yes, you are looking at a complete SQL statement, which means that this is probably the best SQL statement given by MSYQL, which can be learned and reused4. Explain partitionsSelect *  fromZi_empwhereXXXXX can see where the current record's partition is located

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.