On Sun, 4 Jan 2015 20:41:58 -0800 (PST)
Richard Brockie <
richard...@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