Django

Code

Ticket #2277 (closed: wontfix)

Opened 2 years ago

Last modified 1 year ago

Change manipulator fires a huge number of queries

Reported by: akaihola Assigned to: nobody
Milestone: Component: django.contrib.admin
Version: Keywords:
Cc: freakboy3742@gmail.com Triage Stage: Accepted
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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.

Attachments

Change History

07/05/06 08:03:57 changed 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.

07/26/06 20:32:58 changed by anonymous

  • cc set to freakboy3742@gmail.com.

02/27/07 13:48:04 changed by Gary Wilson <gary.wilson@gmail.com>

  • stage changed from Unreviewed to Accepted.

(follow-up: ↓ 5 ) 02/28/07 03:05:32 changed 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?

(in reply to: ↑ 4 ) 03/01/07 19:50:54 changed by Gary Wilson <gary.wilson@gmail.com>

Replying to akaihola:

Isn't newforms going to obsolete this anyway?

Possibly, but it might not be a manipulator problem.

03/12/07 07:51:43 changed by mtredinnick

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

09/16/07 07:58:20 changed by ubernostrum

  • status changed from new to closed.
  • resolution set to wontfix.

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


Add/Change #2277 (Change manipulator fires a huge number of queries)




Change Properties
Action