Odd sum (1), sum (2), count (1), count (6), count (*) in SQL: Total number of statistics, sumcountSQL statistical functions
The SQL statistical function has count statistics, and uses sum to accumulate the specified field value with sum, but note
The number of records in the database table is:
Sql> Select COUNT (*) from table_name t;
COUNT (*)----------6873
1, using the statistical results of COUNT (*):
Sql> alter session Set Nls_language = "American";
Session altered.
Sql> set timing on;Sql>
Execution effect:
1. Count (1) and COUNT (*) when the table has a larger amount of data, using count (1) is more time-consuming than using count (*) when analyzing the table. From the execution plan, the effect of count (1) and COUNT (*) is the
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
Transferred from: http://blog.csdn.net/sjf0115/article/details/8600599Problem:Given a decimal positive integer n, write down all integers starting with 1, to N, and then count the number of all "1" that appear.For example:N= 2, write down 1, 2.
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
Select count (*), Count (1), and Count (column)
In SQL Server, Count (*), Count (1), or Count ([column]) is perhaps the most common aggregate function. Many people cannot tell the difference between the three. This article will explain the functions,
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
If NULL participates in the aggregation operation, all other aggregation functions except count (*) ignore null. Such as:ID DD1 E2 NULLSelect COUNT (*) from table--the result is 2Select COUNT (DD) from table---result is 1Efficiency issues:When the
[PHP source code reading] count function, php source code count function. [PHP source code reading] count function, php source code count function in PHP programming, when traversing the array, it is often necessary to calculate the length of the
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.