Optimize IS EMPTY predicate to skip non-optional associations at the end of a path
Not sure if this is easily doable, but I just noticed that a predicate like collection.assocation IS EMPTY will produce a left join for the collection and the check in an exists subquery if an association join would be possible. This is correct but not very performant if we know that the assocation is non-optional. It would be best if we could reduce this to collection IS EMPTY if somehow possible.
This will require a few changes in the JoinManager probably. The path expression knows it is used in a collection function so we know which paths to process there.
The idea is, after resolving the root, we determine the path result type and try to find a singular non-optional path back to a plural attribute. If we find that, we alter the path to end at the plural attribute instead. After that, we continue with the normal implicit join procedure.