Using count(*) vs num_rows

后端 未结 5 2531
灰色年华
灰色年华 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:00

    It depends on your implementation. If you're dealing with a lot of rows, count(*) is better because it doesn't have to pass all of those rows to PHP. If, on the other hand, you're dealing with a small amount of rows, the difference is negligible.

提交回复
热议问题