MySQL database optimization tips What?

  1. Enabling query caching, optimizing the query.
  2. explainYour selectqueries, which can help you analyze performance bottlenecks in your query or table structure. EXPLAINThe results will also tell you your index primary key is how to use, how your table is searched and sorted.
  3. When using a single line of data limit 1, MySQLthe database engine will stop the search after finding a piece of data, rather than continue to check back next line with less data record.
  4. Indexed for the search field.
  5. Use ENUMinstead VARCHAR. If you have a field, such as "sex", "state" or "Department", you know the values of these fields is limited and fixed, then you should use ENUMinsteadVARCHAR。
  6. Prepared Statements, Precompiled statement Prepared Statementslike stored procedures, run in the background of a SQLset of statements, we can use from the prepared statementsget a lot of benefits, whether it is performance problems or security issues. Prepared StatementsYou can check some good bind variables, so you can protect your program will not be " SQLinjection" attack.
  7. Vertical table;
  8. According to business needs, choose the right storage engine.


Transfer: https://xushanxiang.com/2019/11/mysql-optimization-tips.html

Guess you like

Origin www.cnblogs.com/xusx2014/p/11904840.html