- Ount (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 COUNT (*)
- If your table has only one field, then count (*) is the quickest.
- COUNT (*) count (1) compares the two. The data field that corresponds to count (1) is mostly still.
- If count (1) is a clustered index, ID, that must be count (1) fast. But the difference is very small.
- Because count (*), automatically optimizes the specified field to that one. So there is no need to count (?), with count (*), SQL will help you to complete the optimized
- Count Detailed:
- COUNT (*) returns the total number of rows that exist in the table, including rows with a value of null, whereas count (column name) returns the total number of all rows except null in the table (columns with default values will also be counted).
- Distinct the column name, the result will be the result of dropping the value null and repeating the data
The difference between count (1) and COUNT (*) in Oracle