Opened 10 years ago

Closed 10 years ago

#23139 closed Uncategorized (duplicate)

mysql backend should use CHAR instead of VARCHAR if model has a CharField of fixed length.

Reported by: Damien Nozay Owned by: nobody
Component: Database layer (models, ORM) Version: 1.6
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

see as well https://code.djangoproject.com/ticket/23138 which asks for min_length to be added to models.fields.Field.

For optimization purposes, if I have a model that wants exactly N characters for a field, then CHAR uses less bytes than VARCHAR.
One way to detect that intent is if you have CharField(min_length=N, max_length=N) -- in other words min_length == max_length.

common example: a hash always has the same length (always?).

https://github.com/django/django/pull/2921

Change History (2)

comment:1 by anonymous, 10 years ago

Six years ago, this was discussed (and closed wont fix) in #9349.

comment:2 by Tim Graham, 10 years ago

Resolution: duplicate
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top