I have the following query
SELECT /*+ USE_HASH_AGGREGATION */ id --, count(id) , listagg(type, ', ') within group (order by null) types FROM test group by id
Both type and id are short strings. The execution plan for when I comment out listagg and leave count aggregation in is a HASH GROUP BY (even without the hint) and works fast. With the listagg aggregation Oracle always chooses SORT GROUP BY which is an order of magnitude slower. Is there any reason for that?