Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 811
Muhammad Faizan Khan Avatar asked Oct 17 '25 14:10

Muhammad Faizan Khan


1 Answers

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.

like image 128
tadman Avatar answered Oct 20 '25 06:10

tadman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!