On Sat, May 16, 2015 at 5:27 PM, Erik Cederstrand <erik+li...@cederstrand.dk > wrote:
> > > Den 15/05/2015 kl. 20.54 skrev Timothy W. Cook <t...@mlhim.org>: > > > > def formfield_for_many_to_many(self, db_field, *args, **kwargs): > > formfield = super(ClusterAdmin, > self).formfield_for_many_to_many(db_field, *args, **kwargs) > > if db_field.name in > ['cluster','dvboolean','dvuri','dvstring','dvcodedstring','dvidentifier','dvparsable','dvmedia', > > > 'dvordinal','dvcount','dvquantity','dvratio','dvtemporal']: > > formfield.queryset = > formfield.queryset.select_related('project') > > return formfield > > > > > > > > Each of the ManyToMany references have this in their model: > > > > > > def __str__(self): > > return self.prj_name.prj_name + ":" + self.data_name > > Are you sure you don't mean > > formfield.queryset.select_related('prj_name') > > If 'prj_name' is the FK on your m2m models, then that's what should be > passed to select_related() > > Django 1.8 should catch this for you, if 'project' isn't also a FK on your > model. > > Project is the model used as the foreign key. But yes, I suppose that prj_name is the correct field name to use there. However, I still have 4520 queries executing. Before that change it was 4521. Strange that it would drop by only one query. I changed it back to 'project' just to be sure I remembered correctly and yes it went back to 4521. The queries look like this: *SELECT* "ccdgen_cluster"."id" <http://127.0.0.1:8000/admin/ccdgen/cluster/209/#> *FROM* "ccdgen_cluster" *INNER JOIN* "ccdgen_cluster_clusters" *ON* ( "ccdgen_cluster"."id" = "ccdgen_cluster_clusters"."to_cluster_id" ) *INNER JOIN* "ccdgen_project" *ON* ( "ccdgen_cluster"."prj_name_id" = "ccdgen_project"."prj_name" ) *WHERE* "ccdgen_cluster_clusters"."from_cluster_id" = 209 *ORDER* *BY* "ccdgen_project"."prj_name" *ASC*, "ccdgen_cluster"."cluster_subject" *ASC* *...* *SELECT "ccdgen_project"."id", "ccdgen_project"."pgroup_id", "ccdgen_project"."prj_name", "ccdgen_project"."description", "ccdgen_project"."rm_version_id" <http://127.0.0.1:8000/admin/ccdgen/cluster/209/#> FROM "ccdgen_project" WHERE "ccdgen_project"."prj_name" = 'Brain Tumors'* *Most take between .35 and .9 seconds. * *Except this one took 17 seconds. No idea why except possibly memory swapping or something at that point?* *It seems to be just like many of the others. * *SELECT ••• <http://127.0.0.1:8000/admin/ccdgen/cluster/209/#> FROM "ccdgen_dvtemporal" INNER JOIN "ccdgen_project" ON ( "ccdgen_dvtemporal"."prj_name_id" = "ccdgen_project"."prj_name" ) ORDER BY "ccdgen_project"."prj_name" ASC, "ccdgen_dvtemporal"."data_name" ASC* These are all times running with the dev server on a laptop. They do not take that long on a small AWS instance. *But still too long to be friendly to most users. * *Thanks for any other insight. * *--Tim* > Erik > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-users+unsubscr...@googlegroups.com. > To post to this group, send email to django-users@googlegroups.com. > Visit this group at http://groups.google.com/group/django-users. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/D28F7970-28EB-46DE-9FD2-3BD3F63A085E%40cederstrand.dk > . > For more options, visit https://groups.google.com/d/optout. > -- ============================================ Timothy Cook LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook MLHIM http://www.mlhim.org -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2B%3DOU3UmG1Pyj90gSr_EQP1ogLT-CL3u2nd1MRSepXWmAmv9Lg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.