A witness held in the custody of the sheriff as a result of a material witness order must be paid the sum of three dollars per day for each day of confinement in such custody. Such compensation is a county charge and is payable upon release of such material witness from custody or, in the discretion of the court, at any designated times or intervals during the confinement as the court may deem appropriate.