Maximizing efficiency for database updating