Home > Backend Development > PHP Tutorial > mysql_num_rows VS COUNT efficiency problem analysis_PHP tutorial

mysql_num_rows VS COUNT efficiency problem analysis_PHP tutorial

WBOY
Release: 2016-07-21 15:30:17
Original
1242 people have browsed it

Both mysql_num_rows and count(*) can count the total number, which one is better?
or
When to use num_rows and count( * ) respectively

An intuitive comparison
Test data:
Number of items: 139764
Data table size: 500M

Result:
fetch_num_rows time: 35.272329092026
count(*) time: 0.071956872940063

If the number is simply counted, of course it is count(*)
fetch_num_rows must be traversed through the database. The result is less efficient than count(*)

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/323250.htmlTechArticlemysql_num_rows and count(*) can both count the total number, which one is better? Or when to use num_rows and count(*)? An intuitive comparison. Test data: Number of items: 13976...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template