on-internet
← Community

Subquery in from clause using HQL

Stack Overflow ·

I have a table articles with 500k rows. An article has a list of authors. I am trying to create a query to get the latest published article for a list of authors. I used the following HQL query which gets me what i want but runs pretty slow (~4s) select author, article from Article article inner join article.authors author where (author.id, article.publishedAt) in (select author.id, max(article.publishedAt) from Article article join article.authors author where author.id in (authors_list)) group by author.id A possible better query in plain sql would be: select * from ( select articles.id, aut

Comments

Sign in or sign up to comment and upvote.

No comments yet.