Home >Database >Mysql Tutorial >Summarize the points to note about specific types of queries
This section is mainly for some specific types of optimization queries: (1) count query optimization; (2) Related query (3) Subquery (4) GROUP BY and DISTINCT optimization (5) LIMIT paging optimization count query optimization The role of the COUNT() aggregate function: (1) Count the number of values in a certain column, and you can also count the number of rows. It should be noted that when counting column values, the column value must be non-empty (NULL is not counted) (2) Count the number of rows in the result set. When the column value cannot be empty, the number of rows in the table is counted. But to ensure that you must use COUNT() to get the number of rows in the result set. Wildcards will directly ignore all column values and directly calculate the number of rows for optimization. For the MyISAM storage engine, COUNT(*) is very fast when the where query conditions are not limited in a single table, because MyISAM itself has already stored the total number of rows. When there is a where qualification, query statistics are also required. A simple optimization usage example is given below: (
1. High-performance MySQL - Detailed explanation of optimization of specific types of queries
Introduction: This section is mainly about some specific types of optimization queries: (1) count query optimization; (2) Related queries (3) Subqueries (4) GROUP BY and DISTINCT optimization (5) LIMIT paging optimization count query optimization The role of the COUNT() aggregate function: (1) Count the number of a certain column value, and you can also count the number of rows. It should be noted that the column value is required when counting column values. Is non-empty (NULL is not counted) (2) Counts the number of rows in the result set when the column value cannot be empty
##[Related Q&A recommendations]:
The above is the detailed content of Summarize the points to note about specific types of queries. For more information, please follow other related articles on the PHP Chinese website!