Differences and performance of count (1) count (*) count (col)

Source: Internet
Author: User

Analysis of the differences between count (1) count (*) count (col) and performance count (1) and count ), in addition, the count (col) statistics for all rows are performed for records whose col columns are not empty. If an index exists, indexes can be used regardless of whether col is empty, without an index, you cannot test www.2cto.com [SQL] hr @ ORCL> select count (1) from t; Execution Plan -------------------------------------------------------- Plan hash value: 2966233522 bytes | Id | Operation | Name | Rows | Cost (% CPU) | Time | ------------------------------------------------------------- | 0 | select statement | 1 | 159 (2) | 00:00:02 | 1 | sort aggregate | 1 | 2 | table access full | T | 50356 | 159 (2) | 00:00:02 | explain hr @ ORCL> select count (*) from t; Execution Plan ---------------------------------------------------------- Plan hash value: 2966233522 bytes | Id | Operation | Name | Rows | Cost (% CPU) | Time | ------------------------------------------------------------------- | 0 | select statement | 1 | 159 (2) | 00:00:02 | 1 | sort aggregate | 1 | 2 | table access full | T | 50356 | 159 (2) | 00:00:02 | -------------------------------------------------------------------

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.