Django & Postgres - Index Row Size Exceeds btree version 4 maximum

Viewed 2846

I have defined the following in Django to store an SSL certificate in plain-text PEM format:

class Certificate(models.Model):
    pem = models.CharField(max_length=4096, unique=True, blank=False, null=False)

When populating the table column in Postgres, I'm seeing this error which says the size of the data is too large for the b-tree index:

django.db.utils.OperationalError: index row size 2720 exceeds btree version 4 maximum 2704 for index "app_certificate_pem_key"
DETAIL:  Index row references tuple (1,6) in relation "app_certificate".
HINT:  Values larger than 1/3 of a buffer page cannot be indexed.
Consider a function index of an MD5 hash of the value, or use full text indexing.

Is there a "Django" way to create a unique index based on a hash of my pem column?

1 Answers

It looks like your index width is exceeded. Try to drop the index for the pem field.

Related