Subject Re: [firebird-support] Err -663 "Too many keys defined for index" while trying to create single field index on table with 4 records..
Author Ann W. Harrison
Lester Caine wrote:
> Database with a table with a single Index on the ID. I wanted to add a
> UNIQUE index on four fields but it failed. Two fields worked fine.
> After a backup and restore then the four field index created without the
> error. The one thing that was a problem was a duplicate record which I had
> deleted before getting the 'Too many keys' error. Could it be that the
> deleted records are causing a problem until they are removed?
Probably not deleted records, but if you ended up with something that
rolled back and hasn't been garbage collected, the system transaction
will treat it as if it were committed. The easy solution is to force
garbage collection on the system tables involved by running these queries

select count (*) from rdb$index_segments
select count (*) from rdb$relation_fields
select count (*) from rdb$fields
select count (*) from rdb$indices
select count (*) from rdb$relations

That's probably overkill - the problem is almost certainly in the first
two tables.