Subject RE: [firebird-support] Questions about unique indexes
Author Ann W. Harrison
Various people wrote

> >
> > I want to make the SUBURL a unique one, but since it's a varchar(1024),
> this
> > doesn't work as the column length is too long.
> >
> > Is there anything else I can do from the database side to ensure this field
> > stays unique? Can I accomplish something with triggers?

I wouldn't unless I was sure that the table would stay small. Very
small. Doing a non-indexed lookup on a large table for every insert and
some updates is going to be a nightmare. If you really need to check,
create a third field - int or int64 - and use it to store a checksum of the
URL. Put a non-unique index on that field. Have your trigger check for
matches on both fields. With luck, the optimizer will check on the indexed
value first, then scan the subset for matches on SUBURL.

Regards,


Ann