开发者

Huge table in a Django?

开发者 https://www.devze.com 2023-01-08 22:36 出处:网络
if you have millions of entries in a mysql table, you often want to manipulate it with a hexadecimal primary key (in practice you do a md5(name)). The queries are then much faster.

if you have millions of entries in a mysql table, you often want to manipulate it with a hexadecimal primary key (in practice you do a md5(name)). The queries are then much faster.

Is there a way to do this with Django? If not, the usual int primary key isn't limitating? How to specify that y开发者_如何学JAVAou want a big integer?


You can use whatever you like as the primary key in Django. Just add primary_key=True to the model arguments. E.g.

foo = models.CharField(max_length=36, primary_key=True)

Here are the Django docs on this topic.

Hope this helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消