Do not make N+1 queries if collection is already loaded

To fix #14917 (and maybe #5990) I'm suggesting to use loaded records if it's possible