Re: [sqlalchemy] Association table very slow

2020-12-12 Thread Marnix le Noble
Sorry, I thought I deleted the post just after sending it but it seems like it still went through. I figured out it was indeed the loading of ORM objects and not the query itself. For completeness sake in case anyone reads this at a later date. We were doing something like len(parent.children) to

Re: [sqlalchemy] Association table very slow

2020-12-11 Thread Mike Bayer
hey there - that query is not a cartesian product. the child and child_parent tables are linked together in the WHERE clause. I would assume the query here is in fact taking about half a second to run, the problem here is in the composition of Python objects for every row. I am assuming

[sqlalchemy] Association table very slow

2020-12-11 Thread marnix....@gmail.com
Dear sqlalchemy users, After look at the docs I arrived at the following structure: ``` Base = declarative_base() parent_child = Table( "parent_child", Base.metadata, Column("parent_id", Integer, ForeignKey("parent.id")), Column("child_id", Integer, ForeignKey("child.id")), ) class