fix for 1049589 and 1049591
update db more efficiently
Merge pull request #91 from yunli2004/devR2.0

fix for 1049589 and 1049591