The difference between count (1) and COUNT (*) in Oracle

Source: Internet
Author: User

    1. Ount (1) compared to count (*):
    2. If your data table does not have a primary key, then count (1) is faster than COUNT (*)
    3. If there is a primary key, then the primary key (the Federated primary key) as the count condition is also faster than COUNT (*)
    4. If your table has only one field, then count (*) is the quickest.
    5. COUNT (*) count (1) compares the two.   The data field that corresponds to count (1) is mostly still.
    6. If count (1) is a clustered index, ID, that must be count (1) fast.   But the difference is very small.
    7. Because count (*), automatically optimizes the specified field to that one. So there is no need to count (?), with count (*), SQL will help you to complete the optimized
    8. Count Detailed:
    9. COUNT (*) returns the total number of rows that exist in the table, including rows with a value of null, whereas count (column name) returns the total number of all rows except null in the table (columns with default values will also be counted).
    10. Distinct the column name, the result will be the result of dropping the value null and repeating the data

The difference between count (1) and COUNT (*) in Oracle

Related Article

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.