I don't think such a thing is supplied. You would probably start with something like for i in `seq 1 100`; do mysql -e 'select sum(size) from mail_item where change_date > 20120601000000 and type=5 and volume_id in (1,2,3)' mboxgroup$i done Accounting for compression and minimum block size is left as an exercise for the reader.