Re: [sqlalchemy] simple relationship join ends up in 1 s

2014-09-12 Thread tatütata Okay
Thats what I did before, activating echo=True shows me correct query too. This joinedload takes 1.3 seconds for this 5000 entries. And only 4 queries in general for complete side load. Adding one more joinedload ends up in 2 seconds, thats way too much for 1700 customers and 5 k bought items On

[sqlalchemy] Re: SQLAlchemy connection errors

2014-09-12 Thread Matthijs Blaas
Ok, i found the issue! When I tried to use pg8000 to connect to postgres i got an error: cannot insert multiple commands into a prepared statement. Apparently multiple queries is fine with psycopg2, but not using pg8000. We prefix all queries because of a workaround. We handle multi-tenancy

Re: [sqlalchemy] simple relationship join ends up in 1 s

2014-09-12 Thread Michael Bayer
OK, keep going with the profiling, whats the total number of rows you are seeing with the joined load, 5000 total ? sometimes a join is actually scrolling through many more rows than that, duplicate rows in the case of a cartesian product.echo='debug' would show that. Or there could be

Re: [sqlalchemy] SQLAlchemy connection errors

2014-09-12 Thread Michael Bayer
On Sep 12, 2014, at 6:45 AM, Matthijs Blaas thijs.bl...@gmail.com wrote: Ok, i found the issue! When I tried to use pg8000 to connect to postgres i got an error: cannot insert multiple commands into a prepared statement. Apparently multiple queries is fine with psycopg2, but not using

Re: [sqlalchemy] SQLAlchemy connection errors

2014-09-12 Thread Jonathan Vanasco
i have no input on the issues michael identified. but i'm curious about a sqlalchemy event somehow not firing. which transaction event were you using? after_begin or after_transaction_create ? -- You received this message because you are subscribed to the Google Groups sqlalchemy

Re: [sqlalchemy] SQLAlchemy connection errors

2014-09-12 Thread Matthijs Blaas
set the search path within the connection pool using the “connect” event; all connections used by the pool will then have this search path setting the moment they connect. Don’t ever put multiple SQL expressions in a DBAPI execute (for this very reason - driver changes, hilarity ensues. We are

Re: [sqlalchemy] simple relationship join ends up in 1 s

2014-09-12 Thread Jonathan Vanasco
I think you need to profile the application like Mike said. Just to be thorough, I'd suggest you time the Query execution and the ORM population. Do you have an example of the faster raw SQL that you're trying to generate ? When you do a query on the commandline it is often faster because the

Re: [sqlalchemy] SQLAlchemy connection errors

2014-09-12 Thread Michael Bayer
On Sep 12, 2014, at 12:26 PM, Matthijs Blaas thijs.bl...@gmail.com wrote: set the search path within the connection pool using the connect event; all connections used by the pool will then have this search path setting the moment they connect. Don't ever put multiple SQL expressions in a

[sqlalchemy] Deferring a many-to-many mapping

2014-09-12 Thread Brian the Lion
Hi all, I am having trouble deferring a many-to-many mapping. I just had a couple of questions related there-to: (1) The most visible implementations of vanilla many-to-many mappings seem to use sqlalchemy.Table(...). Is that, indeed, the accepted practice? One alternative would be to use a