Skip to content

Files

Latest commit

 

History

History

HibernateSpringBootLogSlowQueries

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Log Slow Queries Via DataSource-Proxy

Description: This application is a sample of logging only slow queries via DataSource-Proxy. A slow query is a query that has an execution time bigger than a specificed threshold in milliseconds.

Key points:

  • for Maven, add in pom.xml the DataSource-Proxy dependency
  • create an bean post processor to intercept the DataSource bean
  • wrap the DataSource bean via ProxyFactory and an implementation of MethodInterceptor
  • choose a threshold in milliseconds
  • define a listener and override afterQuery()

Output example:


If you need a deep dive into the performance recipes exposed in this repository then I am sure that you will love my book "Spring Boot Persistence Best Practices"If you need a hand of tips and illustrations of 100+ Java persistence performance issues then "Java Persistence Performance Illustrated Guide" is for you.