Optimize query and add 'ids_only' parameter for controls.json [story:47414061]