id summary reporter owner description type status component version severity resolution keywords cc stage has_patch needs_docs needs_tests needs_better_patch easy ui_ux 21463 django mysql connection pinging Brian May nobody "Every time django makes a mysql query, it pings the mysql server. django/db/backends/mysql/base.py: {{{ def _valid_connection(self): if self.connection is not None: try: self.connection.ping() return True except DatabaseError: self.connection.close() self.connection = None return False }}} Not only is this inefficient[1], it is not needed. I believe this kludge is in case the server connection is closed, e.g. server restarted, or server closed connection as it was idle, or ... However I have talked to mysql experts, and have been told: ""The proper way is as follows: If the connection was lost, a query call will return a specific error, and the client library will reconnect. The app then just needs to re-issue the same query - or in case it was in the middle of a transaction, restart that transaction (obviously)."" Doing a websearch it also seems to be insufficient, there are a number of user's reporting that they get ""OperationalError: (2006, 'MySQL server has gone away')"" type errors, which suggests Django isn't reconnecting automatically when it should."" I have just received this error myself, from Django 1.5, however still investigating. I have a vague recollection that this was discussed in a ticket from years ago, however I can't find it now. Notes: [1] https://groups.google.com/forum/#!topic/django-developers/oIkjJbdWVEo" Uncategorized closed Database layer (models, ORM) 1.5 Normal fixed Unreviewed 0 0 0 0 0 0