I have been using Hibernate for a few years. In the last few days, I encountered a problem which I now seem to run out of ideas.
I need to run a query to a few tables, each of which has tens of millions of rows. The query is something like this (pseudo code):
Code:
select count(A.ID), A.GROUP_ID from A inner join B ... inner join C... where ... group by A.GROUP_ID
I am using Hibernate Core Version: 3.2.6-GA. Annotation: 3.3.1-GA. The Criteria API is used to implement the query. The program always hangs when it executes this query. Here is what I gathered:
1. With the debug turned on, I noticed that hanging happens right after the SQL statement printed out, and binding variables are set (no returned values were printed out)
2. If I copied the generated SQL statement, replace the binding variable (about 18 of them) with the values printed out, and paste the SQL in TOAD and execute it, the SQL returns the result in a few minutes.
3. If I ran the same java code against a smaller database, it ran fine. So it appears it is the data volume issue.
Has anyone run into this issue before? I'd be appreciated any tips or advice you may have.
Thanks,
AW