1

I have a spring batch application that uses Azure SQL server as a backend, I am using Hibernate to update the database.

Below is my Hibernate configuration

<bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager" lazy-init="true">
    <property name="sessionFactory" ref="sessionFactory" />
</bean>

<tx:annotation-driven transaction-manager="transactionManager"/>
<bean id="hibernateProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
    <property name="properties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.SQLServer2012Dialect</prop>
            <prop key="hibernate.show_sql">false</prop>
            <prop key="hibernate.format_sql">false</prop>
            <!-- <prop key="hibernate.hbm2ddl.auto">update</prop> -->
        </props>
    </property>
</bean>

<bean class="org.springframework.batch.core.scope.StepScope" />

<!-- DATA SOURCE -->
<bean id="demoDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" />
    <property name="url" value="jdbc:sqlserver://demo.database.windows.net:1433;database=sqldb;encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30;" />
    <property name="username" value="user1" />
    <property name="password" value="p@ssword1" />
</bean>

I want know all the list of queries and its average execution time, how do I achieve this?

One Developer
  • 99
  • 5
  • 43
  • 103

1 Answers1

0

You can check p6spy. This tool wraps your datasource and logs all queries along with their execution time.

Mahmoud Ben Hassine
  • 28,519
  • 3
  • 32
  • 50