generalized and optimized
generalized and optimized

now handles multiple tables and multiple objects. I also broke up the
query depending on the input data which sped up query processing by up
to a factor of 430.

mattgiguere/cedat,mattgiguere/cedat,mattgiguere/cedat