更新时间:2022-04-24 22:41:32
创建[UNIQUE | FULLTEXT | SPATIAL] INDEX index_name [index_type] 开启tbl_name(index_col_name,...) [index_type]
CREATE [UNIQUE|FULLTEXT|SPATIAL] INDEX index_name [index_type] ON tbl_name (index_col_name,...) [index_type]
index_col_name: col_name [(长度)] [ASC | DESC]
index_col_name: col_name [(length)] [ASC | DESC]
index_type: 使用{BTREE |哈希}
index_type: USING {BTREE | HASH}
检查是否真的必须选择所有表中的每一列?如果不是,请确保仅选择所需的列,避免使用 select *
仔细检查是否确实需要左联接,如果不需要,请使用INNER JOIN.
Double check if you really need LEFT JOINS, if no, use INNER JOINs.
如果在完成查询调整后仍然存在性能问题,请考虑对模式进行规范化以消除联接
If performance is still an issue after you're done tweaking your query, consider denormalizing your schema to eliminate joins
您可能还需要考虑通过使用诸如sphinxsearch和memcached之类的缓存应用程序来减少数据库的负载
You may also want to consider reducing the load on the database by using caching applications like sphinxsearch and memcached
检查所有联接都不是视图联接,而不是实际表联接
Check none of your joins are to views rather than actual tables
参考: