What does “select count(1) from table_name” on any database tables mean?

前端 未结 9 601
被撕碎了的回忆
被撕碎了的回忆 2020-12-22 18:38

When we execute select count(*) from table_name it returns the number of rows.

What does count(1) do? What does 1 signify here

9条回答
  •  遥遥无期
    2020-12-22 19:08

    Depending on who you ask, some people report that executing select count(1) from random_table; runs faster than select count(*) from random_table. Others claim they are exactly the same.

    This link claims that the speed difference between the 2 is due to a FULL TABLE SCAN vs FAST FULL SCAN.

提交回复
热议问题