Get statistics from database
Fix small bug in MySQL backend