开发者

How to count the number of queries with DBIx::Class?

开发者 https://www.devze.com 2023-01-12 05:29 出处:网络
I\'m using DBIx::Class in a web context and I\'d like to display the number of SQL querie开发者_开发百科s performed and the time they took for the rendering of a page.

I'm using DBIx::Class in a web context and I'd like to display the number of SQL querie开发者_开发百科s performed and the time they took for the rendering of a page.

Any idea about how to implement that?


See the DBIx::Class cookbook on the "Profiling" section for examples on how to do that.

Simply enabling profiling via the DBIC_TRACE=1 environment variable will not do what you want, but you can sub-class DBIx::Class::Storage::Statistics (as per the linked cookbook example) and override query_start and query_end in a way that lets you count the SQL queries done.

The linked example is very close to what you want to achieve.

0

精彩评论

暂无评论...
验证码 换一张
取 消