using python 2.7, sqla 0.7.9, postgresql 9.1 i've setup joined table inheritance and wanted an eager loaded relationship from one of the derived objects to another derived object. when i do that i get what seems to be a really inefficient query.
here is the minimal setup: http://pastebin.com/yS7gDfju and this is the output: SELECT ... FROM root JOIN type2 ON root.id = type2.id LEFT OUTER JOIN (SELECT root.id AS root_id, root.type AS root_type, type1.id AS type1_id, type1.field1 AS type1_field1 FROM root JOIN type1 ON root.id = type1.id) AS anon_1 ON type2.type1_id = anon_1.type1_id what i expected was: SELECT ... FROM root JOIN type2 ON root.id = type2.id LEFT OUTER JOIN root as root_1 ON root_1.id = type2.type1_id LEFT OUTER JOIN type1 ON type1.id = root_1.id which runs *much* faster for the data sets i've tried. is there a way to force the relationship to generate the 2nd form? or am i doing something i shouldn't? thanks -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/0laXtaxdh8UJ. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.