will show table status display exact rows in the table?

后端 未结 2 1275
抹茶落季
抹茶落季 2021-01-25 14:34

I have a table in DB and it is approx 90 GB in space. I tried to count no of rows in the table select count(idNewsNotification) from notification and it resulted <

2条回答
  •  长情又很酷
    2021-01-25 15:13

    The fact that your count took an hour implies that you're running InnoDB (which doesn't cache this data).

    As such, the table status is an approximation based on other factors, and is not to be trusted.

    The count(*) would be accurate, but a pain to wait for.

    From the doc:

    Some storage engines, such as MyISAM, store the exact count. For other storage engines, such as InnoDB, this value is an approximation, and may vary from the actual value by as much as 40 to 50%. In such cases, use SELECT COUNT(*) to obtain an accurate count.

提交回复
热议问题