Stephan Bruijnis .dev

Don't combine unique validation rule with an index

Don't combine unique validation rule with an index

Jul 26, 2022
Mendix, TIL
Database, Performance

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.

Today I learned is a category with short posts on new insights, things I learned, or questions and answers.