#28062: Using QuerySet.iterator() with pgBouncer leads to nonexistent cursor 
errors
-------------------------------------+-------------------------------------
     Reporter:  Sergey Fursov        |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  1.11
  (models, ORM)                      |
     Severity:  Release blocker      |               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 Sergey Fursov):

 Hi Josh,

 > For your particular setup, I'd maybe recommend running a second
 pgbouncer in session mode (or not use pgbouncer), and for queries that use
 .iterator(), using that specific connection. As long as iterator() isn't
 used in the majority of your requests, the number of connections shouldn't
 spike too high.

 This is reasonable suggestion, thanks

 > We could also add an argument to .iterator() that allows users to opt-in
 to the new server side cursors. We'd need to document the limitations, and
 suggest ideal scenarios (use transaction.atomic, or
 .using('non_pgbouncer_transaction_connection')).

 This sound like the best option for me (at least compared to reverting
 changes)

 Another my point was the fact, that django use iterator internally in
 ModelChoiceField for optimizing iteration over queryset and in several
 serializer methods.
 For my particular case it would be enough to add additional
 ModelChoiceIterator to override default ModelChoiceField.iterator field
 (we don't use DB serialization much, so i don't know, does serialization
 part have big impact on production using). But i think this point should
 be considered while working on this issue, too, because it might break
 apps in production.

--
Ticket URL: <https://code.djangoproject.com/ticket/28062#comment:4>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.f67638e0fd572ac3e116d977a1c87694%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to