Using count(*) vs num_rows

后端 未结 5 2528
灰色年华
灰色年华 2021-02-20 10:20

To get number of rows in result set there are two ways:

  1. Is to use query to get count

    $query=\"Select count(*) as count from some_table where type=

5条回答
  •  深忆病人
    2021-02-20 11:07

    count is much more efficient both performance wise and memory wise as you're not having to retrieve so much data from the database server. If you count by a single column such as a unique id then you can get it a little more efficient

提交回复
热议问题