is SELECT COUNT(*) expensive?

后端 未结 7 1789
小蘑菇
小蘑菇 2021-01-13 00:16

Do you think it\'s a good idea to count entries from a really big table (like 50K rows) on each page load?

SELECT COUNT(*) FROM table

Right

7条回答
  •  庸人自扰
    2021-01-13 00:53

    It can be. According to this forum PostgreSql will do an entire scan of the database to figure out the count.

提交回复
热议问题