MySQL is an SQL statement optimization, what to do with

Source: Internet
Author: User
An SQL statement optimization for MySQL
SELECT t_wenzhang.contents, T_wenzhang.createtime, T_wenzhang.title,t_wenzhang.pagepath from T_wenzhang left JOIN T_ Keys on t_keys.id = T_wenzhang.keyword where SUBSTRING (KEYP, 1, 1) = ' "+ Zimu +" ' ORDER BY createtime Desc






Above the T_wenzhang table 4 W data, T_keys 3W, how this executes in + + seconds! If and optimization!
------Solution--------------------
The first is to index the 4 fields of T_keys.id,t_wenzhang.keyword,keyp,zimu
Second, if it's slow, try to change the engine.
Finally, you can use Explan to help select better indexes and write more optimized query statements!
  • 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.