save counter and offset to db