Rewrite select_cell using two cursors for completely lazy evaluation.

This prevents massive result sets from exhausting available memory.