Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony Profiler Query Stack Trace

I have a portal made with Symfony 3.4 and Sonata Admin.

In a specific admin page there are a lot of generated queries. I used the profiler to track them down but I cannot see where they generated from:

enter image description here

There is the same query repeated a lot of times with different IDs:

enter image description here

Is there a way to understand where they are generated? I saw that post and it seems impossible to do at the moment:

https://github.com/doctrine/DoctrineBundle/issues/722

Can't I just drop a dump/die somewhere in the profiler to get the specific line?

like image 424
StockBreak Avatar asked Sep 10 '25 07:09

StockBreak


2 Answers

Since v1.11.0, Doctrine Bundle can display query backtrace in Symfony Profiler. This is may be helpful to find what code caused the specific query to be executed.

The feature is disabled by default but you can enable it using profiling_collect_backtrace configuration in your doctrine connection settings.

See https://symfony.com/blog/new-in-doctrinebundle-1-11-0#store-backtraces-when-profiling-queries for more information.

like image 90
Miroslav Šustek Avatar answered Sep 13 '25 10:09

Miroslav Šustek


I just found this plugin which is doing exactly what I need:

https://github.com/VincentChalnot/DoctrineDebugBundle

enter image description here

It seems to work fine and it's showing the stack trace from the query.

like image 22
StockBreak Avatar answered Sep 13 '25 11:09

StockBreak