Hi David and Howard,
there is a cause for this and it's that the uniqueness cannot be guaranteed because fields can contain empty strings and those break uniqueness.
This is caused by a historic problem in the DB layer for old MySQL versions and since then we have all the varchar(xxx) fields with a default '' instead of using proper NULLs.
So, something like that:
create table test (
id bigint(10) not null primary key auto_increment,
shortname varchar(100) not null default '',
fullname varchar(255) not null default '');
create unique index test_uix on test (shortname);
insert into test (fullname) values ('One fullname');
insert into test (fullname) values ('Another fullname');
simply breaks, with duplicate key found error.
This is more noticeable with the idnumber field (
MDL-14084) because it's optional in the course configuration page, but internals are the same for both fields.
Until we switch to proper NULLs in those fields (unique indexes use to ignore NULLs so it's safe to have them in more than one record), we only can make application checks, instead of DB checks.
About performance... well... I would measure it as really minor...
So I'm going to close this as won't fix, due to the reasons above. Feel free to reopen, comment or whatever.
Thanks and ciao