Optimize database operate