Mysql_num_rows VS COUNT Efficiency problem Analysis _php Tutorial

Source: Internet
Author: User
Mysql_num_rows and COUNT (*) can count the total, that can be better?
Or
When do you use Num_rows and COUNT (*) separately?

An intuitive contrast
Test data:
Number of articles: 139,764
Data table Size: 500M

Results:
Fetch_num_rows spents: 35.272329092026
COUNT (*) spents: 0.071956872940063

If the purely statistical quantity is of course count (*)
Fetch_num_rows must traverse the database to get less efficient than count (*)

http://www.bkjia.com/PHPjc/323250.html www.bkjia.com true http://www.bkjia.com/PHPjc/323250.html techarticle Mysql_num_rows and COUNT (*) can count the total, that can be better? or when to use Num_rows and COUNT (*) separately? An intuitive comparison test data: Number of bars: 13976 ...

  • 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.