def batch_qs(qs, batch_size=1000):
    total = qs.count()
    for start in range(0, total, batch_size):
        end = min(start + batch_size, total)
        yield (start, end, total, qs[start:end])
Returns a (start, end, total, queryset) tuple for each batch in the given
dataset/ETHPy150Open dimagi/commcare-hq/corehq/apps/reports/util.py/batch_qs