SQL tuning is primarily about reducing the number of consistent gets and physical reads.
COUNT (1) is compared with COUNT (*):
If your datasheet does not have a primary key, then count (1) is faster than COUNT (*)If you have a primary key, the
1) count (1) compared to COUNT (*):1. If your data table does not have a primary key, then count (1) is faster than COUNT (*)2, if there is a primary key, then the primary key (Union primary key) as the count of the condition is also faster than
Count1) with Count (*) Comparison: If your data table does not have a primary key, COUNT (1) than COUNT (*Fast If there is a primary key, then the primary key (the Federated primary key) as the count condition is also more than count (*) to be quick
Count (1) compared to count (*):
If your data table does not have a primary key, then count (1) is faster than COUNT (*)
If there is a primary key, then the primary key (the Federated primary key) as the count condition is also faster than
This section is mainly for some specific types of optimization queries: (1) Count query optimization, (2) Correlation query (3) subquery (4) GROUP by and distinct optimization (5) LIMIT paging optimization count query optimizes the effect of the
MySQL learning footprint record 10 -- Summary Data -- data used in this article, such as MAX (), MIN (), AVG (), SUM (), and COUNT ()
mysql> SELECT prod_price FROM products;+------------+| prod_price |+------------+| 5.99 || 9.99 ||
COUNT (*) it returns the number of rows retrieved, regardless of whether they contain null values.SELECT retrieves from one table without retrieving other columns, and when there is no WHERE clause, COUNT (*) is optimized to the fastest return speed.
This section is mainly for some specific types of optimization queries: (1) Count query optimization, (2) Correlation query (3) subquery (4) GROUP by and distinct optimization (5) LIMIT paging optimization count query optimizes the effect of the
Linus the great God again in rant! This time the Spit object is the hot parallel technology (parellism), and it is straightforward to say that parallel computing is a waste of all time ("the whole" let's parallelize "thing is a huge waste Of
Cause: It's too slow to make count (*) statistics on the InnoDB table, so find a way to see if it's going to be faster.
Phenomenon: First look at a few test cases, as follows
First, the test on the Sbtest table
Show CREATE TABLE Sbtest\g1. Row ***
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.