Automatic collection of statistics