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

Show stack trace of Doctrine query #30040

Closed
iluuu1994 opened this issue Jan 30, 2019 · 11 comments
Closed

Show stack trace of Doctrine query #30040

iluuu1994 opened this issue Jan 30, 2019 · 11 comments

Comments

@iluuu1994
Copy link
Contributor

Description

When a page executes too many queries it would be extremely useful to know where these queries are executed. Since these queries are generated by Doctrine it is very non-obvious where they are coming from.

Example

image

I would add another toggle "Show stack trace" that shows you exactly where the query was executed in your code.

@javiereguiluz
Copy link
Member

@iluuu1994 I agree that this would be great. However, it seems that Doctrine DBAL is not ready for this. Check doctrine/DoctrineBundle#722 (and duplicated issues like doctrine/DoctrineBundle#800).

So, I must close this and I hope that one day this is fixed in Doctrine and leveraged in DoctrineBundle. Thanks.

@iluuu1994
Copy link
Contributor Author

@javiereguiluz Thanks for investigating!

DBAL already has a DebugStack logger doing this

Is this not an option?

@javiereguiluz
Copy link
Member

Sadly that's not an option. The Doctrine data collector used in DoctrineBridge is already using it. However, as you can see in its code (https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Logging/DebugStack.php) it doesn't log who/where the query was executed. That's why we don't have that info in the data collected by Symfony:

symfony-demo-doctrine-collector

@iluuu1994
Copy link
Contributor Author

Bummer. Anyway, thanks @javiereguiluz!

@alcaeus
Copy link
Contributor

alcaeus commented May 10, 2019

Just to follow up, this was added in doctrine/DoctrineBundle#954 and will be released in version 1.11.0 of the Doctrine Bundle 👍

@iluuu1994
Copy link
Contributor Author

Hype! Thanks @ottaviano and @alcaeus!

@mayro
Copy link

mayro commented Nov 19, 2019

Hello @alcaeus,
I'm using doctrine 1.11.2 and i haven't this profiling, i have only the query...

@stof
Copy link
Member

stof commented Nov 20, 2019

@mayro due to the performance impact (it increases memory usages of the collected queries), you need to opt-in in your DoctrineBundle config (see profiling_collect_backtrace). It is turned off by default.

@mayro
Copy link

mayro commented Nov 20, 2019

Thanks @stof i enable the profilning_collect_backtrace, I can now trace the steps but anyway it doesn't log where the query was executed... I'm using the Master/Slave connection and i need to know in which Database my query executed

@stof
Copy link
Member

stof commented Nov 20, 2019

"in which connection of the Master/Slave" is not the same question than "where in the project", which is what a debug backtrace provides.

@mayro
Copy link

mayro commented Nov 20, 2019

@stof Thank you for clarifying that. so is there any way to know in which connection (Master or slave) the query was executed please ?

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

5 participants