Speed up query from about 3.5 minutes to 43 seconds.