Search code examples
mysqldatabaseimportbackup

Same MySQL database import showing different numbers of records


Same database imported 3 three times after empty the entire database and surprisingly every time it shows different number of records. Why?

1st time import: enter image description here

2nd time import: enter image description here

3rd time import: enter image description here

It is not right to trust on Rows count as shown in picture it show approxmiate value as error suggested. So the question is how can we ensure that database is right and no record missing? note: short-cut require can't use count with each table it will lots of time.


Solution

  • MySQL is, surprisingly, really bad at numbers. For InnoDB tables those are often estimates of how many rows it contains and they can be wildly wrong.

    The way it computes the numbers you're seeing is by taking the total size of the table data and dividing by the average row size in bytes. This is usually a good enough approximation of your data, but it can be very misleading, off by a factor of up to 100.

    The only way to know for sure is to do COUNT(*), something that can take some time to compute on a very active table.