The table status of Mysql shows more than 20, 000 records, but count (*) shows 0

as shown in the figure below, there are obviously more than 20, 000 records in the table, but 0 is displayed using count (*). Is it locked? How to unlock it?

mysql> show table status like "md_org" \G
*************************** 1. row ***************************
           Name: MD_ORG
         Engine: InnoDB
        Version: 10
     Row_format: Dynamic
           Rows: 26553
 Avg_row_length: 337
    Data_length: 8962048
Max_data_length: 0
   Index_length: 5832704
      Data_free: 4194304
 Auto_increment: NULL
    Create_time: 2018-08-27 11:09:17
    Update_time: NULL
     Check_time: NULL
      Collation: utf8_general_ci
       Checksum: NULL
 Create_options:
        Comment:
1 row in set (0.01 sec)

mysql> select count(*) from md_org;
+----------+
| count(*) |
+----------+
|        0 |
+----------+
1 row in set (0.04 sec)
May.02,2021

Thank you for the invitation.
this select count (*) from md_org is just a query, has nothing to do with locks, and is not locked.

Rows:26553 is a rough statistic and is not guaranteed to be accurate. The exact number of rows is obtained using selct count (xxx).

if it is found to be 0, it means that the actual number of rows in the table is 0.

< hr >

I will restore your situation:
you open the transaction, and then insert data constantly, inserting more than 20,000 pieces of data. At this time, the rows in show table status will see the more than 20,000 pieces of data you inserted, but you accidentally close the x and drop the window, resulting in the transaction not committing. There is no such data in the actual table (mysql will not intelligently update the number of rows entries, it is just a rough statistic.) It's not necessary.

Menu