id summary reporter owner description type status component version severity resolution keywords cc stage has_patch needs_docs needs_tests needs_better_patch easy ui_ux 16759 Expensive sql.Query cloning Alexander Schepanovski Alexander Schepanovski "I dug into `Query.clone()` and found that deepcopying of it's where tree may sometimes lead to deepcopying of model fields and _meta. And with a help of related fields it sometimes becomes a disaster. I dug further and found that actual culprits are `db.models.sql.where.Constraint` and `db.models.sql.expressions.SQLEvaluator` which ""leak"" deepcopying to ORM objects. We fixed this problem for ourselves and here is the patch." Bug closed Database layer (models, ORM) 1.3 Normal fixed orm performance cloning anssi.kaariainen@… Anssi Kääriäinen hv@… niwi@… Ready for checkin 1 0 0 0 0 0