In my case, since I’m running on Windows, I created the following PowerShell script: What’s great about this service is that it offers an API we could use to format SQL statements.ĭepending on the OS you are using, you can choose one of the provided options to call the SQLFormat service. If you ever attended my awesome trainings and workshops, then you already know that I’m using SQLFormat to format SQL statements generated by the test cases we are running during the training. Therefore, we need a way to format SQL statements on-demand only for the queries we are interested in analyzing.įor more details about how to configure datasource-proxy with Spring Boot, check out this article. While you could format the SQL statement at logging time, this is undesirable as it can complicate the log parsing logic that extracts log info and aggregates it (e.g., Elastic Stack). Type:Prepared, Batch:False, QuerySize:1, BatchSize:0 Name:dataSource, Connection:6, Time:0, Success:True ![]() Once you add datasource-proxy, SQL statements are going to be logged as follows: If you’re using Spring or Spring Boot, then my favorite SQL logging framework is datasource-proxy, which besides logging, allows us to detect N+1 query issues during testing. ![]() In this article, I’m going to show you how to format SQL using the command line and transform a single-line SQL statement into a multi-line SQL string that’s way more readable.Īs I explained in this article, logging your SQL queries is very important when using a data access framework that generates statements on your behalf, be it Hibernate or jOOQ. So, enjoy spending your time on the things you love rather than fixing performance issues in your production system on a Saturday night! Well, Hypersistence Optimizer is that tool!Īnd it works with Spring Boot, Spring Framework, Jakarta EE, Java EE, Quarkus, or Play Framework. Follow having a tool that can automatically detect JPA and Hibernate performance issues.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |