title: Best way to fetch millions of records table using hibernate
body: <p>I am using mysql tables and would like to fetch more than 10 millions of data in a single query for reporting purposes.</p>
  
  <p>My table might contain foreign keys as well. I am using hibernate queries for fetching the data. The querying part alone is taking around 20-30 seconds.</p>
  
  <p>Is there a way I can optimise this ? Indexing the tables in mysql will be of any help?  </p>