Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6036747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:58:14+00:00 2026-05-23T05:58:14+00:00

I have a databas table with cca. 327 000 entries. (SQL Server 2005, Hibernate

  • 0

I have a databas table with cca. 327 000 entries. (SQL Server 2005, Hibernate 3) I have to generate a report that queries this table for 300 times. The Hql query looks like this:

select hist from HistoryTable hist where year(hist.date) = :year and 
        hist.user.userId = :userId and hist.entryType = :created

I need to wait 3 minutes for the report to be generated, so is there a way to optimize this query to run faster?
I though of returning the hist.id (because that is a primary key therefore it is indexed and I guess it is looked up faster) instead of the whole hist object and then retrieve the History object via its id? Maybe Hibernate does the same thing, and this is not neccessary, and then there is nothing to be done. Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T05:58:15+00:00Added an answer on May 23, 2026 at 5:58 am

    I don’t think it will help you that much to first retrieve the primary keys. That will only add to the number of queries you need to run (and consequently the time it takes).

    I’d rather have a look at the report and see if the number of queries could be reduced.
    Furthermore, i’d consider retrieving scalar values instead of full object instances if you are dealing with a large number of objects (Hibernate comes with an overhead compared to retrieving plain values from a database).

    I’d also make sure that all tables are properly indexed (test the queries and see how they perform).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database table in SQL Server 2005 Express that takes in 2367
I have a database table that uses Sql Server 2005's uniqueidentifier column. I know
I have a database table on a development server that is now fully populated
I have Database table and I am using SQL Server 2008. The table contins
I have a database table that i want to allow my friends to update.
I have a Database table that I want to display in a DataGridView. However,
I have a database table of topics that changes frequently. Let's say the table
I have a database table. It has several hundred entries and each entry is
i have a database table with a list of sql views i want to
I have a database table that represents Events. The table has 2 main fields

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.