eliminate unlimited 'select first value' queries