Let nextJobDB.php narrow down the type based on a set.

* This can avoid slower for loops in jobs-loop.sh.

Change-Id: I4d686400dcb83a3c64c14a01100ad6b451542f05
(cherry picked from commit 7eb23ccccd185768bc712608ec9f872c6cc4b671)