How to use force index with QueryDSL?

I am currently working on a project that uses queryDsl, jpa and hibernate with a mysql database. One of the generated queries took 625 seconds. Since I donโ€™t have the ability to change indexes on the table itself, but I can use the force index for the actual query, which reduces the query time to 0.62 seconds during testing, how to do this in QueryDSL?

+4
source share
1 answer

You cannot use the force index directly in Querydsl JPA, as such syntax is not supported. You can customize the rendering of Hibernate SQL, but it is not trivial http://www.znetdevelopment.com/blogs/2009/10/07/using-use-index-with-hibernatemysql/

I would recommend using SQL in this case. You can use SQL with Querydsl JPA using JPASQLQueryand HibernateSQLQuery.

0
source

All Articles