Plugin for MyBatis that keeps track of executed mapped statements

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Plugin for MyBatis that keeps track of executed mapped statements

mybatis-user mailing list
Dear group,

while working at a large web application that makes heavy usage of MyBatis I wanted to inspect how many statements get executed on a given site request. This information was used to optimise the application: discover dreadful selects in for-loops and finding slow queries. 

Thanks to the Plugin architecture in MyBatis this was very convenient to develop and I am quite happy with the results!

For example I can see all the mapped statements that were executed on certain JavaServer Faces page.

/app/secure/home/index.jsf
+------------------------------------------+-------+---------------+---------------+
| MappedStatement                          | Times | Min. Response | Max. Response |
+-------------------- ---------------------+-------+---------------+---------------+
| org.raupach.data.FooMapper.selectByValue |      7|              1|              4|
| org.raupach.data.FooMapper.selectOne     |      1|              6|              6|
+------------------------------------------+-------+---------------+---------------+

I know it is just a little plugin and it certainly needs more work, but feel free to use and modify if anyone is interested.

Here is the URL: https://github.com/raupachz/mybatis-profiler

Calling it profiler was a bit bold ;) 

happy hacking
/Björn

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Plugin for MyBatis that keeps track of executed mapped statements

Guy Rouillier-2
Björn, thanks for sharing your plugin.  Did you see the section on logging in the MyBatis User Guide?  You can use many of the common logging frameworks - log4j, slf4j, etc. - to log executed statements, including parameters if you want. 

--
Guy Rouillier

------ Original Message ------
From: "'Björn Raupach' via mybatis-user" <[hidden email]>
To: "mybatis-user" <[hidden email]>
Sent: 8/29/2017 8:12:45 AM
Subject: Plugin for MyBatis that keeps track of executed mapped statements

Dear group,

while working at a large web application that makes heavy usage of MyBatis I wanted to inspect how many statements get executed on a given site request. This information was used to optimise the application: discover dreadful selects in for-loops and finding slow queries. 

Thanks to the Plugin architecture in MyBatis this was very convenient to develop and I am quite happy with the results!

For example I can see all the mapped statements that were executed on certain JavaServer Faces page.

/app/secure/home/index.jsf
+------------------------------------------+-------+---------------+---------------+
| MappedStatement                          | Times | Min. Response | Max. Response |
+-------------------- ---------------------+-------+---------------+---------------+
| org.raupach.data.FooMapper.selectByValue |      7|              1|              4|
| org.raupach.data.FooMapper.selectOne     |      1|              6|              6|
+------------------------------------------+-------+---------------+---------------+

I know it is just a little plugin and it certainly needs more work, but feel free to use and modify if anyone is interested.


Calling it profiler was a bit bold ;) 

happy hacking
/Björn

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Plugin for MyBatis that keeps track of executed mapped statements

raupach

On 29. Aug 2017, at 23:27, Guy Rouillier <[hidden email]> wrote:

Björn, thanks for sharing your plugin.  Did you see the section on logging in the MyBatis User Guide?  You can use many of the common logging frameworks - log4j, slf4j, etc. - to log executed statements, including parameters if you want. 

Hi Guy,

yes, of course and MyBatis logging works really well! I go back to logging during debugging or when things go wrong. 

However we wanted a much smaller, aggregated report. Don’t care much about the parameters only the summary. Helps to find bottlenecks and what better to refactor next. Looks better in a before and after report.


--
Guy Rouillier

------ Original Message ------
From: "'Björn Raupach' via mybatis-user" <[hidden email]>
To: "mybatis-user" <[hidden email]>
Sent: 8/29/2017 8:12:45 AM
Subject: Plugin for MyBatis that keeps track of executed mapped statements

Dear group,

while working at a large web application that makes heavy usage of MyBatis I wanted to inspect how many statements get executed on a given site request. This information was used to optimise the application: discover dreadful selects in for-loops and finding slow queries. 

Thanks to the Plugin architecture in MyBatis this was very convenient to develop and I am quite happy with the results!

For example I can see all the mapped statements that were executed on certain JavaServer Faces page.

/app/secure/home/index.jsf
+------------------------------------------+-------+---------------+---------------+
| MappedStatement                          | Times | Min. Response | Max. Response |
+-------------------- ---------------------+-------+---------------+---------------+
| org.raupach.data.FooMapper.selectByValue |      7|              1|              4|
| org.raupach.data.FooMapper.selectOne     |      1|              6|              6|
+------------------------------------------+-------+---------------+---------------+

I know it is just a little plugin and it certainly needs more work, but feel free to use and modify if anyone is interested.


Calling it profiler was a bit bold ;) 

happy hacking
/Björn

-- 
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.