Is using COUNT(*) or SELECT * a good idea?

后端 未结 8 2203
囚心锁ツ
囚心锁ツ 2020-12-10 17:03

I\'ve heard several times that you shouldn\'t perform COUNT(*) or SELECT * for performance reasons, but wasn\'t able to dig up some further informa

8条回答
  •  鱼传尺愫
    2020-12-10 17:55

    COUNT(*) is different from COUNT(column1) !
    COUNT(*) returns the number of records, and does NOT use more resources, while COUNT(column1) counts the number of records where column1 is non null.

    For SELECT, it is different. SELECT * will of course request more data.

提交回复
热议问题