Quick way to search through loads of dossiers

Hi, In our application, we create new dossiers, and in those dossiers we can add different parties. When saving a party, a check is done to see if the same party (based on zipcode / number or streetname) is used in other dossiers, as a sort of fraud detection. However, we currently have about 1.8 million dossiers in our app. As you might guess, saving a party (and checking for duplicates) takes a lot of time, time you don't expect when 'just adding a party to a dossier'. When executing a similar query in the database environment, it only takes a second (as expected) Any tips on how to improve this? I'd be happy to provide more information if needed. Thanks in advance
1 answers

Create an index on zipcode + number. Domain model: open entity, click on tab indexes, add.

Besides that you can optimize the database.