On Jul 2, 8:00 pm, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote:
> Sorry, I meant how many HTTP requests *per page*, as in, how many
> external resource references?
- 13 unique external images
- 4 stylesheets (changelists.css from contrib/admin)
and I just noticed I create:
- 4000 HTML anchors
> Are you serving media off a separate server, or though apache? If
> apache, are you using it's regular file service or running it through
> Django?
Through Apache's regular file service (as described in the tutorial).
> > 1, essentially: Book.objects.select_related(). Plus access to 5
> > foreign objects per book.
>
> with settings.DEBUG = True:
>
> from django.db import connection
> print connection.queries
>
> May give you a clue.
I've now instrumented as you suggest:
db.reset_queries()
book_list = list(Book.objects.select_related())
l0 = len(book_list)
l1 = len(db.connection.queries)
response = render_books(request, book_list, title='All books')
l2 = len(db.connection.queries) - l1
response.write('<span class="mini quiet">(%s, %s, %s)</span>' %
(l0, l1, l2))
return response
and the amazing response is:
(l0: 225, l1: 1, l2: 2630)
!!!
I'm quite at lost here. What am I doing wrong?
> > book_list = cache.get('all_books')
> > if not book_list:
> > book_list = Book.objects.select_related()
> > cache.set('all_books', book_list)
>
> This doesn't actually cache the result set. Querysets are lazy.
> If you want to cache the finished results, try this:
>
> book_list = cache.get('all_books')
> if not book_list:
> book_list = list(Book.objects.select_related())
Thanks. I've now tried the above, no performance gain however. Could
this be related to the issue above?
> cache.set('all_books', book_list)
>
> > book_list = [b for b in book_list if b.is_visible_by(user)]
>
> Concur with Tim that this may be worth making a DB function and
> using extra() on.
>
> Depends which DB you're using, really?
Initially, sqlite3, but I've now switched to MySQL 5.
JJ.
On Jul 2, 8:00 pm, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote:
> On 7/2/07, jj <[EMAIL PROTECTED]> wrote:
>
> > > How many HTTP requests?
>
> > It's only me testing at the moment, and it's already slow enough.
>
> Sorry, I meant how many HTTP requests *per page*, as in, how many
> external resource references?
>
> Are you serving media off a separate server, or though apache? If
> apache, are you using it's regular file service or running it through
> Django?
>
> > 1, essentially: Book.objects.select_related(). Plus access to 5
> > foreign objects per book.
>
> with settings.DEBUG = True:
>
> from django.db import connection
> print connection.queries
>
> May give you a clue.
>
> > book_list = cache.get('all_books')
> > if not book_list:
> > book_list = Book.objects.select_related()
> > cache.set('all_books', book_list)
>
> This doesn't actually cache the result set. Querysets are lazy.
> If you want to cache the finished results, try this:
>
> book_list = cache.get('all_books')
> if not book_list:
> book_list = list(Book.objects.select_related())
> cache.set('all_books', book_list)
>
> > book_list = [b for b in book_list if b.is_visible_by(user)]
>
> Concur with Tim that this may be worth making a DB function and
> using extra() on.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---