Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report repeated queries #398

Closed
truizsanchez opened this issue Feb 8, 2020 · 1 comment
Closed

Report repeated queries #398

truizsanchez opened this issue Feb 8, 2020 · 1 comment

Comments

@truizsanchez
Copy link

Your tool seems fantastic to me, but in order to optimize data access through the django ORM, I miss a report on the number of queries that are repeated, since this may be indicative of not having used a select related, prefetch related , or some mistake such as a queryset within a for loop.

I have been using django-queryinspect https://github.com/dobarkod/django-queryinspect, which has been very useful for this purpose, but silk provides many other interesting tools, the ideal would be to have the best of both worlds.

As an advance in terms of analysis, I have seen how it could be carried out using a fork and / or a contribution, but I have been limited by the fact that the SQLQuery#query attribute already has the SQL formatted with the parameters already evaluated (usually ids), which makes it difficult to detect repeated queries. For example, if we have stored:

SELECT * FROM foo WHERE id = 42
SELECT * FROM foo WHERE id = 43

It makes it more difficult to detect repeated queries than if we had stored (in another attribute of the SQLQuery object for example), the query without evaluating:

SELECT * FROM foo WHERE id =?
SELECT * FROM foo WHERE id =?

Before thinking on my own a solution to this need, I would like to know what your opinion is about this feature. Thank you!

@truizsanchez
Copy link
Author

I've been testing it and it looks very nice. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants