Query optimizations.