Thanks a lot for all the answers. So far I've only implemented select queries, using dbsession.execute. I'll read about the "changed" state handling.
About the additional options: pool_pre_ping seems to work well and doesn't seem to have any side effects. pool_reset_on_return on the other hand is interesting, as it did make my development queries 3x faster. (I did 50 curl queries and it was 600 ms with rollback vs 200 ms with none for a "select 1" endpoint, between EU <> US). My only problem was that it left the connection in "idle in transaction" state, on which we have a 5 minute timer on the server, so the connection get's disconnected. That breaks SQLAlchemy. Because of this, I've commented it out (i.e. left it on "rollback"). I think this would only work if I didn't use transactions, but just direct queries. Wouldn't it be possible to simply add the engine to request and then do something like with request.engine.connect() as conn: ? // I know this is only affecting dev setup, and the overhead of a transaction + rollback is almost nothing within the same datacenter, but still, I'm curious about how much of this session + transaction mechanism is needed for select-only queries. Zsolt On Mon, 29 Apr 2019 at 18:24, Jonathan Vanasco <[email protected]> wrote: > > > > On Saturday, April 27, 2019 at 11:43:33 PM UTC-4, Mike Orr wrote: > >> >> 'session.execute()' executes SQL like 'engine.execute()' does, so you >> can get the advantages of a request transaction without using ORM >> queries. > > > in addition to Mike's comments - make sure to read the zope.sqlalchemy docs > on `mark_changed` or starting the session on a 'changed' state > > https://pypi.org/project/zope.sqlalchemy/ > > > if you don't do that, sqlalchemy won't know you did something and will > rollback instead of commit. > > -- > You received this message because you are subscribed to a topic in the Google > Groups "pylons-discuss" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/pylons-discuss/8Rndsn6oLyg/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/pylons-discuss/6015d75c-f277-42cb-880c-9d30632fdcb5%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "pylons-discuss" 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]. To view this discussion on the web visit https://groups.google.com/d/msgid/pylons-discuss/CAKw-smD4XG3k-3U0sJ8Pq9Oxx3bObG0uB1wfhPrN97M%2BMRC3ig%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
