[sqlalchemy] Connection initialization
When we make a new connection to the database (MySQL in this case), it appears that the dialect has some initialization functions than run several queries: connection duration rows query primary_slave/tid=92761174.014ms 1'SELECT DATABASE()' primary_slave/tid=92761171.868ms 1SELECT CAST('test unicode returns' AS CHAR(60)) AS anon_1 primary_slave/tid=92761178.586ms 8SHOW VARIABLES LIKE 'character_set%' primary_slave/tid=92761174.056ms 1SHOW VARIABLES LIKE 'lower_case_table_names' primary_slave/tid=92761178.084ms 126'SHOW COLLATION' primary_slave/tid=9276117 30.873ms 1SHOW VARIABLES LIKE 'sql_mode' Is there a way to eliminate the need to make these queries ? Though we of course don't open new connections often, it does happen and adding this overhead for information that probably shouldn't change seems unnecessary. (MySQL 5.0.x, sqlalchemy 6.0beta) Rhett -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
Re: [sqlalchemy] Connection initialization
On Jun 25, 2010, at 6:53 PM, Rhett Garber wrote: When we make a new connection to the database (MySQL in this case), it appears that the dialect has some initialization functions than run several queries: connection duration rows query primary_slave/tid=9276117 4.014ms 1'SELECT DATABASE()' primary_slave/tid=9276117 1.868ms 1SELECT CAST('test unicode returns' AS CHAR(60)) AS anon_1 primary_slave/tid=9276117 8.586ms 8SHOW VARIABLES LIKE 'character_set%' primary_slave/tid=9276117 4.056ms 1SHOW VARIABLES LIKE 'lower_case_table_names' primary_slave/tid=9276117 8.084ms 126'SHOW COLLATION' primary_slave/tid=9276117 30.873ms 1SHOW VARIABLES LIKE 'sql_mode' Is there a way to eliminate the need to make these queries ? Though we of course don't open new connections often, it does happen and adding this overhead for information that probably shouldn't change seems unnecessary. (MySQL 5.0.x, sqlalchemy 6.0beta) Those queries happen exactly once per create_engine() statement, which is something meant to be called once per-application-process, per database. Because the inspection is limited to the very first connect call of the engine, there's no real overhead here. It is necessary to get that information at least once so that the dialect can properly render SQL for the target backend. I would also recommend not using a beta release of 0.6. 0.6.1 is the current version. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] Connection initialization
Hi, How can I place some initialization code for each connection in the pool? Currently I do something like this: engine.execute(SET collation_connection=utf8_general_ci) engine.execute(SET names utf8) engine.execute(SET character_set_client=utf8) engine.execute(SET character_set_results=utf8) before processing each http-request. But it needs to be done only once per connection. -- Paul. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---