If anyone's curious, the mysql situation is as crazy as you might expect. :)

The max is only determined only by the total row size (65,535 bytes) and
the index size (767 bytes default).

Mysql defaults to only allowing 3-byte (no emoji) unicode characters, so
65,535/3=21,845 max across the entire row (the sum of all of the maxes of
all char/varchar columns), and each indexed field only gets 767/3=255
characters by default.

If you change to 4-byte unicode characters, (which you should, but django
doesn't really help you out #18392), your max_lengths can add up to
65,535/4=16,383 characters, and if you want the field to be indexed, you
only get 191 characters (using the default index size). It's possible to
only index the first 767/4=191 characters of the field, but django doesn't
really support that.

Basically, 255 works pretty well by default, allowing 65,535/3/255=85
3-byte fields per row, and indexes just work if you stick to the default
settings.

https://dev.mysql.com/doc/refman/5.0/en/char.html
https://code.djangoproject.com/ticket/18392


On Tue, Sep 22, 2015 at 1:56 AM, Aymeric Augustin <
aymeric.augus...@polytechnique.org> wrote:

> Hi Shai,
>
> On 22 sept. 2015, at 04:22, Shai Berger <s...@platonix.com> wrote:
>
> > I'd solve the "need to specify" issue by setting a default that is
> > intentionally smaller than the smallest (core) backend limitation, say
> 128.
>
> I would pick the highest value supported by all core backends (probably 255
> for MySQL, unless there’s something about indexes and multi-byte encodings
> that I forget) in order to minimize the need to increase it.
>
> If we go for a lower value, I suggest to pick something totally arbitrary
> like
> 100 to make it clear that it isn't a technical limitation.
>
> > I"d make an "unlimited length text field" a new type of field,
> explicitly not
> > supported on MySql and Oracle; and I'd suggest that it can live outside
> core
> > for a while. so we may get an impression of how popular it really is.
>
> The main use case seems to be “VARCHAR() on PostgreSQL”. What about
> defining a
> slight variant of CharField in django.contrib.postgres that merely makes
> the
> max_length argument default to None?
>
> --
> Aymeric.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers  (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-developers+unsubscr...@googlegroups.com.
> To post to this group, send email to django-developers@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-developers.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-developers/17C37814-E6A8-4E27-B590-BF9FFF42CB20%40polytechnique.org
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAFO84S5TUwLPf%3DRrGXL4%3Dvf3647CufOsijiznttVQF%2BxYHaBFg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
      • ... Christophe Pettus
      • ... Podrigal, Aron
      • ... Christophe Pettus
      • ... Podrigal, Aron
      • ... Christophe Pettus
      • ... Shai Berger
      • ... Christophe Pettus
      • ... Podrigal, Aron
      • ... Josh Smeaton
      • ... Aymeric Augustin
      • ... Collin Anderson
      • ... Michael Manfre
      • ... Aymeric Augustin
      • ... Podrigal, Aron
      • ... Aymeric Augustin
      • ... Podrigal, Aron
      • ... Tim Chase
      • ... 'Tom Evans' via Django developers (Contributions to Django itself)
  • Re: Ma... Remco Gerlich
    • R... Christophe Pettus
      • ... Tom Christie

Reply via email to