Uses iter([]) instead of empty_iter.
Added emre's support to disable caching for the queries contain ordered by random.