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

  • Home
  • SEARCH
  • 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 8269119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:07:11+00:00 2026-06-08T06:07:11+00:00

Our DBA just came back with a long running query against our SQL server

  • 0

Our DBA just came back with a long running query against our SQL server database. He thought we should review that query and see if we could optimize.

The problem is that the query doesn’t come from our application code. It is loading a number of records from a single table by their primary key, nine to be exact, and we NEVER have any queries to that table by primary key from our application. It is also definitely a hibernate query by the name mangling that hibernate does and the loading of all of the properties.

So I’m wondering if hibernate does some predictive caching, like pulling records it thinks I might want later. Any input on this?

Thanks.

  • 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-06-08T06:07:13+00:00Added an answer on June 8, 2026 at 6:07 am

    This is probably a query that is executed due to batch fetching:

    Using batch fetching, Hibernate can load several uninitialized proxies
    if one proxy is accessed. Batch fetching is an optimization of the
    lazy select fetching strategy.

    Batch fetching for classes/entities is easier to understand. Consider
    the following example: at runtime you have 25 Cat instances loaded in
    a Session, and each Cat has a reference to its owner, a Person. The
    Person class is mapped with a proxy, lazy=”true”. If you now iterate
    through all cats and call getOwner() on each, Hibernate will, by
    default, execute 25 SELECT statements to retrieve the proxied owners.
    You can tune this behavior by specifying a batch-size in the mapping
    of Person:

    <class name="Person" batch-size="10">...</class>
    

    Hibernate will now execute only three queries: the pattern is 10, 10,
    5.

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

Sidebar

Related Questions

Our application uses Hibernate with Sql Server 2005. Being a DBA, I am not
My DBA just lost some development work that he did on our development database.
I work at an eCommerce company. Our DBA recently told me that using SQL
Our DBA came to us with information that our LINQ queries are creating many
We are using SQL 2008 Transactional replication to replicate data from our production database
Recently we started to get some performance issues on our SQL Server. On analysis
In your experience, how often should Oracle database statistics be run? Our team of
Our company has a share point document server where the UNC looks something like
I'm trying to better understand why one of our database update scripts failed to
I have my production SQL Server in a remote data center(and the web servers

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.