code: function updateSqliteStats(){
  	if (count_writes % 100 !== 0)
  		return;
  	db.query("SELECT MAX(rowid) AS count_units FROM units", function(rows){
  		var count_units = rows[0].count_units;
  		if (count_units > 500000) // the db is too big, anaylze will lock db for long time,skip it from now on.
  			return;
  		readCountOfAnalyzedUnits(function(count_analyzed_units){
  			console.log('count analyzed units: '+count_analyzed_units);
  			if (count_units < 2*count_analyzed_units)
  				return;
  			count_units_in_prev_analyze = count_units;
  			console.log("will update sqlite stats");
  			db.query("ANALYZE", function(){
  				db.query("ANALYZE sqlite_master", function(){
  					console.log("sqlite stats updated");
  				});
  			});
  		});
  	});
  }
docs: update stats for query planner