What is the best (and most performant) implementation to ensure there are no duplicate DOM instance names for a specific definition, taking into account that we need to support CRUD actions in bulk?

Hi Joey, I’m not sure if it’s the most performant, but I created a script which is executed on DOM instance action settings – OnUpdate (if needed) and OnCreate.
There, with a simple automation script, I check if there is a duplicate name. It’s also executed for each DOM instance individually, which comes with a pitfall, though.
Because the scale of my DOM Definition is not as large as yours, I could afford fetching all DOM instances to check if the name exists.
In your case, you need a “small” caching mechanism.
I have tested a bit with a static Collection or a Set of all names in the script, and it turned out to be working fine, but creating a re-population and synchronization method (in case of process crash, DMA restart, etc.) would be like carrying water to the sea, as I have no more than 200 DOM instances. But that could work in your case.
Another idea are memory files, but I don’t know how performant would they be with the scale you’re operating with. It’s a shot in the dark.
Hope this helps even a bit.
Hi Joey,
In general, it is recommended to avoid situations where DOM data like the name or a value of a field needs to be unique, as this will pretty much always mean an extra read check will need to be done. A DOM instance already has an ID that is guaranteed to be unique.
If this unique name field is needed, the only way to ensure this would be unique is to do a read check to see if there are already instances using that name. If the creates (or updates if this could impact the name) are done in bulk, the read call could also check multiple names at once using OR operators. (Note that cross-DMA uniqueness cannot be guaranteed if an instance with potentially the same name is created on another agent before the other with that name is fully indexed in the DB)
Caching could speed up things, but as mentioned by Benjamin, that requires you to know all names, which means you would need to read out all instances for the definition. If you expect that to be more than a few thousand of instances, this is not recommended. During the runtime of the solution, you could potentially keep a list of known-in-use names of the instances that were created during that runtime. If it is on that list, you could fail early. Not sure if that will be worth it in your case, however.

Would it be a valid feature request to be able to indicate what fields in a DOM definition are expected to be unique (across instances using that definition)?

That could in theory be something that could be made configurable. However, since this can drastically impact the create/update performance, (and considering the note about the cross-DMA limitation), I fear the team would be hesitant to make that available as a core feature.
To be more specific, let's assume there are already 100K of these instances, and 10K instances need to be created or updated.