#32577: Add support for `UUIDAutoField` `DEFAULT_AUTO_FIELD`
-------------------------------------+-------------------------------------
     Reporter:  Tomasz Wójcik        |                    Owner:  nobody
         Type:  New feature          |                   Status:  new
    Component:  Database layer       |                  Version:  3.2
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Tomasz Wójcik):

 Replying to [comment:8 Antonin Grêlé]:
 > Replying to [comment:7 Tomasz Wójcik]:
 > > What I meant is I think users only use numeric types and uuids for
 generic app-wide primary keys so I don't think it's necessary to allow
 other types for {{{AutoField}}}, such as string. So instead of refactoring
 the entire {{{AutoField}}}, another type - {{{UUIDAutoField}}} could be
 added.
 >
 > Could I argue that IDs based on human-readable strings, like
 [https://coolname.readthedocs.io coolname], are a valid use case?
 >
 > It's easier to reference '"soft-cuddly-shrew-of-expertise" than
 "a1e1b1c5-5d5e-4eef-9ee9-e74e87ce71d6" or "2467584".
 >
 > Would this be seen as bad practice and we should use a slugfield that's
 not the primary key for something like this instead?

 Popular use case for a "readable uuid" like that is a randomly generated
 username. It's usually not a pk, just has a unique constraint, because you
 often perform many operations against users table and you don't want this
 table to be slow on joins. For other cases, why does it need to be
 readable at all?

 To my understanding there's no significant performance hit from using UUID
 as a primary key. It is 4x larger than int32 (128bit). So also index is
 bigger, cache will store less data etc.

 To my knowledge, varchar is a completely different story. It's way bigger
 and more difficult to sort, because it's very difficult to compare.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32577#comment:9>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.a4c6365014ea59dc5cb3ef81e40b73e6%40djangoproject.com.

Reply via email to