Consider this (partial) model:
I have multiple threads and lists of strings that should be stored, if the particular string don't exist. Currently i have a ugly bad implementation for this that just checks for every string if it exists and add it if it don't. The string sets -to check and to insert - are quite large (e.g. 8000 strings at once). I would like to do something like this for performance reasons: Get all strings that don't exist in one batch - insert all entities with new strings in one batch. I have multiple worker threads and sometimes they have the same string which should be inserted. To two inserts with the same string are executed. One of them fail with a unique constraint violation. How can this be avoided / handled best? |
Hello Thomas, I'd start with the following pattern:
Hope that helps. |