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 8117495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:11:24+00:00 2026-06-06T04:11:24+00:00

Hi i have a class which contains different methods for checking database values. Each

  • 0

Hi i have a class which contains different methods for checking database values.
Each method is for a particular table, so the select sql remains the same each time the method is called only the where clause value to be checked changes ,so i am using prepared statement

like

public boolean checkVal(Session session,String b,String c,String d)
    {
        String sql="select a from tbl_name where b=? and c=? " +
                "and d=? ";
        Query query=session.createSQLQuery(sql).addScalar("a",Hibernate.STRING);
        query.setParameter(0,b);
        query.setParameter(1,c);
        query.setParameter(2,d);

    if(){
some check and return
}
}

this method is to be called like 100000 times, so i think the sql will get regenerated and using a prepared statement here is useless, so what should i do to increase performance? what should be the right approach for doing this?

  • 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-06T04:11:27+00:00Added an answer on June 6, 2026 at 4:11 am

    The SQL String can be static and final; there’s no reason to recreate it each time.

    But that’s not your biggest problem.

    PreparedStatement was born for binding and repeated execution. There’s nothing better. The JDBC driver can cache the PreparedStatement once it’s parsed and validated, so you only do that work once.

    Have you measured performance and found a performance issue with this method? If not, don’t guess that you’ve got a problem until you have some data.

    I’d ask why the method has to be called repeatedly. Is it once each for 100,000 users? If yes, there’s nothing you can do except reduce your audience or eliminate the need for the call. (Think caching.) 100,000 for a single user? Figure out how to make one call or batch them. You’ll die a latent death with that arrangement. Hyperbole on your part? Take a deep breath, relax, and get some data.

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

Sidebar

Related Questions

I have an abstract class which contains method for setting header text. It looks
I have a class contains 10 methods which are doing almost the same things
I have a database table which contains an ID column and a Name column.
I have helper class which contain different methods. I dо not want to include
I have a class which contains a static collection that can be used across
I have a class which contains 5 properties. If any value is assingned to
I have a parent class which contains a child object. I am using set
Alright so here is the question. I have a user class which contains a
I have a class library project which contains some content files configured with the
I have class like this below shown. which contains the shopping items where the

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.