Re: BUG #1748: Unique contraints cannot be added to long text fields

From: Alvaro Herrera <alvherre(at)surnet(dot)cl>
To: Greg Steffensen <greg(dot)steffensen(at)gmail(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #1748: Unique contraints cannot be added to long text fields
Date: 2005-07-03 16:09:05
Message-ID: 20050703160905.GA15445@surnet.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Sat, Jul 02, 2005 at 05:20:29PM +0100, Greg Steffensen wrote:

> I'm storing SVG files, which can be many kilobytes long, in a text field.
> When I try to add a unique contraint to that field, or try to add a row to a
> table that already has had the unique contraint applied, I get errors like
> the following:
>
> ERROR: index row requires 15528 bytes, maximum size is 8191
>
> Evidently, the unique constraint creates an index, but the index can't
> handle large field sizes.

Yes, that's a known limitation -- you cannot store arbitrarily large
fields in an index. Even if it was possible I don't think it'd be a
good idea from an efficiency POV. You may want to create an index in a
digested version of the file instead (SHA-1, say, or MD5).

--
Alvaro Herrera (<alvherre[a]surnet.cl>)
"El conflicto es el camino real hacia la unión"

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Karsten Desler 2005-07-03 16:49:20 Re: BUG #1736: endless loop in PQconnectdb
Previous Message Tom Lane 2005-07-03 15:57:21 Re: BUG #1736: endless loop in PQconnectdb