Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django&;Postgres-索引行大小超过btree版本4的最大值_Django_Postgresql - Fatal编程技术网

Django&;Postgres-索引行大小超过btree版本4的最大值

Django&;Postgres-索引行大小超过btree版本4的最大值,django,postgresql,Django,Postgresql,我在Django中定义了以下内容,以明文PEM格式存储SSL证书: class Certificate(models.Model): pem = models.CharField(max_length=4096, unique=True, blank=False, null=False) 在Postgres中填充表列时,我看到一个错误,即数据的大小对于b树索引来说太大: django.db.utils.OperationalError: index row size 2720 exce

我在
Django
中定义了以下内容,以明文PEM格式存储SSL证书:

class Certificate(models.Model):
    pem = models.CharField(max_length=4096, unique=True, blank=False, null=False)
Postgres
中填充表列时,我看到一个错误,即数据的大小对于b树索引来说太大:

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.

是否有一种“Django”方法可以基于my pem列的哈希创建唯一索引?

看起来您的索引宽度超出了范围。尝试为pem字段添加索引。

好吧,我仍然希望使用索引。在这种情况下,添加另一个字段,类似于
pem_short=models.CharField(max_length=2048,unique=True,blank=True,null=True)
然后在您看来将其指定为pem字段的前2000个字符。然后通过短字段进行索引。