optimizing database queries drill