3

in my application, each time I refresh page I get a different data.

After check the code, I guess the problem is with mysql, because in phpmyadmin, each time I refresh page two of my tables changes it's rowcount

I tried to turn off mysql cache and run optimize, check and analyze tables, but no success

It is running with nginx and ubuntu on digitalocean

Leabdalla
  • 656
  • 9
  • 19

1 Answers1

4

Are you running innodb tabels? If so you cannot rely on the table's reported row count--it's just an estimate (a crazy one at that).

Do a select count(primary_key) from table to get the correct count. If that's still showing changing numbers, turn on your db's query log an watch what's going on.

Ray
  • 40,256
  • 21
  • 101
  • 138
  • this query returns always the same count, thanks! the tables are innodb, should I change this? what can cause this problem? yesterday I got the same problem for 2 hours, then it normalized, and now its happening again – Leabdalla Oct 21 '13 at 14:14
  • There is no 'fix', it's just the way innodb stores data that it can't accurately give a row count without running a count query (dont' do a count(*) though). See this for more details: http://stackoverflow.com/questions/8624408/why-is-innodbs-show-table-status-so-unreliable – Ray Oct 21 '13 at 14:17