code: function updateSqliteStats(unit){
  	if (count_writes === 1){
  		start_time = Date.now();
  		prev_time = Date.now();
  	}
  	if (count_writes % 100 !== 0)
  		return;
  	var STATS_CHUNK_SIZE = 1000;
  	if (count_writes % STATS_CHUNK_SIZE === 0){
  		var total_time = (Date.now() - start_time)/1000;
  		var recent_time = (Date.now() - prev_time)/1000;
  		var recent_tps = STATS_CHUNK_SIZE/recent_time;
  		var avg_tps = count_writes/total_time;
  		prev_time = Date.now();
  	//	console.error(count_writes+" units done in "+total_time+" s, recent "+recent_tps+" tps, avg "+avg_tps+" tps, unit "+unit);
  	}
  	if (conf.storage !== 'sqlite' || bDbTooBig)
  		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
  			bDbTooBig = true;
  			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