Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » Django
  • » Should not select related be default? [RSS Feed]

#1 March 24, 2008 12:03:20

s.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Should not select related be default?


In most of my pages, select_related dramatically reduces the number of
queries the page is needing, so I was wondering what is the reason
behind not making select_related default and providing a method for
do_not_select_related
--~--~---------~--~----~------------~-------~--~----~
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
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en-~----------~----~----~----~------~----~------~--~---

Offline

#2 March 24, 2008 13:40:25

Tom B.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Should not select related be default?


On Mon, Mar 24, 2008 at 11:03 AM, shabda <> wrote:

>
> In most of my pages, select_related dramatically reduces the number of
> queries the page is needing, so I was wondering what is the reason
> behind not making select_related default and providing a method for
> do_not_select_related
>

Explicit is better than implicit

Try an "import this" on a python shell.

Tom

--~--~---------~--~----~------------~-------~--~----~
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
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en-~----------~----~----~----~------~----~------~--~---

Offline

#3 March 24, 2008 19:39:14

s.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Should not select related be default?


Ah, but practicality beats purity :)

But of course I have not fully profiled, the times so might be not
select_related as default is a good idea.

On Mar 24, 5:40 pm, "Tom Badran" <> wrote:
> On Mon, Mar 24, 2008 at 11:03 AM, shabda <> wrote:
>
> > In most of my pages, select_related dramatically reduces the number of
> > queries the page is needing, so I was wondering what is the reason
> > behind not making select_related default and providing a method for
> > do_not_select_related
>
> Explicit is better than implicit
>
> Try an "import this" on a python shell.
>
> Tom
--~--~---------~--~----~------------~-------~--~----~
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
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en-~----------~----~----~----~------~----~------~--~---

Offline

#4 March 24, 2008 20:00:46

Malcolm T.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Should not select related be default?


On Mon, 2008-03-24 at 11:38 -0700, shabda wrote:
> Ah, but practicality beats purity :)
>
> But of course I have not fully profiled, the times so might be not
> select_related as default is a good idea.

I think you're also equating your particular use-cases with being the
most common and that's not necessarily true (it's also pretty much
impossible to measure). I know that on different projects I've worked
on, sometimes the code is regularly traversing relations on models,
sometimes hardly ever. Uncontrolled select_related() calls are a
performance hit because you end up doing database joins against tables
you don't need, so we don't want to hit people with the performance
penalty when it's not needed.

Not everybody needs to access every attribute on their model that has a
relation to another table every time, which would be the only case when
using select_related() all the time made sense. In fact, in order to
provide more control over this, in the "coming soon" features, you can
control which of the related tables are pulled in via select_related(),
because we realise that pulling in every table related to a model is not
a very good idea, particularly on models with high branching degree in
their relations. The current "all or nothing" approach is a reasonable
first step, but we can do better (particularly with self-referential
models).

Regards,
Malcolm

--
Two wrongs are only the beginning.http://www.pointy-stick.com/blog/--~--~---------~--~----~------------~-------~--~----~
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
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en-~----------~----~----~----~------~----~------~--~---

Offline

  • Root
  • » Django
  • » Should not select related be default? [RSS Feed]

Board footer

Moderator control

Enjoy the 11th of December
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support