func init() { // Add index on FQDN to speed up searchs. FQDN will be a unique field in database mongodb.RegisterIndexFunction(func(database *mgo.Database) error { index := mgo.Index{ Name: "fqdn", Key: []string{"fqdn"}, Unique: true, DropDups: true, } return database.C(domainDAOCollection).EnsureIndex(index) }) // Add index on nameserver.lastokat to speed up the query that check the domains that // need to be notified. We don't use laststatus because the selectivity is low, // according to http://docs.mongodb.org/manual/tutorial/create-queries-that-ensure- // selectivity/ mongodb.RegisterIndexFunction(func(database *mgo.Database) error { index := mgo.Index{ Name: "nameservers", Key: []string{"nameservers.lastokat"}, } return database.C(domainDAOCollection).EnsureIndex(index) }) // Add index on dsset.lastokat to speed up the query that check the domains that need to // be notified. We don't use laststatus because the selectivity is low, according to // http://docs.mongodb.org/manual/tutorial/create-queries-that-ensure- selectivity/ mongodb.RegisterIndexFunction(func(database *mgo.Database) error { index := mgo.Index{ Name: "dsset", Key: []string{"dsset.lastokat"}, } return database.C(domainDAOCollection).EnsureIndex(index) }) }
func init() { // Add index on StartedAt to speed up searchs. StartedAt will be a unique field in // database, so we cannot have two scans starting at the same time. One problem is that // the scan is only going to realize the problem after scanning all domains mongodb.RegisterIndexFunction(func(database *mgo.Database) error { index := mgo.Index{ Name: "startedat", Key: []string{"startedat"}, Unique: true, DropDups: true, } return database.C(scanDAOCollection).EnsureIndex(index) }) }