Use statistics from the stats table not Count(*)

Its really not wise to count all the tables so directly use stats table.

Change-Id: I3966cae3efe3b9dc64b1f89b4c818430dbea5348
Merge "Use statistics from the stats table not Count(*)"