MySQL Count (*) and Count (column) rate

Source: Internet
Author: User

  1. COUNT (*) is typically an index scan of a primary key, and Count (column) does not necessarily
  2. COUNT (*) is the total number of records in the statistics table, count (column) is the number of records for all eligible columns in the tables
  3. Count, if there is no where limit, MySQL directly return to save the total number of records, and there is a where limit, always to the MySQL full table traversal
  4. If the column in Count (column) is a primary key, Count (column) is faster than COUNT (*), otherwise, COUNT (*) is fast
  5. In any case, select COUNT (*) from table is the best choice
  6. Minimize select COUNT (*) from table where column = ' value ' such a query
  7. Eliminate the appearance of select Count (column) from table
  8. The offset of the column determines the performance, the higher the column, the greater the cost of access, the count (*) algorithm and the offset, so count (*) the fastest, count (the last column) slowest

MySQL Count (*) and Count (column) rate

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.