Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

django postgresql OperationalError: index row size xxx exceeds maximum yyy

I am trying to learn a bit of django and trying to insert some values in a database (using model forms), but this seems failing citing:

django.db.utils.OperationalError: index row size 3008 exceeds maximum 2712 for index "appname_mymodel_ggg_like"

My models are quite simple and look like so:

class myModel(TimeStampedModel):

    fff =  models.URLField(db_index=False, blank=False,primary_key=False) 
    ggg = models.TextField(db_index=False, blank=False,primary_key=False)
    mj = models.BooleanField(db_index=False, blank=False, primary_key=False,  default=False) # req field

def __unicode__(self):
    return self.fff

Does this mean that the string is long (yes it is, but not a 1MB string or anything)? This is the reason I was using text field.. but this does not seem to help.

Any hints would be appreciated..

like image 915
AJW Avatar asked Nov 10 '22 09:11

AJW


1 Answers

If anyone gets here through the error message, for me it was this unresolved bug.

Basically a django TextField can be large in size, but if we make it unique as well, the uniqueness check can break.

A suggested "fix" was using the md5 hash for the uniqueness check.

like image 145
David Schumann Avatar answered Nov 15 '22 07:11

David Schumann