replace loop with query in SegmentUnit.delete() (surprisingly improves performance)