Database work

Database auto optimize added, database auto trim to DATABASE_DEPTH_HOURS
added.