Re: BUG #3965: UNIQUE constraint fails on long column values

Поиск
Список
Период
Сортировка
От Gregory Stark
Тема Re: BUG #3965: UNIQUE constraint fails on long column values
Дата
Msg-id 87r6famgev.fsf@oxford.xeocode.com
обсуждение исходный текст
Ответ на BUG #3965: UNIQUE constraint fails on long column values  ("Juho Saarikko" <juhos@mbnet.fi>)
Список pgsql-bugs
"Juho Saarikko" <juhos@mbnet.fi> writes:

> It is propably impossible to fix this in a simple way, since it is an
> inherent result of the underlying storage specification rather than a mere
> programming error, so the documentation needs to be updated to warn about
> this.

Point taken.


> I suggest implementing unique hash indexes and automatically creating one
> (and turning the b-tree index into a non-unique one) when a large value is
> inserted to fix this. Alternatively, fix b-trees so they can handle large
> values; however, a hash index should be far more efficient for this specific
> case, since the size of a hash is independent of pre-hash data size.

With expression indexes you can do this yourself with something like
 CREATE INDEX pk_hash on tab ((hashtext(safe)))

We can't do this automatically since it wouldn't enforce the UNIQUE
constraint. Conceivably we could actually do something about that but there's
nothing like that now.

We have hash indexes too but in practice a btree over a hash seems to work
just as well or better.

--
  Gregory Stark
  EnterpriseDB          http://www.enterprisedb.com
  Ask me about EnterpriseDB's PostGIS support!

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Zdenek Kotala
Дата:
Сообщение: Re: Bug (#3484) - Missing pg_clog/0AE6
Следующее
От: Tom Lane
Дата:
Сообщение: Re: BUG #3966: problem with implicit cast array parameter