In the constructor of {{org.hibernate.query.sqm.internal.ConcreteSqmSelectQueryPlan}} we currently always choose {{ListResultsConsumer.UniqueSemantic.ALLOW}}, but it would be better to use this instead:
{noformat{NONE}sqm} if we know for sure that the cardinality is preserved.containsCollectionFetches() ? ListResultsConsumer.UniqueSemantic.ALLOW : ListResultsConsumer.UniqueSemantic.NONE{noformat}
The deduplication showed up on some flame graphs and I realized that in that particular case it is not even necessary, because only collection join fetches alter the cardinality such that duplicates are possible. Maybe non-attribute joins could alter the cardinality as well, so it might be worth being pessimistic about this for now. We could detect some non-cardinality altering cases though if we want. |
|