Reorder database hits to limit parameters used.