order of magnitude speedup when we can fit the full cost table in memory