Use python to combine queries for faster performance.