Обсуждение: Number of SQL queries

Поиск
Список
Период
Сортировка

Number of SQL queries

От
Thomas Güttler
Дата:
I would like to know the number of sql queries which were executed during a http request.

Is there a way to get this number?

I would like to warn if a http request produces too many statements.

I am running a django application. If DEBUG is True, then django writes all queries into a list (connection.queries). 
But I would like to get this value from a production server. On the production server DEBUG is False and
connection.queries does not get filled by django.

It would be nice to get this value from psycopg2.

Regards,
   Thomas



-- 
Thomas Guettler http://www.thomas-guettler.de/
I am looking for feedback: https://github.com/guettli/programming-guidelines


R: Number of SQL queries

От
Federico Di Gregorio
Дата:

---- Thomas Güttler ha scritto ----

> I would like to know the number of sql queries which were executed during a http request.

>

>

>

> Is there a way to get this number?

>

>

>

> I would like to warn if a http request produces too many statements.

>

>

>

> I am running a django application. If DEBUG is True, then django writes all queries into a list (connection.queries).

>

> But I would like to get this value from a production server. On the production server DEBUG is False and

>

> connection.queries does not get filled by django.

>

>

>

> It would be nice to get this value from psycopg2.

psycopg2 doee not know about HTTP requests and if you enable connection pooling the same database connection is used multiple times. So no, you cant use psycopg to count the number of queries per request. Only Django can do that.

federico

Re: R: Number of SQL queries

От
Thomas Güttler
Дата:
thank you for your reply. I guess I will use this tool in the future:

https://github.com/jazzband/django-silk#requestresponse-bodies


Am 19.07.2018 um 12:05 schrieb Federico Di Gregorio:
> ---- Thomas Güttler ha scritto ----
> 
> 
>  > I would like to know the number of sql queries which were executed during a http request.
> 
>  >
> 
>  >
> 
>  >
> 
>  > Is there a way to get this number?
> 
>  >
> 
>  >
> 
>  >
> 
>  > I would like to warn if a http request produces too many statements.
> 
>  >
> 
>  >
> 
>  >
> 
>  > I am running a django application. If DEBUG is True, then django writes all queries into a list
(connection.queries).
> 
>  >
> 
>  > But I would like to get this value from a production server. On the production server DEBUG is False and
> 
>  >
> 
>  > connection.queries does not get filled by django.
> 
>  >
> 
>  >
> 
>  >
> 
>  > It would be nice to get this value from psycopg2.
> 
> 
> 
> psycopg2 doee not know about HTTP requests and if you enable connection pooling the same database connection is used

> multiple times. So no, you cant use psycopg to count the number of queries per request. Only Django can do that.
> 
> 
> federico
> 
> 
> 

-- 
Thomas Guettler http://www.thomas-guettler.de/
I am looking for feedback: https://github.com/guettli/programming-guidelines