Oracle COUNT(1) vs COUNT(*) Explained
In Oracle, both COUNT(1) and COUNT(*) are aggregate functions used to calculate the number of rows, but they have some slight differences between them.
- COUNT(1) will calculate the count of 1 for each row, and then return the number of rows with non-null values. This method is faster as it only needs to check if one value in each row is not null.
- COUNT(*) will calculate the number of rows including NULL values. This method may be slower because it needs to check every column of each row for empty values.
In most cases, the results of using COUNT(1) and COUNT(*) are the same. However, for performance optimization purposes, it may be beneficial to use COUNT(1) to obtain faster query results.