Little optimization for the api sql writes.