No, when you use the select_related method, the query that generated is:

SELECT * FROM tablename
     INNER JOIN tablename2 ON (tablename.field = tablename2.field)
     ....
     WHERE ....

The problem is when you have a null value in a field that is foreing key.

You'll can try to fix this or you'll can set foreing key fields name
manually as a list:

queryset = Model.objects.filter().select_related(fields=['field', 'field2'])

the main idea is exclude fields that contains null values. Probably this
will produce more than one query.

apologies, my english is quite bad


2011/12/6 Szabo, Patrick (LNG-VIE) <patrick.sz...@lexisnexis.at>

>  Okay it seems that specifying which Foreign-Keys it should follow solves
> the problem. ****
>
> Is this a known issue and can I be sure that this won’t cause any further
> trouble !?****
>
> ** **
>
>  . . . . . . . . . . . . . . . . . . . . . . . . . .
>
>  **
>
> Ing. Patrick Szabo
> XSLT Developer
>
> LexisNexis
> Marxergasse 25, 1030 Wien
>
> patrick.sz...@lexisnexis.at
>
> Tel.: 00431 534521573
>
> Fax: +43 (1) 534 52 - 146
>
>
> *Von:* django-users@googlegroups.com [mailto:django-users@googlegroups.com]
> *Im Auftrag von *Szabo, Patrick (LNG-VIE)
> *Gesendet:* Dienstag, 06. Dezember 2011 08:29
> *An:* django-users@googlegroups.com
> *Betreff:* AW: AW: Performance****
>
> ** **
>
> Thank you, i could cut my queries in half which brings almost a second J**
> **
>
> Unfortunately the function seems to effect the results.****
>
> ** **
>
> If I run the query with select_related() I get 151 objects. ****
>
> Without select_related() I get 199. ****
>
> ** **
>
> Is there something I can to to overcome this ?!****
>
> ** **
>
> *Von:* django-users@googlegroups.com [mailto:django-users@googlegroups.com]
> *Im Auftrag von *Felipe Morales
> *Gesendet:* Montag, 05. Dezember 2011 17:50
> *An:* django-users@googlegroups.com
> *Betreff:* Re: AW: Performance****
>
> ** **
>
> Patrick, ****
>
> ** **
>
> try to use select_related() method instead of only filter() when you get a
> list of elements, e.g. :****
>
> ** **
>
> queryset = Model.objects.filter().select_related()****
>
> ** **
>
> by this way you'll get only one query instead 800****
>
> ** **
>
> good luck!****
>
> ** **
>
> Felipe****
>
> 2011/12/5 Nikolas Stevenson-Molnar <nik.mol...@consbio.org>****
>
> It would help to know a little more about your code here. Could you give
> some examples?****
>
> ** **
>
> _NIk****
>
> ** **
>
> On Dec 5, 2011, at 3:18 AM, Szabo, Patrick (LNG-VIE) wrote:****
>
> ** **
>
> Okay that toolbar is really useful and also looks kind of nice J…Thanks
> for that.****
>
> I’ve already found the problem….somehow my app triggers 800 queries just
> for a simple page.****
>
> Can I somehow find out which part of my code is causing those queries ?!**
> **
>
>  ****
>
> patrick****
>
>  ****
>
> ** **
>
> . . . . . . . . . . . . . . . . . . . . . . . . . .****
>
> Ing. Patrick Szabo
> XSLT Developer****
>
> LexisNexis
> Marxergasse 25, 1030 Wien
>
> patrick.sz...@lexisnexis.at****
>
> Tel.: 00431 534521573****
>
> Fax: +43 (1) 534 52 - 146****
>
> ** **
>
> *Von:* django-users@googlegroups.com [mailto:django-users@googlegroups.com
> ] *Im Auftrag von *Nikolas Stevenson-Molnar
> *Gesendet:* Montag, 05. Dezember 2011 08:14
> *An:* Nikolas Stevenson-Molnar
> *Cc:* django-users@googlegroups.com
> *Betreff:* Re: Performance****
>
>  ****
>
> A bit more searching turned up something even better... looks like the
> Django folks address this directly:
> https://code.djangoproject.com/wiki/ProfilingDjango****
>
>  ****
>
> _Nik****
>
>  ****
>
> On Dec 4, 2011, at 11:03 PM, Nikolas Stevenson-Molnar wrote:****
>
> ** **
>
> I haven't done this myself, but I would assume you could use the Python
> profiler. Here's one project that facilitates profiling a WSGI app
> (assuming you're using Django via WSGI): http://repoze.org/****
>
>  ****
>
> Others here may have more experience with profiling web apps.****
>
>  ****
>
> _Nik****
>
>  ****
>
> On Dec 4, 2011, at 10:55 PM, Szabo, Patrick (LNG-VIE) wrote:****
>
> ** **
>
> Hi,****
>
>  ****
>
> In the last couple of weeks my app has become quite slowly and I’m
> wondering why that is.****
>
> Are there any debugging tools where I can see what takes how much time ?**
> **
>
>  ****
>
> cheers****
>
>  ****
>
> . . . . . . . . . . . . . . . . . . . . . . . . . .****
>
> Ing. Patrick Szabo
> XSLT Developer****
>
> LexisNexis
> Marxergasse 25, 1030 Wien
>
> patrick.sz...@lexisnexis.at****
>
> Tel.: 00431 534521573****
>
> Fax: +43 (1) 534 52 - 146****
>
>  ****
>
>  ****
>
>  ****
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.****
>
>  ****
>
>  ****
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.****
>
> ** **
>
> ** **
>
> ** **
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.****
>
> ** **
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.****
>
>
>
> ****
>
> ** **
>
> --
> Felipe Morales C.
> Ingeniero de Ejecucin en Computacin e Informtica.****
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.****
>
> . . . . . . . . . . . . . . . . . . . . . . . . . .****
>
> Ing. Patrick Szabo
> XSLT Developer ****
>
> LexisNexis
> Marxergasse 25, 1030 Wien
>
> patrick.sz...@lexisnexis.at****
>
> Tel.: 00431 534521573 ****
>
> Fax: +43 (1) 534 52 - 146 ****
>
> ** **
>
> ** **
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.****
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Felipe Morales C.
Ingenierío de Ejecución en Computación e Informática.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to