Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Speed of simple query to complicated view with few data increases after 3rd execution

blamaNov 29 2013 — edited Dec 11 2013

Hello everyone,

I'm developing an OLTP application where a complicated view exists that is queried often by the application through Tomcat.

The application itself uses a framework that generates the SQLs on the fly, so no parameter binding is possible.

What I experience is the following:

If I execute the query from the application, it always takes about 3 seconds to complete, also for subsequent runs (Tomcat uses ojdbc6.jar)

If I execute the same query from SQL Developer it is the same behaviour. If I execute from Toad, it's the same behaviour for the first two runs, afterwards it executes in <50ms.

I assume that it has something to do with plan creation/caching. How can I prove it and - best - fix it?

Right now I'm using 11.2 XE running on my laptop together with Tomcat. In production it will be on a 11.2 SE1.

The plan itself shows little to no cost. This is expected, as the tables are almost empty and all joins are indexed as needed (the last row of 103 steps is):

|   0 | SELECT STATEMENT                                         |                            | 1 |  4876 |26  (12)| 00:00:01 |

The statement itself is

  SELECT

    .....all view columns...

    FROM myview

   WHERE (myview.user_id = 1010)


The statement is always generated like this, but with changing user_id for different users. The plan ID is always the same, no matter what the user_id is.

Is it possible to have the queries fast from the beginning / 2nd run of the query?

Is is only happening on 11.2 XE and will be gone in 11.2 SE1?

Thank you & Best regards,

Blama

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jan 8 2014
Added on Nov 29 2013
4 comments
358 views