Don't combine unique validation rule with an index

Posted in Mendix on Jul 26, 2022 · 1 min read

Q: Should I use an index on an attribute if it also has an unique validation rule? For example when I use that attribute a lot when retrieving data?

A: No. When you add a unique constraint on an attribute, you don’t need to add an index on that attribute. Mendix will create an index for that unique constraint. Adding an index on the same attribute will create a duplicate index and impact performance, wasting database resources and generating unnecessary overhead.

It does require that uniqueness validation is set to Database (Project Settings > Runtime).

Checked in Mendix 8.18.18 on PostgreSQL database.