I am working on a django-postgresql project and I need to see every query that django run on database(so I can fine-tune queries). Is there a way to get those queries. Update: My development environment is on ubuntu linux
相关问题
- Django __str__ returned non-string (type NoneType)
- Django & Amazon SES SMTP. Cannot send email
- Django check user group permissions
- Django restrict pages to certain users
- UnicodeEncodeError with attach_file on EmailMessag
相关文章
- postgresql 关于使用between and 中是字符串的问题
- postgresql 月份差计算问题
- how do I log requests and responses for debugging
- Using boolean expression in order by clause
- Table valued Parameter Equivalent in Postgresql
- Profiling Django with PyCharm
- in redshift postgresql can I skip columns with the
- Why doesn't Django enforce my unique_together
Check out this Question (and the two top most answers): django orm, how to view (or log) the executed query?
You can also have a look at the Djando documenation: https://docs.djangoproject.com/en/dev/faq/models/#how-can-i-see-the-raw-sql-queries-django-is-running
Hope this helps, Anton
You can decorate a request handler or other function with this and it will print the sql nicely formated with totals at the end.
Try the django debug toolbar. It'll show you all the SQL executed over the request. When something is executing way too many queries, it becomes really slow, though. For that, I've been meaning to try out this profiler. However, I've rolled this middleware on a couple of projects:
Just go to the relevant URL for the request you are interested in and add a
dbprof
GET
parameter, you'll see the profiling output instead of the normal response.Well, you could just set the pgsql server to log every query. Or just to log the slow ones. Look in the postgresql.conf file, it's pretty close to self-documenting.