python - SQLAlchemy MySQL STRAIGHT_JOIN -


my code executes queries fine in sqlalchemy orm layer so:

session().query(model_a).join(     (model_b, == somethingelse) ).join(     (model_c, == somethingelse) ) # etc ... 

but i've come across query taking minutes finish. turns out mysql blame because it's not joining in order ask to. adding straight_join after select like:

select straight_join table_a.id table_a inner join table_b ... 

fixes problem can't figure out if there's way make sqlalchemy add straight_join after select. docs suggest hints can added select() via with_hint(table_a, "straight_join") adds text in wrong place causes mysql syntax error. involve stepping outside of orm not ideal.

i've tried using various mysql debugging techniques explain, analyze table etc... can't seem find out why mysql choosing wrong path. manually switching around order of joins doesn't seem either i'm in position need straight_join work.

any ideas?

we support directly case of mysql , strange keywords:

session().query(model_a).prefix_with("straight_join").join(     (model_b, == somethingelse) ).join(     (model_c, == somethingelse) ) # etc ... 

http://docs.sqlalchemy.org/en/rel_0_8/orm/query.html?highlight=query.prefix_with#sqlalchemy.orm.query.query.prefix_with


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -