Nhãn hiệu của chúng tôi

Impact-Company-Logo-English Black-01-177x54

Chào mừng bạn đến với Trang web của Schneider Electric

Chào mừng đến với trang web của chúng tôi.
		
Hôm nay chúng tôi có thể giúp gì cho bạn?
Approximate Count in Microsoft SQL Server 2019

Issue
The SQL Count(distinct()) function provides the actual row count and may take a very long time to execute on a very large database table.

Product Line
Power Monitoring Expert 7.2.2
Power Monitoring Expert 8.2
Power Monitoring Expert 9.0
Power Monitoring Expert 2020
Power Monitoring Expert 2021
Power Monitoring Expert 2022
Power Monitoring Expert 2023
Power Monitoring Expert 2024

Environment

SQL Server 2012

SQL Server 2016

SQL Server 2019

SQL Server 2022

Cause
The Count(distinct()) function provides the actual row count.  This may take a considerable amount of time with tables containing millions or billions of rows.
This could consume a large amount of time while waiting for the result, if all you require is an approximate row count.

Resolution
*Warning: Irreparable database damage can occur. This procedure should only be performed by users familiar with SQL Server Management Studio.
Databases should be backed up prior to performing this procedure.*

SQL Server 2019 introduces the new function Approx_Count_Distinct to provide an approximate count of the rows. The APPROX_COUNT_DISTINCT function
does not return the actual number of rows with each distinct value, but instead returns an approximate count. The approximate count might be higher or lower
than the actual number. According to Microsoft's documentation, 97% of the time the APPROX_COUNT_DISTINCT function will be within the 2% of the actual value.

Below is an example of how to use this new function:

SELECT APPROX_COUNT_DISTINCT(MyColumn)
FROM [dbo].[MyTable];

The above command can be executed by logging into SQL Server Management Studio, entering the command inside a query window while
replacing both 'MyColumn' and 'MyTable' with the values of the column and table you are interested in.

Schneider Electric Việt Nam

Tìm hiểu thêm
Phạm vi:
Tìm hiểu thêm
Phạm vi:

Bạn cần trợ giúp?

  • Công cụ chọn sản phẩm

    Nhanh chóng và dễ dàng tìm được sản phẩm và phụ kiện phù hợp cho các ứng dụng của bạn.

  • Nhận báo giá

    Bắt đầu gửi yêu cầu bán hàng trực tuyến và chuyên gia sẽ liên hệ với bạn.

  • Nơi mua hàng?

    Dễ dàng tìm nhà phân phối Schneider Electric gần bạn nhất.

  • Trung tâm Hỗ trợ

    Tìm sự hỗ trợ cho mọi nhu cầu của bạn tại một nơi.

  • Tài liệu về Sản phẩm
  • Tải xuống phần mềm
  • Công cụ chọn Sản phẩm
  • Thay thế và thay đổi sản phẩm
  • Trung tâm Hỗ trợ
  • Tìm Văn phòng của chúng tôi
  • Nhận báo giá
  • Tìm Nhà Phân phối
  • Cơ hội nghề nghiệp
  • Hồ sơ doanh nghiệp
  • Báo cáo hành vi sai trái
  • Khả năng truy cập
  • Phòng tin tức
  • Nhà đầu tư
  • EcoStruxure
  • Tìm việc
  • Blog
  • Chính sách bảo mật
  • Thông báo về Cookie
  • Điều khoản sử dụng
  • Change your cookie settings