Fix n+1 query bug created by #d04542a #20