Opened 9 years ago

Closed 8 years ago

#2277 closed defect (wontfix)

Change manipulator fires a huge number of queries

Reported by: akaihola 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: UI/UX:

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 Changed 9 years ago by mtredinnick

  • Owner changed from adrian to mtredinnick

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.

comment:2 Changed 9 years ago by anonymous

  • Cc freakboy3742@… added

comment:3 Changed 8 years ago by Gary Wilson <gary.wilson@…>

  • Triage Stage changed from Unreviewed to Accepted

comment:4 follow-up: Changed 8 years ago by akaihola

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 in reply to: ↑ 4 Changed 8 years ago by Gary Wilson <gary.wilson@…>

Replying to akaihola:

Isn't newforms going to obsolete this anyway?

Possibly, but it might not be a manipulator problem.

comment:6 Changed 8 years ago by mtredinnick

I suspect #3436 will fix this issue, but it may not be a direct dupe.

comment:7 Changed 8 years ago by ubernostrum

  • Resolution set to wontfix
  • Status changed from new to closed

Comments in #3436 indicate that this is not a problem in newforms, and the old forms system is deprecated.

Note: See TracTickets for help on using tickets.
Back to Top