Skip to Main Content

SQL & PL/SQL

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!

Query execution time increases on subsequent executions after 10mins

MoazzamFeb 14 2014 — edited Feb 14 2014

We are trying to optimize the below query(SELECT statement from USERS table). On first time execution, it takes 47ms and on subsequent execution it takes averagely about 5ms. If I run it again after 10 minutes, it takes same 47ms on average.

Does it mean that I need to increase the size of SGA to retain the query/blocks there for longer time. The USERS table is a small table containing about 500 rows. Followings are SGA parameters. The machine is not being used actively because this is a dev database.

sga_max_size = 325MB

sga_target = 325MB

Query:

DECLARE

   v_id   number;

   v_user varchar2(100);

   v_password varchar2(1000);

   v_description varchar2(100);

   v_active char(1);

   v_update_time date;

  

   start_time   TIMESTAMP;

   end_time   TIMESTAMP;

BEGIN

   start_time := SYSTIMESTAMP;

   SELECT ID, name, password,description,active, update_time

     INTO v_id, v_user, v_password,v_description,v_active, v_update_time

     FROM USERS

    WHERE user_name = 'userName2';

   end_time := SYSTIMESTAMP;

DBMS_OUTPUT.PUT_LINE ( (EXTRACT (SECOND FROM end_time) - EXTRACT (SECOND FROM start_time)) * 1000);

END;

/

We are using Oracle 10g R2 with Linux.

This post has been answered by Karthick2003 on Feb 14 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 14 2014
Added on Feb 14 2014
3 comments
1,962 views