Performance problem: N! database calls