Sql COUNT Performance Question

Table structure Example:

Id, Integer (PK)
Name, Varchar(100)
Description, Text

I need to know if there is a performance difference between:

SELECT COUNT(*) FROM Example;

and

SELECT COUNT(Id) FROM Example;

Or are there no differences?

+3
source share
4 answers

Differences exist both in performance and in the actual result set.

Executing the COUNT SQL Function

+2
source

Check the plan of explanation: is the result obtained from a table or from metadata (for example, INFORMATION_SCHEMA) ?: The differences are likely to be very minimal.

0
source

, ; , , .

, , : SELECT COUNT (*) FROM
: SELECT COUNT (Id) FROM Example
: SELECT COUNT (1) FROM

0
source

It is worth reading, but, unfortunately, in Russian.

COUNT (*), could it be faster?

A story that is COUNT(*)not as effective as direct access to dm_db_partition_stats.

0
source

Source: https://habr.com/ru/post/1723107/


All Articles