To count how many rows of data a table T has, the usual notation is:
Query A:select Count (*) from T
But you can also use the following statement to check:
Query B:select count (1) from T
The results are usually the same. So where is the difference?
If the T table is a large table, then the query speed will be significantly different. In practice, the T-table has 42 million rows, the use of query B, takes more than 3 minutes, and the use of query A, the time is less than 1 seconds. It is obvious that you must be very cautious on queries on large tables.
So why is query a faster than query B?
Personal analysis that query A does not need to filter, directly with the last row position-the first row position/each row occupies the position. and query B, because each row to be compared to the constant 1, not NULL statistics, so it is slow.
The difference between select COUNT (1) and select COUNT (*)