Home > Database > Mysql Tutorial > body text

Summarize the points to note about specific types of queries

巴扎黑
Release: 2017-06-12 14:12:45
Original
1374 people have browsed it

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

Summarize the points to note about 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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template