Fix performance problems in the dbstore.