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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:50:46+00:00 2026-06-06T18:50:46+00:00

Our software is deployed at a client site where they are having performance issues,

  • 0

Our software is deployed at a client site where they are having performance issues, they’ve hired a SQL consultant to look at the databases and see where their bottlenecks are.

One of the things the consultant spotted was that a lot of our statements where converting to nvarchar.
After some investigation I discovered that it was the PreparedStatement that was doing it.

To give you an example:

PreparedStatement query = connection.prepareStatement("SELECT * FROM sys.tables WHERE"
        + " name LIKE ?");
query.setString(1, "%%");

Becomes

declare @p1 int
set @p1=1
exec sp_prepexec @p1 output,N'@P0 nvarchar(4000)',N'SELECT * FROM sys.tables WHERE name LIKE @P0        ',N'%%'
select @p1

the adhoc executeQuery method on the other hand just sends the SQL through

ResultSet rs = connection.createStatement().executeQuery("SELECT * FROM sys.tables WHERE  name LIKE '%%'");

becomes

SELECT * FROM sys.tables WHERE  name LIKE '%%'

What I’m trying to work out is how bad this actually is. Prepared Statements are used all over our application because their use is supposed to be more efficient (if executed multiple times) than the adhoc queries.

Additionally I can’t see that the Microsoft guys would put something into their driver that they knew would cause performance issues.

Is this something that we should really be looking into, or is the consultant looking for issues where there aren’t any?

  • 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-06T18:50:48+00:00Added an answer on June 6, 2026 at 6:50 pm

    The pepared statement forces the query to become a parameterized query (which is a good thing), whereas the ad-hoc query may or may not be auto-parameterized by the SQL engine. In short, it’s not a major performance hit.

    However, there’s always a lot of debate about whether or not you should use parameterized stored procedures from a design perspective (not necessarilly a performance one). I think most DBA’s (and probably database consultants) prefer stored procedures because they’re easier to debug using traditional database management tools (as well as providing security benefits, and including parameterization by default).

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

Sidebar

Related Questions

A few years ago, TortoiseSVN 1.4.3 was deployed to our software development team and
For our software testing we have a test that lets us check to see
I am developing initscripts for some of our software, and am having difficulty deciding
Our software was installed on (customer site) Window Server 2008 R2 Foundation in Turkey
We want to build into our software the capability to build SQL queries freehand
Our software must be able to run on SQL Server 2000 and 2005. To
Occasionally some users of our software report issues that are caused by wired DirectoryNotFoundException
Our software has a swing panel that's used to list jdk installation paths. For
Our software has data to store, so it also install MYSQL, a root user
Our software is written in Java and comprise many (7) projects. These projects are

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.