#33359: Don't close database connections after every TestCase
-------------------------------------+-------------------------------------
     Reporter:  Ran Benita           |                    Owner:  nobody
         Type:                       |                   Status:  new
  Cleanup/optimization               |
    Component:  Testing framework    |                  Version:  dev
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Florian Apolloner):

 > DB connection setup can be somewhat heavy and so needlessly closing them
 adds overhead to the test run.

 Agreed, this can be "heavy" -- do you mind running with sqlite & postgres
 locally and report timings with and without your patch?

 What I am a bit worried though is that the state of the connection is
 essentially undefined after running a test, so I wonder if we should add a
 `reset` method or similar on the connection to restore it to it's initial
 state; for instance see docs about `server_reset_query` in pgbouncer:

 > The query is supposed to clean any changes made to the database session
 so that the next client gets the connection in a well-defined state. The
 default is DISCARD ALL which cleans everything, but that leaves the next
 client no pre-cached state. It can be made lighter, e.g. DEALLOCATE ALL to
 just drop prepared statements, if the application does not break when some
 state is kept around.

 We might have to rerun connection initialization queries after that
 though.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33359#comment:1>
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/066.5e7b379d9cdd74115efb3f890a6ac170%40djangoproject.com.

Reply via email to