MDL-39725 database: Add statistics collection functions