1189 queries is quite a large amount, are all of those really needed? I
think some profiling is in order.

On Mon, Jan 5, 2015 at 3:09 AM, Jani Tiainen <rede...@gmail.com> wrote:

> On Sun, 4 Jan 2015 20:41:58 -0800 (PST)
> Richard Brockie <richard.broc...@gmail.com> wrote:
>
> > Hello again,
> >
> > I'm to the point in my django development that I am beginning to use
> > realistic amounts of test data. I'm using postgresql as the database
> > server, with PyCharm as my IDE, everything in a virtualenv on an SSD on
> an
> > Ivy Bridge Core i7 processor with 16 GB of RAM running Windows 7 64-bit.
> >
> > One disappointing thing I have just encountered is the lack of speed when
> > working with my real-world data. I'm comparing this with the same data
> in a
> > non-framework-based php/MySQL webapp running on XAMPP (which means
> apache)
> > in parallel on the same system.
> >
> > With DjDT installed (Django development tools), I'm getting the following
> > stats:
> >
> >    - Quick to load page:SQL: 5 queries in 4 ms, Time: 76 ms
> >    - Slow to load page: SQL: 1189 queries in 463 ms, Time: 9754 ms
> >
> > From task manager, the slow to load page is making "python.exe *32" use 1
> > whole logical processor during the page load.
> >
> > Are these expected response times? I'm hoping this is the result of a
> > non-optimized development server, and not the expected performance of
> > Django itself.
> >
> > Any comments or advice?
>
> By judging amount of queries of your "slow" page you probably have
> model(s) with foreign keys that you lazy load - which means that each fk is
> loaded individually from the database with separate query.
>
> For example if you have a model that contains 4 foreign keys and you query
> 100 instances (rows) you would actually invoke 1 + 4 * n queries, which in
> example case would be 401.
>
> Without actually knowning your code one of the first options you usually
> do to optimize queries is to use select_related and prefetch_related
> queryset methods to cut down number of queries needed.
>
> --
>
> Jani Tiainen
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/20150105080927.4cc08eac%40jns42-l.w2k.keypro.fi
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALn3ei0wOncJGN00TG460MY%3DabuSqFm5bnd4SE77Hydngt-ybA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to