document database optimizations