0

I am working on a project which involves MySQL database which has billions of rows and building a Java based application on top of it. I am using Hibernate as ORM. While I execute a complex query on MySQL it is taking about 2.5 secs to execute where as in Hibernate the same query is taking about 8.9 secs. Are there any settings I need to change to reduce the execution time in Hibernate?

1 Answer 1

1

Hibernate is a bit slower than native - that's to be expected... Have you defined the indexes properly? Are you using lazy loading (you should be). What query is hibernate spitting out to fetch your data compared to the native (use hibernate.show_sql=true)

Sign up to request clarification or add additional context in comments.

1 Comment

The query I am using is: SELECT start_date, X, 'USER_[[:digit:]]+' AS Y, SUM(Z) FROM table_name WHERE ( Y REGEXP 'USER_[[:digit:]]+') AND X IN ("AAAA", "BBB" ) AND start_date >= "XXX" AND start_date < " YYY" GROUP BY X, startDate ORDER BY X} The database has a single table but not joins. I am using session.createSQLQuery to send the data to MySql. I used an index for X and start_date.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.