N+1 and redundant queries: An exhaustive guide