rows in mysql explain bigger than real rows

1.1k views Asked by At

DB:Mysql 5.6, Innodb,the index

explain result: explain result

the real data: enter image description here

I'm confused where does the 16462900 come from. When I set 6 wave_no, the rows in explain result is 6: enter image description here

3

There are 3 answers

3
spencer7593 On

The value of rows in the EXPLAIN output is an estimate of the number of rows that will be examined.

It's just an estimate, based on the calculated statistics.

References:

http://dev.mysql.com/doc/refman/5.6/en/explain-output.html

http://dev.mysql.com/doc/refman/5.6/en/innodb-persistent-stats.html

0
Jess Chen On

My college said this because of table fragmentation, you can search it from Google, here is one .

MySQL tables, including MyISAM and InnoDB, two of the most common types, experience fragmentation as data is inserted and deleted randomly. Fragmentation can leave large holes in your table, blocks which must be read when scanning the table. Optimizing your table can therefore make full table scans and range scans more efficient.

Here is the article in official site.

0
Rick James On

Use this 'composite' index to improve performance:

INDEX(com_uid, exchange_state, wave_no)

And remove the FORCE.

The statistics are sometimes that far off. This can especially happen if there are TEXT or BLOB columns, which are stored elsewhere, thereby messing with the arithmetic. Don't worry about it.

You could do ANALYZE TABLE to recalculate the stats, but that might not improve the stats.