Re: unique constraint
От | Tom Lane |
---|---|
Тема | Re: unique constraint |
Дата | |
Msg-id | 13949.1334690333@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | unique constraint ("Roberto Caravani" <JFanatiker@gmx.at>) |
Список | pgsql-novice |
"Roberto Caravani" <JFanatiker@gmx.at> writes: > I have a little problem with a unique constraint: > create table meta_data ( > id serial primary key, > type int not null, > data bytea not null, > unique (type, data) > ); > data can be quite large (a few hundred kilo bytes). The unique constraint automatically creates a btree index as I learnedfrom the documentation. The problem is that I get an error when inserting data, that the index is to large. You mean that an index entry is too large, because you have a wide "data" value? The usual hack for that is to put a unique index on some hash of the wide column, trusting that you won't get hash collisions. So for instance create unique index meta_data_unique on meta_data (type, md5(data)); regards, tom lane
В списке pgsql-novice по дате отправления: