Menu
About me Kontakt

Which is faster in SQL - count(1) or count(*)? Plus an explanation of how it works

The article discusses the performance of two counting methods in databases: COUNT(*) and COUNT(1). The author explores which of these methods is faster and the reasons behind it. Both methods are used to count rows in query results, but they have different approaches to achieving this task. The differences in handling all rows versus rows containing NULL values are detailed in the article. Additionally, specific examples and performance test results are provided, indicating the factors affecting the speed of these operations. The conclusions drawn from the research can assist developers in optimizing their database queries and understanding how differences in queries can impact performance.