MUY Belgium
MUY Belgium

Reputation: 2452

How to log SQL requests posted by a django application?

I have a quite slow admin interface in a django application, the application is supported by apache2 and PostgreSQL.

I suspect the problem to be unoptimized sql request but I cannot understand which one. I believe that a request is sent for every row instead of a request for all row.

Is it possible to log every sql requests actually sent to my database?

Thank for your advice.

Upvotes: 0

Views: 144

Answers (1)

user330315
user330315

Reputation:

Use the log_min_duration option in the configuration file:

http://www.postgresql.org/docs/current/static/runtime-config-logging.html#GUC-LOG-MIN-DURATION-STATEMENT

You might also want to install the auto-explain module which will also dump the execution plan of the slow queries to the log file.

More details here: http://www.postgresql.org/docs/current/static/auto-explain.html

Upvotes: 1

Related Questions