replace large batch database query with local cache for improving
performance