Which of the following statements does SELECTCOUNT (1) and SELECTCOUNT (*) have good performance?

Source: Internet
Author: User
Which of the following statements does SELECTCOUNT (1) and SELECTCOUNT (*) have good performance? Today, I met someone in an article I wrote and asked if the statistical information could not be updated. Isn't that the address of this article wrong when the statistical data is obtained: previously, I thought SELECTCOUNT (*) was based on statistics, but I thought about it later. This is definitely not true.

Select count (1) and select count (*) which has good performance? Today, I met someone in an article I wrote and asked if the statistical information could not be updated. Isn't that the address of this article wrong when the statistical data is obtained: previously, I thought that select count (*) was based on statistics, but I thought about it later.

Select count (1) and select count (*) which has good performance?

Today I met someone who asked me in a previous article

If the statistics have not been updated, isn't it wrong?

Address of this article:

Previously, I thought that select count (*) was based on statistics, but I thought about it later. This is definitely not

How does sqlserver count select count ??

In fact, SQLSERVER is also a scan method.

You can also take a look at allocation scan and range scan in SQLSERVER.

However, we will not discuss whether it is allocation scan or range scan. We all know that SQLSERVER is using the SCAN method.

Clustered index table

The SQL script is as follows:

Ct1 (c1 INT, c2 VARCHAR (2000); t1c1 ON ct1 (c1);) ct1, 2000) ct1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.