db: trigger commits on either time or number-of-queries limits