Opened 9 months ago

Closed 9 months ago

#23139 closed Uncategorized (duplicate)

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

Reported by: dnozay 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 Changed 9 months ago by anonymous

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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

comment:2 Changed 9 months ago by timo

  • Resolution set to duplicate
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.
Back to Top