Muhammad Faizan Khan
Muhammad Faizan Khan

Reputation: 10541

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.

Upvotes: 3

Views: 4113

Answers (5)

Luton Datta
Luton Datta

Reputation: 54

The number you are seeing is approximation. To get the actual number JUST CLICK ON THE NUMBER. You will see the actual number. You do not need to run any query to view actual row number.

Upvotes: 1

tadman
tadman

Reputation: 211560

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.

Upvotes: 11

abhayendra
abhayendra

Reputation: 187

You'll notice that all of the "negative mysql records" This isn't a negative sign its ~, which means approximately. if you want actual count use

SELECT count(*) FROM 'table_name';

Upvotes: 3

mysqlrockstar
mysqlrockstar

Reputation: 2612

Tools like phpmyadmin/adminer always picks the row count from INFORMATION_SCHEMA. In case of InnoDb storage engine the row count is a rough estimate, it is never the exact value. The table_rows which phpmyadmin picks which is never accurate for Innodb

SELECT SUM(TABLE_ROWS) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'table_name';

For exact value we need

SELECT count(*) FROM 'table_name';

For reference: http://dev.mysql.com/doc/refman/5.7/en/tables-table.html

Upvotes: 3

Dario Corsetti
Dario Corsetti

Reputation: 76

I wouldn't rely on comparison of numbers with a tilde (~) as prefix.~ means approximation.

Based on bencoder response to this phpMyAdmin - What a tilde (~) means in rows column? the approximation can vary a lot.

To check the real number of rows imported use: select count(*) from TABLE_NAME

Upvotes: 2

Related Questions