On Jul 2, 10:00 am, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote:
> How many HTTP requests?

It's only me testing at the moment, and it's already slow enough.

> How many queries?

1, essentially: Book.objects.select_related(). Plus access to 5
foreign objects per book.

> How many bytes in response?

~ 550 kB

> What web server?

Apache 2.2.4

> > - Books have Authors, Publishers, etc. I use select_related() instead
> > of all(), but this does not improve performance much (half a second
> > over about 6 seconds query time).
>
> I think you're not measuring the whole thing somewhere

I use time.clock() in the template:
    ...
    {% block content %}
        {% let time.clock as time1 %}
        {% for book in book_list %}
            {% show_book_title book %}
            {% show_book_authors book %}
            {% show_book_publisher book %}
            ... (about 20 or so attributes in total, including 5
foreign keys) ...
        {% endbook %}
        {% let time.clock as time2 %}
        {% let "(time2-time1)*10" as delta %}
        Returned {{ book_list|length }} books in {{ delta|
floatformat:"-2" }} seconds.
    {% endblock %}
    ...

> -- or there's a bug in select_related

I also tried using select_related() with sqlite3, no gain there
either.

> > - Platforms are WinXP.
>
> Not to be facetious, but this may be part of the problem.

No worry, I understand.

> > - I user memcache/Win32, initial request is slow, subsequent requests
> > are faster,
>
> Err, does this mean subsequents are cache hits, or that the memcache
> client is slow at connecting, or something else?

The former: subsequent requests are cache hits. Actually, I tried all
3 caching mechanisms: per site, per view and low-level. The former was
easiest and fastest, but conflicting with @login_required (all my
views require login). The latter was, surprisingly, slower than no-
cache. The exact code for the low-level cache was:

    book_list = cache.get('all_books')
    if not book_list:
        book_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)]
    return render_to_response(...)

JJ.

> > - Each user can only see books which they have borrowed in the past or
> > who's technical area is theirs. So there's an extra query to filter
> > down the initial list of all books to the one they are actually
> > authorized to see.
>
> So you're caching the whole initial list and then filtering later?  Or
> you're caching the individual lists?  Or something else?


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to