On 11/18/2013 04:06 PM, Jonathan Vanasco 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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.
Wouldn't selecting the sql logger and logging the comment provide you
the same information?
AM
--
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.