yes that is here: http://www.sqlalchemy.org/trac/wiki/UsageRecipes/Explain
comments: http://www.sqlalchemy.org/trac/wiki/UsageRecipes/SessionModifiedSQL feel free to combine On Nov 22, 2013, at 5:12 AM, Chris Withers <[email protected]> wrote: > I saw this thread and had been thinking of something similar... > > ...a query.explain() that would run an explain of the query, log the output > somewhere and then return the query so you could do: > > query.explain().all() > > ...and the like. > > Is there a similar recipe for logging the query and its explain that > sqlalchemy is about to do? > > cheers, > > Chris > > On 19/11/2013 01:40, Michael Bayer wrote: >> there’s a recipe for doing this with events: >> >> http://www.sqlalchemy.org/trac/wiki/UsageRecipes/SessionModifiedSQL >> >> >> On Nov 18, 2013, at 7:06 PM, Jonathan Vanasco <[email protected] >> <mailto:[email protected]>> wrote: >> >>> >>> Something that I realized would be very useful, is to enable comments >>> on query compilation. That would make it SO much easier to understand >>> logs. >>> >>> Yes this sounds slightly silly. >>> >>> Yes I am 100% serious. >>> >>> I've been working all day on optimizing a web page. It originally had >>> 200 queries, I'm down to 60, I think we can get to 15. >>> >>> Combing through 200 queries and associating the SQL to code is a pain. >>> >>> Consider this statement / syntax : >>> >>> results = dbSession.query( Foo ).filter_by( Foo.id.in_( 1,2,3) >>> ).comment("initial foo select").all() >>> >>> generating this sql ( which would propagate into all the various logs ) >>> >>> SELECT * FROM foo WHERE foo.id IN (1,2,3); -- initial foo select >>> >>> I think this would be ridiculously useful for troubleshooting. It >>> could even (potentially) be controlled by a setting in the engine or >>> connect string. Show comments on DEV, not PRODUCTION; turn on >>> Production comments only during a test timeframe, etc. >>> >>> Most Sql dialects support comments in queries. >>> >>> The following works in postgres, mysql, sqlite: >>> >>> c-style >>> >>> SELECT foo FROM bar /* comment here , can span multiple lines */; >>> >>> >>> until EOL - postgres and mysql >>> SELECT foo FROM bar ; -- comment >>> >>> After combing through many different docs, I also found this little >>> (outdated) chart -- >>> http://3rdstage.blogspot.com/2009/04/sql-comments-syntax-for-oracle-db2.html >>> >>> >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "sqlalchemy" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected] >>> <mailto:[email protected]>. >>> To post to this group, send email to [email protected] >>> <mailto:[email protected]>. >>> Visit this group at http://groups.google.com/group/sqlalchemy. >>> For more options, visit https://groups.google.com/groups/opt_out. >> > > -- > Simplistix - Content Management, Batch Processing & Python Consulting > - http://www.simplistix.co.uk > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" 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]. > Visit this group at http://groups.google.com/group/sqlalchemy. > For more options, visit https://groups.google.com/groups/opt_out.
signature.asc
Description: Message signed with OpenPGP using GPGMail
