avoid n+1 queries issue

@ibawt @qq99 a bit fugly but...