1.
    users = User.objects.only("power_level")[:500000]
    for user in users.iterator():
        d = user.power_level

2.
   users = User.objects.all()[:500000]
    for user in users.iterator():
        d = user.power_level

1. ~24 sec
2. ~28 sec

This one looks correct.
But I am a bit confused, does this mean that only() and defer() should
not be used in single-item pk queries?

On Aug 6, 1:34 am, Alex Gaynor <alex.gay...@gmail.com> wrote:
> On Thu, Aug 5, 2010 at 5:32 PM, OverKrik <overk...@gmail.com> wrote:
> > I am performing every test 10 times, excluding one fastest and one
> > slowest result, restarting db every time and performing 10 000 request
> > to warm db before measuring execution time.
> > Just in case, I've tried running tests in only-full-only-full and
> > defer-full-defer-full patters and got same results.
>
> > On Aug 6, 1:18 am, Dennis Kaarsemaker <den...@kaarsemaker.net> wrote:
> >> On do, 2010-08-05 at 16:09 -0500, Jacob Kaplan-Moss wrote:
>
> >> > - What database engine are you using?
> >> > - Where's the database being stored (same server? other server?
> >> > in-memory?)
> >> > - How much data is in the database?
> >> > - How big is that "info" field on an average model?
>
> >> - Were OS/database level caches equally hot or cold?
> >> --
> >> Dennis K.
>
> >> They've gone to plaid!
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django developers" group.
> > To post to this group, send email to django-develop...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-developers+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-developers?hl=en.
>
> Can you try comparing:
>
> Model.objects.only("field1")[:150000]
>
> vs.
>
> Model.objects.all()[:150000]
>
> Instead of looping and doing individual queries?
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your
> right to say it." -- Voltaire
> "The people's good is the highest law." -- Cicero
> "Code can always be simpler than you think, but never as simple as you
> want" -- Me

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

Reply via email to