Technology Sharing

MYSQL 4. MySQL Advanced 8 (Index Optimization and Query Optimization)

2024-07-11

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

What dimensions can be used for database tuning? In short:

  • Index failure, not fully utilized - create index
  • Too many JOINs in associated queries (design flaw or unavoidable requirement)——SQL optimization
  • Server tuning and various parameter settings (buffers, number of threads, etc.) - adjust my.cnf
  • Too much data - separate database and table

Knowledge about database tuning is very scattered. Different DBMS, different companies, different positions, and different projects all encounter different problems. Here we divide it into three chapters for detailed explanation.

Although there are many SQL query optimization techniques, they can be divided into物理查询优化and逻辑查询优化Two big pieces.

  • Physical query optimization is achieved through索引and表连接方式And other technologies are used for optimization. The key here is to master the use of indexes.
  • Logical query optimization is achieved through SQL等价变换Improving query efficiency, to put it bluntly, means that changing the way of writing queries may be more efficient.

1. Data Preparation