disable unused mysql call to _detect_collations() on connect - only call _detect_casing() for tests ?

Issue #2404 resolved
Mike Bayer repo owner created an issue

_detect_collations() appears to load a few hundred rows in upon connection. The value is assigned to a private dialect variable _server_collations that doesn't appear to be used.

_detect_casing() seems to only be used for a few tests.

I'd propose we turn off these methods being called by default, or at least _detect_collations() which has significant overhead.

Comments (3)

  1. Mike Bayer reporter
    diff -r b5188631d04567a34b78f1b11d71a12a858f2a92 lib/sqlalchemy/dialects/mysql/base.py
    --- a/lib/sqlalchemy/dialects/mysql/base.py Wed Feb 29 19:18:11 2012 -0500
    +++ b/lib/sqlalchemy/dialects/mysql/base.py Wed Feb 29 19:28:00 2012 -0500
    @@ -1939,8 +1939,6 @@
         def initialize(self, connection):
             default.DefaultDialect.initialize(self, connection)
             self._connection_charset = self._detect_charset(connection)
    -        self._server_casing = self._detect_casing(connection)
    -        self._server_collations = self._detect_collations(connection)
             self._detect_ansiquotes(connection)
             if self._server_ansiquotes:
                 # if ansiquotes == True, build a new IdentifierPreparer
    diff -r b5188631d04567a34b78f1b11d71a12a858f2a92 test/lib/requires.py
    --- a/test/lib/requires.py  Wed Feb 29 19:18:11 2012 -0500
    +++ b/test/lib/requires.py  Wed Feb 29 19:28:00 2012 -0500
    @@ -395,11 +395,11 @@
    
     def _has_mysql_on_windows():
         return testing.against('mysql') and \
    -            testing.db.dialect._server_casing == 1
    +            testing.db.dialect._detect_casing(testing.db) == 1
    
     def _has_mysql_fully_case_sensitive():
         return testing.against('mysql') and \
    -            testing.db.dialect._server_casing == 0
    +            testing.db.dialect._detect_casing(testing.db) == 0
    
     def sqlite(fn):
         return _chain_decorators_on(
    
  2. Log in to comment