#16865: get_or_create defaults to _for_write even when it's just reading
-------------------------------------+-------------------------------------
     Reporter:  Rick van Hattem      |                    Owner:  nobody
  <Rick.van.Hattem@…>                |                   Status:  new
         Type:  Bug                  |                  Version:  1.3
    Component:  Database layer       |               Resolution:
  (models, ORM)                      |             Triage Stage:  Accepted
     Severity:  Normal               |      Needs documentation:  0
     Keywords:                       |  Patch needs improvement:  0
    Has patch:  0                    |                    UI/UX:  0
  Needs tests:  0                    |
Easy pickings:  1                    |
-------------------------------------+-------------------------------------

Comment (by poirier):

 There's too great a chance that the slave DB is a little out of date,
 get_or_create sees no record, tries to create it, and then fails because
 it already exists in the master DB.

 get_or_create() is more designed for data imports than to be used in every
 request.  If 99% of the time the record is expected to be there, and
 performance is critical, why not use a get() and catch the exception and
 call get_or_create() in those rare cases.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/16865#comment:3>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to