HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

COUNT(*) on InnoDB whenever phpMyAdmin loads

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
innodbwheneverphpmyadminloadscount

Problem

It's a known issue that innodb is slow in

SELECT count(*) FROM Table


Hence I avoided that. But I notice that whenever I login to phpmyadmin, it will automatically execute a count() for my innodb table with 19k rows, which can take up to a minute to execute. Yet it doesn't initiate such count() for the other innodb table with 4 million rows.

Another clue, in phpmyadmin, under the Records column, the number of records for the 19k-row table is showing the exact value whereas the 4-million-row table is showing an approx.

I understand innodb table gives an estimation of the row count. But it seems that for smaller table, in this case with 19k rows, phpmyadmin decides to do a count(*) instead of just giving an estimation.

Question is, is there a way to stop phpmyadmin from doing such count on my innodb table? It's okay to just give an estimation instead of doing an expensive row count whenever I refresh my phpmyadmin screen.

Solution

Edit config.inc.php, and change the setting for MaxExactCount.

$cfg['MaxExactCount']
Type: integer
Default value: 500000

For InnoDB tables, determines for how large tables phpMyAdmin should get the
exact row count using SELECT COUNT. If the approximate row count as returned
by SHOW TABLE STATUS is smaller than this value, SELECT COUNT will be used,
otherwise the approximate count will be used.

Context

StackExchange Database Administrators Q#1508, answer score: 3

Revisions (0)

No revisions yet.