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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:42:47+00:00 2026-05-26T03:42:47+00:00

When running a performance benchmark for our data processing application we start with a

  • 0

When running a performance benchmark for our data processing application we start with a FOO_TABLE empty and then insert records from one thread while in another thread we select the same records from processing using a query like:

select * from FOO_TABLE where ID > ?

in conjunction with:

stmt.setMaxRows(5000);

in Java to limit the number of records selected in one chunk. (We don’t want to use BETWEEN here because the IDs have gaps). And we keep processing chunks of 5000 until the test is stopped.

Now, the performance of our application degrades over time and when I checked what happens on the Oracle side, I was surprised to notice that the query plan for “select * from FOO_TABLE where ID > ?” does a table scan instead of using the PK index on ID.

After restarting our application (but without truncating the table) Oracle came back to reason and used the PK index.

So, my explanation was that Oracle thought it’s a good idea to scan the table when it was nearly empty but then never revised this query plan. This brings me to my question: How often does oracle revise a query plan?

Was it because I restarted our application? I have some doubts about this, since we recycle our pooled connections after 1 hour (therefore no connection can be older than 1 h).

Was it because a certain amount of time had passed?

How would you force oracle to not do a scan even when the table is nearly empty?

Environment information:
– oracle 11g
– jdbc client (java 6)

UPDATE 10/25/2011: I did a regression test on Oracle 10g and the problem is the same, so it’s neither caused nor fixed by the dynamic cursor sharing. As Mark mentioned initially, the plan does not get revised unless there is a major event like structural changes or re-computing the table stats.

Eventually I’ve added a hint to force access by the PK, but I think the optimizer should have been able to figure this out. If there’s a PK that matches the search criteria, then go ahead and use even for small tables (where the performance difference is insignificant anyway).

  • 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-26T03:42:47+00:00Added an answer on May 26, 2026 at 3:42 am

    What version of Oracle?

    Generally,

    select * from FOO_TABLE where ID > ?
    

    would get hard parsed if the statement was not already in the shared pool. This would be the time that the execution plan would get generated.

    After that, the execution plan wouldn’t change unless something caused it to be invalidated. (drop/add an index to the table,drop a column from the table, recompute stats on the table, etc).

    11g has adaptive cursor sharing (which is why I asked the version of Oracle), and, without getting into a lot of details, it will peek at bind variable values and determine if a plan change is necessary, based on a new bind value.

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

Sidebar

Related Questions

I'm doing a performance study for a web application framework running on Apache Tomcat
I am running a program that does simple data processing: parses text populates dictionaries
I’m running some performance tests on an ASP.NET MVC application. I see a high
I'm running some performance tests on some .NET code that processes lots of data.
I am trying to compare the performance of a specific F# benchmark running on
I'm frequently running into performance issues when I XSL transform large amounts of data
When running performance tests file system cache hit or miss can significantly influence test
How much of a performance hit will running everything over TLS do to my
I've been having performance issues with a high traffic ASP.NET 2.0 site running on
I get the following error when running FXCop: CA1800 : Microsoft.Performance : 'obj', a

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.