---
title: "Count(*) vs Count(1) - SQL Server"  
description: "Count(*) vs Count(1) - SQL Server"  
author: "Ravi Misra"  
published: 2023-04-12  
updated: 2023-04-12  
canonical: https://answers.mindstick.com/qa/99387/count-vs-count-1-sql-server  
category: "database"  
tags: ["database"]  
reading_time: 3 minutes  

---

# Count(*) vs Count(1) - SQL Server

Just wondering if any of you [people](https://www.mindstick.com/news/2295/more-people-need-to-monitor-this-crucial-metric-for-heart-health) use `Count(1)` over `Count(*)` and if there is a noticeable [difference](https://yourviews.mindstick.com/story/5016/chia-vs-basil-seeds-what-s-the-difference) in performance or if this is just a [legacy](https://yourviews.mindstick.com/view/85016/the-legacy-of-vinayak-damodar-savarkar-examining-his-influence-on-hindu-nationalism) habit that has been brought [forward](https://www.mindstick.com/forum/159810/what-happens-during-a-roll-forward-process) from days gone [past](https://www.mindstick.com/articles/13129/great-tools-for-continuing-your-education-past-college)?

The [specific database](https://www.mindstick.com/forum/160935/how-to-setup-a-trace-using-sql-profiler-to-monitor-a-specific-database) is `SQL Server 2005`.

## Answers

### Answer by Jujhar Singh

In SQL Server, both **[COUNT](https://yourviews.mindstick.com/story/4590/10-natural-things-to-increase-your-platelet-count)(*)** and **COUNT(1)** can be used to count the number of rows in a table or a result set. However, there are some differences between the two, and choosing one over the other can have an impact on query performance.![Count(*) vs Count(1) - SQL Server](https://answers.mindstick.com/questionanswer/c5eff174-4f6f-4814-b3b4-e4e00bf1235b/images/e1c0d39a-9716-47c2-96d0-e8b2f2430bed.png)

**COUNT(*)** counts the total number of rows in a table or result set, regardless of whether the individual rows contain any data or not. This means that even if a row has null values in all its columns, it will still be counted by **COUNT(*)**. This is because the asterisk symbol (*) in **COUNT(*)** is a wildcard that includes all columns in the table.

On the other hand, **COUNT(1)** is a shorthand way of counting the rows in a table or result set. It works by counting the number of non-null values in the first column of each row. Since every row in a table or result set will have a value in the first column (even if it is null), **COUNT(1)** will always return the same result as **COUNT(*)**.

So, what is the difference between the two and which one should you use?

The main difference between **COUNT(*)** and **COUNT(1)** is in their query execution plans. When you use **COUNT(*)**, [SQL Server](https://www.mindstick.com/articles/12343/sql-server-2017-ctp-2-0-now-available) has to retrieve all columns of the table or result set to determine the number of rows. This can be slow and resource-intensive, especially if you are working with large tables.

In contrast, **COUNT(1)** only needs to look at the first column of each row to determine if it is null or not. This can be faster than **COUNT(*)**, as it requires less data to be retrieved from disk.

However, the performance difference between the two may not be significant, especially for small tables or result sets. In such cases, either **COUNT(*)** or **COUNT(1)** can be used without any major impact on query performance.

In general, it is recommended to use **COUNT(1)** over **COUNT(*)** as it is more efficient and can potentially improve query performance. However, if you need to count the total number of rows in a table or result set, regardless of whether they contain any data or not, then **COUNT(*)** is the appropriate choice.

In summary, both **COUNT(*)** and **COUNT(1)** can be used to count the number of rows in a table or result set in SQL Server. **COUNT(*)** counts all rows, while **COUNT(1)** counts the number of non-null values in the first column of each row. **COUNT(1)** is generally more efficient and should be used in most cases, but **COUNT(*)** is necessary when you need to count all rows, regardless of their contents.


---

Original Source: https://answers.mindstick.com/qa/99387/count-vs-count-1-sql-server

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
