is SELECT COUNT(*) expensive?

后端 未结 7 1723
小蘑菇
小蘑菇 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:51

    COUNT(*) isnt an expensive operation, it dosent actually return the data just looks at the indexes. You should be fine even on a 50k table.

    If you experience issues in loading it would be simple to retractor and optimise at that that point.

提交回复
热议问题