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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:49:48+00:00 2026-05-17T15:49:48+00:00

I was looking at a very slow SQL query (originating from a Java app

  • 0

I was looking at a very slow SQL query (originating from a Java app using Hibernate deployed in JBoss 5.1). This particular query returned about 10K records but still took 40s or more.

I ended up sniffing the traffic with the database (wireshark has a dissector for TNS) and found something unexpected. When data was coming from the server, each result row was in its own TNS packet. Furthermore, each TNS packet was acknowledged by the client (i.e. the app server) before the next one was sent from the database. For 10K records, there are 10K roundtrips to get a packet and acknowledge it. The impact on the performance is huge.

This is terribly inefficient. TCP allows larger packets and has a number of mechanisms (sliding windows, delayed ACKs) to reduce latency and increase throughput. However, in this case it’s the TNS protocol on top that adds its own negotiation.

If I run the same query from the Oracle’s SQL Developer, I don’t see this pattern. The query completes in about 1/10 of the time, without thousands of round trips.

Short version: Oracle’s wire protocol (TNS) seems to pass data in one TNS packet per query result row and requires each packet to be acknowledged by the client before the server sends the next one.

I’ve found some info about this [here][1] (scroll down until the section on ‘The SDU and TDU parameters in the tnsnames.ora file’).

And thus my question: is it possible to control the behaviour of the Oracle driver (I’m using 10.2.0.4.0) so the TNS protocol is more efficient? Again, this is a pretty standard J2EE app deployed in JBoss.

Thanks a lot!

  • 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-17T15:49:49+00:00Added an answer on May 17, 2026 at 3:49 pm

    Tune the SDU and TDU parameters in tnsnames.ora and listener.ora

    To set the batch size to 100 for the current statment.

      ((OracleStatement)stmt).setRowPrefetch (100);
    

    Note:

    Setting the prefetch size can affect
    the performance of an application.
    Increasing the prefetch size will
    reduce the number of round-trips
    required to get all the data, but will
    increase memory usage. This will
    depend on the number and size of the
    columns in the query and the number of
    rows expected to be returned. It will
    also depend on the memory and CPU
    loading of the JDBC client machine.
    The optimum for a standalone client
    application will be different from a
    heavily loaded application server. The
    speed and latency of the network
    connection should also be consideredconnection should also be considered

    (from Oracle Database JDBC Developer’s Guide and Reference )

    Available connection properties here.

    Also have a look at Oracle UCP too.

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

Sidebar

Related Questions

I'm looking to create a very small cataloguing app for personal use (although I'd
I am looking for a very fast way to filter down a collection in
I'm looking for a very simple tool to monitor the bandwidth of all my
I'm looking for a very specific eclipse plugin that will tell me if a
I'm looking for a very simple example of active record in .NET (code samples
I don't find the oft-used * to be very nice looking - can anyone
Looking to do a very small, quick 'n dirty side project. I like the
I am looking to create a very lightweight GUI front end in Windows. It's
I'm looking to implement a very basic shopping cart. Satchmo seems to install a
I'm looking for ideas for a heap-manager to handle a very specific situation: Lots

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.