Opened 4 years ago

Closed 4 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


see as well 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?).

Change History (2)

comment:1 Changed 4 years ago by anonymous

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

comment:2 Changed 4 years ago by Tim Graham

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