Reduce offchain database costs

@Jenya Piskunov write some details here...