Empty query pruning

MSP-8948

Check for new records to eliminate NULLs in queries which means that the
query was unnecessary.  This brings the time down -18.36% to 186.56
seconds from the last commit and a total -28.15% from the original,
unoptimized time.  Timing statistics:
https://docs.google.com/spreadsheet/ccc?key=0Ah1hRHfpRW92dGxDRnN1ajJPWXlUWFBQNTdvWl9KZFE&usp=sharing.