From the debug result, I can see my website browser timing is really long.
Basically I create 13000 items for the blog table. Seems like it takes not a long time to do sql query.
The debug result
My questions is how can I identify bottlenecks from debug result. Why it loads so slowly, takes near 20s. How can I reduce the domContentLoadedEvent and domloading Time.
Thanks.
Here's a direct answer to your question using Debug Toolbar: enable the profiling panel.
Note: this will remove the other panels if you don't have the default panels in the dictionary, as in the example.
Docs
settings.py
DEBUG_TOOLBAR_PANELS = {
'debug_toolbar.panels.profiling.ProfilingPanel',
}
Related
There are 60 Items in a region showing as a group of 10 rows, 6 Items each.
Initially Items are hidden and each group is getting shown based on a button click.
But the page is taking too long time (10 sec apx) to load the page, same goes for validation also.
Any help here...?
Did you take a look at the debug data ? It shows very clearly what specific section is consuming a lot of time. Once you know what is causing the page to be slow you can start working on a solution.
You can read about debug here: https://docs.oracle.com/database/apex-18.1/HTMDB/utilizing-debug-mode.htm#HTMDB10003
--Koen
Try to uncheck the True or False Actions of DA which Fire on Page load as much as you can.
Page will load fast or we can move few conditions to validation with a generic condition can be another approach of this solution.
I have a project in which I need to save or display multiple forms after saving data when the page load it takes several time to display whole content, please help me to suggest the good package of compressing static files, I have already used django-compressor and django-assets packages but didn't get any success.Any ither things I can apply here ??
What do you mean with 'it takes several time to display content', do you need to refresh your page multiple times or just it takes a few seconds to load the page?
If the rendering of the page takes a long time to render, you could try to find out why. Django debug toolbar (https://github.com/jazzband/django-debug-toolbar) is a good tool to get some insights to find some improvements.
If it's not possible to improve the rendering and most of the requests are made to the same form/data then you can take a look at the Django cache framework (https://docs.djangoproject.com/en/2.2/topics/cache/)
you can save the url of the static file in your database and using the url from the database you can load the files from the static folder . Also if it okay with your project you can use pagination
I've a model with approximately 150K rows.
It takes 1.3s to render the ListView for this model.
When I click the change link in the ListView I takes almost 2 minutes to render the change view.
Other models have normal render times for the edit view.
Any ideas how to speed this up?
Your best bet is to limit the number of returned rows and implement some type of pagination in your application.
Django conveniently implements a type of pagination
First of all, ask yourself these questions:
Do you have much work with your data in templates?
Can I do this work in a backend and in a template only render it?
Do I use pagination?
As I know pagination in Django implemented with LIMIT and OFFSET sql statements, which work not so quickly when you're having many pages. In our projects, we wrote a row SQL for this purpose which works a little bit faster.
Also, you can install Django Debug Toolbar which can show you what statements django ORM is executing and measure time.
I have a search field, which lets the user search books (filters records, which are retrieved with ember-data).
I have found that any access the store from the results computed property within my component (see jsbin) makes the typing into the search field very slow (noticeable on my PC, and terrible on smartphone).
Here is a screenshot of the Timeline pane when typing a search query. The displayed part show that every keypress causes A LOT of layout (the search field seems to rerendered on every keypress). I also provide the exported timeline which you can load into your dev tools as explained here
I have tried to recreate the issue in a jsfiddle, but it seems to work just fine. The difference might be that in the jsbin I am using fixtures, while in my app I retrieve data from a real API.
I don't understand what is causing this behavior. It may be hard to come to any conclusion from the data I can provide, but does anyone have any ideas? Has anyone experienced similar performance issues?
Update 2014-03-01
I should note that the performance hit only happens if the results computed property contains a call to the store. If I replace it with any other thing (like just returning [], or some random async method -- like $.get) it not display this performance hit.
Additionally, I should make it clear (in case you didn't read the code), that the results computed property is not called on every keypress, but only when the search is submitted.
This is not a Ember/Ember-data bug, but apparently a Google Chrome bug.
I have created a new question regarding the issue here
I have the following model
class Plugin(models.Model):
name = models.CharField(max_length=50)
# more fields
which represents a plugin that can be downloaded from my site. To track downloads, I have
class Download(models.Model):
plugin = models.ForiegnKey(Plugin)
timestamp = models.DateTimeField(auto_now=True)
So to build a view showing plugins sorted by downloads, I have the following query:
# pbd is plugins by download - commented here to prevent scrolling
pbd = Plugin.objects.annotate(dl_total=Count('download')).order_by('-dl_total')
Which works, but is very slow. With only 1,000 plugins, the avg. response is 3.6 - 3.9 seconds (devserver with local PostgreSQL db), where a similar view with a much simpler query (sorting by plugin release date) takes 160 ms or so.
I'm looking for suggestions on how to optimize this query. I'd really prefer that the query return Plugin objects (as opposed to using values) since I'm sharing the same template for the other views (Plugins by rating, Plugins by release date, etc.), so the template is expecting Plugin objects - plus I'm not sure how I would get things like the absolute_url without a reference to the plugin object.
Or, is my whole approach doomed to failure? Is there a better way to track downloads? I ultimately want to provide users some nice download statistics for the plugins they've uploaded - like downloads per day/week/month. Will I have to calculate and cache Downloads at some point?
EDIT: In my test dataset, there are somewhere between 10-20 Download instances per Plugin - in production I expect this number would be much higher for many of the plugins.
That does seem unusually slow. There's nothing obvious in your query that would cause that slowness, though. I've done very similar queries in the past, with larger datasets, and they have executed in milliseconds.
The only suggestion I have for now is to install the Django debug toolbar, and in its SQL tab find the offending query and go to EXPLAIN to get the database to tell you exactly what it is doing when it executes. If it's doing subqueries, for example, check that they are using an index - if not, you may need to define one manually in the db. If you like, post the result of EXPLAIN here and I'll help further if possible.
Annotations are obviously slow, as they need to update every record in the db.
One direct way would be to denormalize the db field. Use a download_count field on the plugin models that is incremented on the new save of Download. Use the sort by the aggregate query on Plugins.
If you think there are going to be too many downloads to update another record of the Plugin all the time, you can update the download_count field on the Plugin via a cron.