MySQL Optimization method

Source: Internet
Author: User

MySQL Optimization method:
  1. Use index:
    There is no difference between indexed and indexed advantages:
    When a table has a large number of records, to query the table, if the index is not used, the search information method is a full table search, is to take all records one by one out, and the query criteria for one by one comparison, and then return to meet the criteria of the record, which will consume a lot of database system time and cause a lot of disk I/O operations If an index is established for some fields in the table, and then the index values matching the query criteria are found in the index, the corresponding records in the table are found quickly by ROWID (equivalent page numbers) saved in the index.
    Disadvantages:
    When the data in the table is added, deleted and modified, the index is also maintained dynamically, reducing the maintenance speed of the data.
  2. To refine the query statement:
    Query, you can not * do not have *, as far as possible to write the full field name;
  3. Transaction:
    Its purpose is either that each statement in the statement block succeeds or fails. In other words, the consistency and integrity of the data in the database can be maintained. Things begin with the BEGIN keyword, and the commit keyword ends. When a SQL operation fails, the rollback command can restore the database to the state it was in before begin.
  4. Use connection (join) instead of subquery (sub-queries)
  5. Select the most applicable field properties:

  6. Table optimization:
    The table field is not NULL as much as possible;
    Table queries with fixed field lengths are faster.

MySQL Optimization method

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.