Opened 18 years ago
Closed 17 years ago
#2277 closed defect (wontfix)
Change manipulator fires a huge number of queries
Reported by: | Antti Kaihola | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | |
Severity: | normal | Keywords: | |
Cc: | freakboy3742@… | Triage Stage: | Accepted |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
In some cases a change manipulator runs an insane number of queries (in my case almost 4000) when a foreign key relation is specified in the follow= keyword.
I've experienced this in a situation not unlike the following:
model A model B: foreign keys to models A and C model C: foreign key to model D model D
When I do A.ChangeManipulator(id, follow={'b': {c: {'id': True, 'd': False} } })
, I get lots and lots of queries for D, even multiple queries per ID.
a.ChangeManipulator(id, follow={'b': {c: False} })
runs well, but doesn't work for me since I need some simple fields from C.
In IRC, ubernostrum mentioned that malcolm has been investigating the same issue.
Change History (7)
comment:1 by , 18 years ago
Owner: | changed from | to
---|
comment:2 by , 18 years ago
Cc: | added |
---|
comment:3 by , 18 years ago
Triage Stage: | Unreviewed → Accepted |
---|
follow-up: 5 comment:4 by , 18 years ago
Sorry, I've meanwhile forgotten in which project and app I had this problem, and how I worked around it.
Isn't newforms going to obsolete this anyway?
comment:5 by , 18 years ago
Replying to akaihola:
Isn't newforms going to obsolete this anyway?
Possibly, but it might not be a manipulator problem.
comment:7 by , 17 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Comments in #3436 indicate that this is not a problem in newforms, and the old forms system is deprecated.
I think this is peripherally related to the general problem I have been looking at about over-enthusiastic "related" queries in some places. But I was trying to repeat the problem described here and was unable to. Setting up a bunch of models exactly as you describe above and populating them with 100 - 200 records each and lots of interlinks, if I consruct a ChangeManipulator as in your first example, I only see queries on the tables for A, B and C.
There are some odd looking queries going on there, so I'm willing to believe something is amiss. What I don't see, however, are any queries on the table for model D (and the source does not lead me to believe it is going to make any).
So, could you take your existing case and try to trim it down and change any confidential bits so that we have an example of what you are seeing. At the moment, I'm pretty stuck as far as this particular example goes, although, as I say, there there are a few places in that part of the code that might be causing this.