Re: [sqlalchemy] MySQL's STRAIGHT_JOIN in SQLAlchemy?

2012-06-29 Thread Martín Soto
Hello Michael: Sorry for not answering before, but I got sidetracked by other tasks. Your answer is very helpful, thanks a lot! I'm using the ORM, so I'll rather use the ORMStraightJoin solution. By looking into the code (that's easier now that I know what to look for) the only thing I

Re: [sqlalchemy] MySQL's STRAIGHT_JOIN in SQLAlchemy?

2012-06-29 Thread Michael Bayer
in most cases query.select_from(ORMStraightJoin(x, y, z)) is roughly equivalent to query.join() so that should do most of what you need.there's not an easy hook right now to get query.join() or something similar itself to do something different, without re-implementing or patching into the

Re: [sqlalchemy] MySQL's STRAIGHT_JOIN in SQLAlchemy?

2012-06-26 Thread Michael Bayer
you can build your own join construct using @compiles: # Core Level from sqlalchemy.sql.expression import Join from sqlalchemy.ext.compiler import compiles class StraightJoin(Join): pass @compiles(StraightJoin) def compile(element, compiler, **kw): return %s STRAIGHT_JOIN %s ON %s % (

[sqlalchemy] MySQL's STRAIGHT_JOIN in SQLAlchemy?

2012-06-25 Thread Martín Soto
Hi everyone! I'm currently working on a query that makes the (rather bad) MySQL optimizer choke. After running EXPLAIN, I noticed that MySQL was taking a pretty long time to optimize it (about 130 seconds) and was then producing a rather unintuitive join order. I tried replacing the JOIN