connection pool and inefficient query plan

There is a single query that covers almost 90% of cpu DB.

Select * from employee e, Department d where e.departement_id = d.department_id

Us will gather statistics for this table in two, and the issues is resolved.

This occurs every 2 weeks. That said, the query runs fine for 2 weeks and then we have questions... we will bring together the statistics of these two tables... and things are good for another 2 weeks.

This query is a proc to store oracle pl - sql, which is called by the JDBC code. I introduced 2 months behind connection pooling, and today, we are facing this problem.

The query has been accounting for 5 years with no problems.

Before that I presented the connection pool, the jdbc code created a new connection before calling the store proc.

Do you think that my connection to the connection pool has introduced this problem.

The DBA tell me that the query runs a bad plan. Oracle recovers not the more effective plan (and that leads to this high CPU utilization).

I guess that after 2 weeks Oracle begins to pick up plans that are effective in.

Do you think all that this question never has nothing to do with my connection pooling code.

I use Oracle 10 G.

Hi Mike and ground beach thanks for your response.

It was just a doubt... that you guys allowed.

Thank you

m

Tags: Database

Similar Questions

  • Alarm of inefficient query Plans

    SQL Server 5.6 cartridge DBSS - view Instance rule would give alarms for inefficient query Plans. Is it possible to get the same kind of alarms for Query Plans by using the SQL Server and SQL Performance Investigator 5.7 cartridge?

    The 'Notice of Performance' function is currently being re-worked in SQL Performance researcher and is therefore not available in version 5.7.

    The feature had become a bit bland in the analysis of the performance and I know that the development team has an exciting idea on how to return in a later version.  If you have something that you particularly liked, or an idea of how opinions can be improved, we will appreciate the feedback.

  • Connection pool with the OAS and the optimal value of min/max

    Hello world


    I have ", works with admin app to implement under oracle application server connection pool. The current value is min = 0, max = unlimited which I think means not implemented connection pool.

    Anyway I don't have a lot of information on connection pooling, I searched the forums, but I'm not able to find any useful information.


    My Manager would like to know what is the optimal value for min/max for the database, is there a specific formula or a tool that can help me on this issue?


    Thanks in advance.

    Hello

    It's a specific formula or a tool that can help me on this issue?

    The value that you specify for the number of connections and connections Min depends on a combination of factors, including the size and configuration of your database server and the type of the SQL operations that
    your application runs.

    For connection pooling,.
    First, check what is the value of 'process' located on the end of DB (for your current value, check v$ resource_limit at the end of db)...
    for example if the process is set to "1000", you cannot set the maximum value of the connection pool to the end server application above 1000 it will crash your database.

    now on the server side Application.
    As a best practice, set the maximum number of open connections and Minimum of connections open to the same value.

    For more details on connection pool and its settings.
    Check "Setting Up Data Sources - Performance Issues" of the link pdf below

    docs.oracle.com/cd/B14099_19/core.1012/b14001.pdf

    Hope that it would be useful

    Concerning
    Fabian

  • Session settings and connection pools

    Hello

    Suppose that I run a command like 'ALTER SESSION SET WORKAREA_SIZE_POLICY = MANUAL' inside a stored procedure called via JDBC and then releases the connection to the pool.  When the connection is next reused by a thread of Weblogic completely independent is it possible that the default setting may be inherited by the new thread?

    I realize that there is a conceptual difference between a process, a connection and a session so, theoretically, the answer to my question should be 'no '.

    But is this the case in real life?

    -Tony

    The pool is a collection of putatively identical connections agnostic. If you change a connection given by means non-JDBC (specific to the SQL DBMS, opaque stored procedures etc.)

    the session of DBMS, associated with the connection is changed permanently and Weblogic knows nothing about it. Yes this state persists as long as the session/connection

    rest and the next user of the connection when it is returned to the pool and out again will inherit the default behavior.

  • I m error when i m to access the Manager version alb 3. "expired.the timeout period elapsed prior to obtaining a connection from the pool.this have bcz grouped all connection used and maximum pool size has been reached.

    Hi team,

    I m error when i m to access the Manager version alb 3. "expired.the timeout period elapsed prior to obtaining a connection from the pool.this have bcz grouped all connection used and maximum pool size has been reached.

    Please provide the solution.

    Concerning

    Ajay

    Discussion moved from the Knowledge Base of VMware Lab Manager

  • Global temporary Tables from Oracle and connection pooling

    When grouping, connection ('maintain connections' in cfadmin) is enabled. Oracle Global Temporary tables is screwed up. Bleeding of a page of data request to another because CF is reusing the same Oracle session over and over again.

    Is there a JDBC driver that will allow the use of global Temp Tables while having enabled connection pooling? 

    Other applications, such as Oracle Application Server servers, somehow allow the pooling and work together harmoniously TWG.

    If your temporary tables created with the default setting of validation remove lines, the cftransaction tag will help you.  Copy the following code:



    insert into t_dan_test values (1)


    Select * from t_dan_test



    Select * from t_dan_test


    a 1 1 x sheet of dumping and x 2 0 dumping.

  • TAF pool and connection

    Hi all

    (1) I am aware that when client-side TAF is configured with LOAD_BALANCE = YES/FAILOVER = ON / normal FAILOVER_MODE(TYPE=SELECT,MODE=BASIC) DSS queries select would failover to the surviving node and terminate properly in case of crash of the primary node. What happens when an application connects to the RAC database using a connection pool. Assume that the connection pool had 10 live connections in the RAC database at the time of the accident of the primary node. 10 connections pool connction would fail on the surviving node with the above updated TAF in place?

    (2) TAF does not manage the LMD. The only way to gracefully handle DML failover is to configure the FAN where the RAC database propagates events to subscribing applications which, in turn, would take appropriate measures to rerun the LMD on the surviving node. Is this a correct statement?

    Thank you

    Hello

    What is the connection pool you use? A conn JDBC pool or pool connections DRCP 11 g? Assumming that makes connections connection pool to the database of x then there x sessions which are shared. One of these sessions on the crashed instance fail over to the other node. How your connection pool faces the one - can not say. While flight statenments SELECT SQL will be executed from the start so that the application would be to see a break (while the statement caught up) and then starts to run again.

    You are right in that if a session has performed DML it does tilt and generates an error; even of the SESSIONS of "ALTER", which the application can be run going to be rubbed, packaged variables reset etc etc. TAF is not big im afraid - Oracle appear to put less emphasis on these days TAF and more FAN (Fast Application Notification) because it allows the programmer to capture faulire events and perform a reset/reconnection and the like.

    Hope that heslp
    -Bob

  • Missing for DBAdapter cluster Weblogic Congfiguration outbound connection Pool entry

    Hello

    When I created an entry for outbound connection pool in DBAdapter weblogic console in a clustered (1-Admin server and servers managed by 2) environment and updated adapter DB, I have identified only input connection is updated in that plan a managed server and other server managed, it is not updated. For this reason, we are unable to access the data sources for some requests for the application.

    As a work-around if we plan. XML file to another server managed manually with update and DB adapter connection entry, we are able to find the entrance of connection for managed servers.

    Outside work around there at - it another solution to this problem so that I can add a connection adapter DB Console entry that will update the two plan files.

    Thank you and best regards,

    Vincent

    Can I propose to maintain the file plan of shared drive accessible from all nodes in the server, this will reduce the manual work.

    Concerning

    Albin I

    http://www.albinsblog.com/

  • vRO (vCO) HTTP-REST Workflow - connection pool closing

    Hi all - I've recently upgraded to vRealize Automation 6.2 and works collaboratively with vRealize Orchestrator to create workflows.  I created HTTP and REST workflows for request/release an IP address from our system IPAM (VitalQIP) and it seems to be failing with the description / the following exception:

    Connection pool stop (workflow: demand-IP-du-QIP / Scripting (item3) #14)

    vRO-1.pngvRO-2.png

    Looking for the schema > script line #14 is in red below:

    prepare the application

    Do not edit

    var inParamtersValues = [subnet, hostname, ddns, mac, type, w2kdom, comment];

    var request = restOperation.createRequest (inParamtersValues, null);

    Set the type of content query

    request.contentType = "";

    System.log ("request:" + request);

    System.log ("the request URL:" + request.fullUrl);

    Customize the request here

    request.setHeader ("HeaderName", "headerValue");

    run the query

    Do not edit

    var response = request.execute ();

    prepare the output parameters

    System.log ("response:" + response);

    statusCode = response.statusCode;

    statusCodeAttribute = statusCode;

    System.log ("status code:"+ statusCode ');

    contentLength = response.contentLength;

    headers = response.getAllHeaders ();

    contentAsString = response.contentAsString;

    System.log ("content in the string:" + contentAsString);

    Grep for IPaddress

    Patt var = ('forward IP");

    IPAddress = contentAsString.match (patt) m:System.NET.SocketAddress.ToString () var;

    IPAddress = ipaddress.split (/ [\s,] + /);

    IPAddress = ipaddress [2];

    System.log ("IP address: =" + ipaddress);

    vRO-3.png

    I'm not sure how to work around this problem and I'm looking for assistance because I'm fairly new to vRO.  Thank you very much!




    There is now an official fix for this problem: Technical preview of REST plugin version

    Please provide your comments.

  • API - POST - REST VCO connection pool closing

    Hello

    I'm working on an automation scenario where I need a VCO A workflow to start another workflow VCO B using the VCO REST Plugin (1.0.2) on VCO 5.1.1.

    I did it with success while creating a multitude of REST and surgery REMAINS by using the appropriate workflow. However, my approach is a lot of static and I need to create REST operations on the fly. I have had a look at workflows Plugin and try to do the same thing in my workflow.

    However I am stuck with the error 'Connection Pool close' when you try to run the POST request.

    My approach is to store the host REMAINS as a static attribute with VCO configuration object and retrieve it from there. I can run GET operations without any problem with the owner, i.e.


    restRequest = restHost.createRequest (restType, restUrl, restContent);

    restResponse = restRequest.execute ();

    My problem is actually running a POST operation. I prepared the content in XML format, which is

    " <-xmlns = execution context" http://www.VMware.com/VCO "> "
    < Parameters >

    < name parameter = "param1" type = "string" >

    < string > 1 < / string >

    < / parameter >

    < name parameter = "param2" type = "string" >

    < string > value2 < / string >

    < / parameter >

    < / Parameter >

    < / execution context >

    and use the content type "application/xml". Earlier in my code, I run a query GET to retrieve my ID for workflow target to create a Url like this:

    flow of work/98c3b8ee-9569-4940-acc1-b8fbc2e64649 / executions.

    This is code that I use to make the POST while creating an operation of REST when needed and delete it later.


    var restOperation = new RESTOperation (System.nextUUID ());

    restOperation.method = restType;

    restOperation.urlTemplate = restUrl;

    restOperation.defaultContentType = restContentType;

    restHost.addOperation (restOperation);

    RESTHostManager.updateHost (restHost);

    inputParameters var = [];

    var restRequest = restOperation.createRequest (inputParameters, restContent);

    restRequest.contentType = restContentType;

    var restResponse = restRequest.execute ();

    restHost.removeOperation (restOperation.id);

    RESTHostManager.updateHost (restHost);

    My code does not work when calling for the lifting of restRequest.execute: ' InternalError: connection pool arrested "." If anyone else has tried a similar scenario or has any idea what I may be missing?

    Thank you

    Bernd

    Thanks chap - update the objects did the trick.

    In my case, that initially caused the problem travel of COULD happen. Of course store the restHost object in the configuration of VCO leads to an out-of-date version at run time. I'm now store the ID of restHost only. Then, copy the following code works:

    var restHostId is System.getModule("my.library").myGetConfigAttr ("Folder", "VCO", "restHostId");.

    var restHost = RESTHostManager.getHost (restHostId);

    If (restType == 'GET') {}
    try {}
    restRequest = restHost.createRequest (restType, restUrl, restContent);
    restResponse = restRequest.execute ();
    }
    catch (exp) {throw ("request REST to run: cannot run '" + restType + "' '" + restUrl + "' request-reason = '" + exp + "'") ;}}
    }
    else {}
    try {}
    var restOperation = new RESTOperation (System.nextUUID ());
    restOperation.method = restType;
    restOperation.urlTemplate = restUrl;
    restOperation.defaultContentType = restContentType;
     
    restHost.addOperation (restOperation);
    RESTHostManager.updateHost (restHost);
     
    restHost = RESTHostManager.getHost (restHost.id);
    restOperation = restHost.getOperation (restOperation.id);

    inputParameters var = [];
    var restRequest = restOperation.createRequest (inputParameters, restContent);
    restRequest.contentType = restContentType;

    var restResponse = restRequest.execute ();

    restHost.removeOperation (restOperation.id);
    RESTHostManager.updateHost (restHost);
    }
    catch (exp) {throw ("request REST to run: cannot run '" + restType + "' '" + restUrl + "' request-reason = '" + exp + "'") ;}}
    }

  • SQL Plugin - connection pool &amp; retries

    People-

    We use vCO workflows which a lot of CRUD operations on the database. In light of these are long-running workflows with a decent amount of load, we want to make sure that this solution we have in place is efficient and reliable. To this end:

    1. we want to ensure that we are able to reuse the database connections - y at - it the notion of Pools of connections or equivalent.

    2 How about reconnecting to the db when it falls down? Is that something it will take the code in the workflow through say managers of exceptions etc..

    I'm sure that others have encountered similar problems - would appreciate all comments that you may have.

    See you soon.

    Hello

    Unfortunately does not support the plugin SQL connection pooling. We have never considered it. We will discuss it and may include in the next version of the plugin update.

    Regarding your second question - we don't keep connection open for a long time and call evry DB is atomic. When you run workflows CRUD a new conncetion is created, the corresponding SQL query is executed / clerk and the connection is closed. If there is a problem, as the disconnection of the server Oracle, the right way to ensure that your operation has passed is to write a custom error handling by using the Scripting of the Orchestrator features. In pseudo-code:

    var hasPassed = false;
    for (i = 0; i< maxretries="" -1="" &&="" !haspassed="" ;="" i++)="">

    hasPassed = false;

    try {}

    Execute the statement using the JDBC API exposed or by using CRUD actions

    hasPassed = true;

    } catch (error) {}

    Save the problem

    }

    }

    Hope this helps you. Any additional comments will be great.

    Best regards

    Boyan

  • OBIEE 11 g - connection Pool &gt; Execute before application procedural error.

    Hello

    I am trying to run a stored procedure before running a query. Thus in the Connection Pool > Login Scripts > before Execute Query, I have the following code.
    BEGIN PRC_RUN_MV_JOBS();  
    END;
    I call a DBMS_JOB. RUN the PRC_RUN_MV_JOBS procedure (NUMBER of JOBS). It works fine when I run using Toad or SQL Developer.

    And I run a scan, I get the following error.
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 43113] Message returned from OBIS. [nQSError: 43119]
     Query Failed: [nQSError: 17001] Oracle Error code: 6550, message: ORA-06550: line 1, column 27: PLS-00103: Encountered the symbol "" when expecting one of the following: 
    begin case declare end exception exit for goto if loop mod null pragma raise return select update while with <an identifier> <a double-quoted delimited-identifier> <a bind variable> 
    << close current delete fetch lock insert open rollback savepoint set sql execute commit forall merge pipe The symbol "" was ignored. at OCI call OCIStmtExecute: BEGIN 
    PRC_RUN_MV_JOBS(); END;. [nQSError: 17011] SQL statement execution failed. (HY000)
    Can someone make me please how to fix this? Thanks in advance.

    Try this:

    BEGIN PRC_RUN_MV_JOBS;  END;
    

    Best regards
    Kalyan Chukkapalli
    http://123obi.com

  • How to compile the connection pool java example code

    I recently bought David Knox of 'Effective Oracle Database 10' g security by Design and worked through his examples with identifiers of customers and how to exploit the database security with anonymous connections pools.

    The side of the things database I totally understand and have implemented, but I now want to compile / the java run the examples of code, but do not know what is required to compile this.

    I am running Oracle 10.2.0.4 (64-bit) Enterprise Edition on a Linux (RHEL 5) PC. Version Java is 1.6.0_20. .Bash_profile relevant environment variables are:
    export LD_LIBRARY_PATH = $ORACLE_HOME/lib: / lib: / usr/lib
    Export CLASSPATH = $ORACLE_HOME/jre: $ORACLE_HOME/jlib: $ORACLE_HOME/rdbms/jlib
    export PATH = $ORACLE_HOME/bin: $ORACLE_HOME/OPatch: / usr/kerberos/bin: / usr/local/bin: / bin: / usr/bin

    When I try to compile, I get:
    Oracle Java: DB10204$ FastConnect.java
    Exception in thread "main" java.lang.NoClassDefFoundError: java/FastConnect
    Caused by: java.lang.ClassNotFoundException: FastConnect.java
    in java.net.URLClassLoader$ 1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged (Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    to Sun.misc.Launcher$appclassloader$ AppClassLoader.loadClass (Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    The main class is not found: FastConnect.java. Program ends.

    Below is an example java source code. Is anyone able to point me in the right direction as to how to get this to compile? I have just a configuration syntax change and/or the environment to do, or there it more for this example doesn't work? Any help much appreciated.
    oracle:DB10204$   cat FastConnect.java 
    package OSBD;
    import java.sql.*;
    import oracle.jdbc.pool.OracleDataSource;
    
    public class FastConnect
    {
      public static void main(String[] args)
      {
        long connectTime=0, connectionStart=0, connectionStop=0;
        long connectTime2=0, connectionStart2=0, connectionStop2=0;
        ConnMgr cm = new ConnMgr();
        // time first connection. This connection initializes pool.
        connectionStart = System.currentTimeMillis();
        Connection conn = cm.getConnection("SCOTT");
        connectionStop = System.currentTimeMillis();
        String query = "select ename, job, sal from person_view";
        try {
          // show security by querying from View
          Statement stmt = conn.createStatement();
          ResultSet rset = stmt.executeQuery(query);
          while (rset.next()) {
            System.out.println("Name:   " + rset.getString(1));
            System.out.println("Job:    " + rset.getString(2));
            System.out.println("Salary: " + rset.getString(3));
        }
          stmt.close();
          rset.close();
          // close the connection which resets the database session
          cm.closeConnection(conn);
          // time subsequent connection as different user
          connectionStart2 = System.currentTimeMillis();
          conn = cm.getConnection("KING");
          connectionStop2 = System.currentTimeMillis();
          // ensure database can distinguish this new user
          stmt = conn.createStatement();
          rset = stmt.executeQuery(query);
          while (rset.next()) {
            System.out.println("Name:   " + rset.getString(1));
            System.out.println("Job:    " + rset.getString(2));
            System.out.println("Salary: " + rset.getString(3));
          }
          stmt.close();
          rset.close();
          cm.closeConnection(conn);
        } catch (Exception e)    { System.out.println(e.toString()); }
        // print timing results
        connectTime = (connectionStop - connectionStart);
        System.out.println("Connection time for Pool: " + connectTime + " ms.");
        connectTime2 = (connectionStop2 - connectionStart2);
        System.out.println("Subsequent connection time: " +
                            connectTime2 + " ms.");
      }
    }
    Code download is: http://www.mhprofessional.com/getpage.php?c=oraclepress_downloads.php & cat = 4222
    I'm looking at Chapter 6.

    I extracted the .jar (jar - xvf) file

    The ODBC .jar file? Don't, don't. Add it to your classpath as it is, or paste it into the WEB-INF/lib directory, or what you have to do.

  • Query Plan changes when a static value is assigned to an update

    I have a table
    SQL> create table test
      2  as
      3  select '001' col
      4    from dual
      5  connect by level <= 15000
      6  /
    
    Table created.
    
    SQL> exec dbms_stats.gather_table_stats('SYSADM','TEST',CASCADE=>TRUE)
    
    PL/SQL procedure successfully completed.
    Now, I want to update the table so that each 5000 lines to be incremented as the value pass
    001.002... and so on.

    I did it.
    SQL> set autotrace traceonly explain
    SQL> set timing on
    SQL> update test t
      2     set col = (select to_char(trunc(rno/5000)+1,'fm009')
      3             from (select row_number() over(order by rowid) rno,
      4                               rowid
      5                     from test) t1
      6             where t.rowid = t1.rowid)
      7  /
    
    15000 rows updated.
    
    Elapsed: 00:03:49.06
    
    Execution Plan
    ----------------------------------------------------------
       0      UPDATE STATEMENT Optimizer=ALL_ROWS (Cost=8 Card=15000 Bytes=60000)
       1    0   UPDATE OF 'TEST'
       2    1     TABLE ACCESS (FULL) OF 'TEST' (TABLE) (Cost=8 Card=15000 Bytes=60000)
       3    1     VIEW (Cost=55 Card=15000 Bytes=375000)
       4    3       WINDOW (SORT) (Cost=55 Card=15000 Bytes=60000)
       5    4         TABLE ACCESS (FULL) OF 'TEST' (TABLE) (Cost=8 Card=15000 Bytes=60000)
    
    SQL> rollback
      2  /
    
    Rollback complete.
    
    Elapsed: 00:00:01.00
    It works very well. But what I discovered is. When I change the update above. And replace the
    TO_CHAR (trunc(RNO/5000) + 1, 'fm009') with a static value as '1' the query plan changes and
    It runs very quickly.
    SQL> update test t
      2     set col = (select '1'--to_char(trunc(rno/5000)+1,'fm009')
      3             from (select row_number() over(order by rowid) rno,
      4                               rowid
      5                     from test) t1
      6             where t.rowid = t1.rowid)
      7  /
    
    15000 rows updated.
    
    Elapsed: 00:00:00.01
    
    
    Execution Plan
    ----------------------------------------------------------
       0      UPDATE STATEMENT Optimizer=ALL_ROWS (Cost=8 Card=15000 Bytes =60000)
       1    0   UPDATE OF 'TEST'
       2    1     TABLE ACCESS (FULL) OF 'TEST' (TABLE) (Cost=8 Card=15000 Bytes=60000)
       3    1     TABLE ACCESS (BY USER ROWID) OF 'TEST' (TABLE) (Cost=1 Card=1 Bytes=4)
    
    SQL> rollback
      2  /
    
    Rollback complete.
    
    Elapsed: 00:00:01.00
    Why is it so. Can someone explain?

    Karthick_Arp wrote:
    SQL > update of test t
    2 set col = (select to_char (trunc(rno/5000) + 1, 'fm009'))
    3 from (select row_number() over (order by rowid) rno,
    4 rowid
    5 test) t1
    6 where t.rowid = t1.rowid)
    7.

    15000 lines to date.

    Execution plan
    ----------------------------------------------------------
    STATEMENT UPDATE 0 = ALL_ROWS optimizer (cost = card 8 = 15000 bytes = 60000)
    1 0 UPDATE OF 'TEST '.
    2 1 TABLE ACCESS (FULL) 'TEST' (TABLE) (cost = card 8 = 15000 bytes = 60000)
    3 1 VIEW (cost = map 55 = 15000 bytes = 375000)
    4 WINDOW 3 (TRI) (cost = map 55 = 15000 bytes = 60000)
    5 4 TABLE ACCESS (FULL) 'TEST' (TABLE) (cost = card 8 = 15000 bytes = 60000)

    SQL > update of test t
    2 set col = (select '1' - to_char (trunc(rno/5000) + 1, 'fm009'))
    3 from (select row_number() over (order by rowid) rno,
    4 rowid
    5 test) t1
    6 where t.rowid = t1.rowid)
    7.

    15000 lines to date.

    Execution plan
    ----------------------------------------------------------
    STATEMENT UPDATE 0 = ALL_ROWS optimizer (cost = card 8 = 15000 bytes = 60000)
    1 0 UPDATE OF 'TEST '.
    2 1 TABLE ACCESS (FULL) 'TEST' (TABLE) (cost = card 8 = 15000 bytes = 60000)
    3 1 ACCESS TABLE (BY USER ROWID) OF 'TEST' (TABLE) (cost = 1 card = 1 bytes = 4)

    Why is it so. Can someone explain?

    In addition to what Rob has already said, the answer to your question is: given that the optimizer is smart and recognizes that your WINDOW TYPE in your second query (aka NWR) is never accessible and therefore simply ignores this part of the application. It turns it to a simple statement like this:

    update test t
       set col = (select '1'
               from (select rowid
                       from test) t1
               where t.rowid = t1.rowid);
    

    who can simply access the TEST table for each row of rowid, while your first query should do recursively for each TEST line full table scan. Using a statistics AUTOTRACE, you should see a large difference in e/s logic for both statements.

    Using DBMS_XPLAN. DISPLAY could reveal more details what happens, if you're already on 9i or later version (seems to be 9iR2).

    Kind regards
    Randolf

    Oracle related blog stuff:
    http://Oracle-Randolf.blogspot.com/

    SQLTools ++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676 /.
    http://sourceforge.NET/projects/SQLT-pp/

  • Connection pool does not work.

    Nice day. all the

    I tried OracleConnectionPoolDataSource and OracleDataSource.

    And found that there is no difference in performance. And connections are not grouped according to me.

    My sample fill the table with the records and read and update simultaneously in two threads.

    Below is a code provided.

    < strong >

    A piece of < facilities > logs: each time new connection is created.

    ...

    connection = oracle.jdbc.driver.OracleConnection@1198891

    0 updatedNumber = 1

    Connection.Close = oracle.jdbc.driver.OracleConnection@1198891

    connection = oracle.jdbc.driver.OracleConnection@17725c4

    Connection.Close = oracle.jdbc.driver.OracleConnection@17725c4

    List.Size () = 10

    0, name_update0, name_desc0, name_status0, 2008-11-04, 2008-11-04.

    1, a1, c1, b1, 2008-11-04, 2008-11-04.

    ...

    view the logs files I see that every time new connection is created in both cases, if I use OracleConnectionPoolDataSource or OracleDataSource.

    < strong >

    Question: < facilities > can someone help me understand how to use the connection pool? And how to see with my own eyes that this works?

    DDL < strong > < facilities >:

    to run the program, we should create table:

    {color: #000080} CREATE TABLE TEST_RECORD1)

    ID NUMBER (10) NOT NULL PRIMARY KEY,

    NAME VARCHAR2 (255 BYTE),

    VARCHAR2 (255 BYTE) STATUS,

    DESCRIPTION VARCHAR2 (255 BYTE),

    START_DATE TIMESTAMP,

    END_DATE TIMESTAMP

    ); {color}

    < strong >

    < Facilities > Java code:

    package test.jdbc;

    import java.sql.Connection;

    import java.sql.PreparedStatement;

    import java.sql.ResultSet;

    import java.sql.ResultSetMetaData;

    import java.sql.SQLException;

    import java.sql.Statement;

    import java.util.ArrayList;

    import java.util.Date;

    import java.util.List;

    javax.sql.ConnectionPoolDataSource import;

    import javax.sql.DataSource;

    Import oracle.jdbc.pool.OracleConnectionPoolDataSource;

    Import oracle.jdbc.pool.OracleDataSource;

    public class TestConnectionPooling2 {}

    static data source data source;

    / * number of iterations * /.

    public static final long BASE_REPEAT_NUMBER = 5;

    public static final long RECORDS_NUMBER = 10;

    Public Shared Sub main (String [] args) throws Exception {}

    Here you can change the data source (shared or not), but the performance has won "t change

    setupDataSource (new OracleDataSource());

    setupDataSource (new OracleConnectionPoolDataSource());

    long startTime = System.currentTimeMillis ();

    own picture

    removeAllRecords ("the removal of test_record1");

    insert records into the table

    for (int i = 0; i & lt; RECORDS_NUMBER; i++) {

    insertRecord (i,

    «insert into TEST_RECORD1 (id, name, status, description, start_date, end_date) "»

    + " values (?, ?, ?, ?, ?, ?)");

    }

    wire installation that queries the data in table

    Wire th1 = new Thread ("thread 1") {}

    public void run() {}

    for (int i = 0; i & lt; BASE_REPEAT_NUMBER; i++) {

    retrieveRecords ("select * from test_record1 by id asc");

    Thread.Yield ();

    }

    }

    };

    wire installation that updates the data in table

    Th2 thread = new Thread ("thread 2") {}

    public void run() {}

    for (int counter = 0; counter & lt; BASE_REPEAT_NUMBER; counter ++) {}

    for (int i = 0; i & lt; RECORDS_NUMBER; i++) {

    performSingleUpdate (counter, i,

    "update TEST_RECORD1 set name =?, description =?, status =? where id =? ») ;

    Thread.Yield ();

    }

    }

    }

    };

    TH1.start ();

    Th2.start ();

    do not complete until the worker threads

    While (th1.isAlive (): th2.isAlive ()) {}

    Thread.Yield ();

    }

    long endTime = System.currentTimeMillis ();

    System.out.println ("execution time:" + (endTime - startTime) + "ms.");

    }

    private static Sub performSingleUpdate (long bar, long I, String sql) {}

    PreparedStatement stmt = null;

    Connection conn2 = getConnection().

    try {}

    stmt = conn2.prepareStatement (sql);

    long temp = counter * 10 + i;

    stmt.setString (1, "name_update" + temp);

    stmt.setString (2, "name_desc" + temp);

    stmt.setString (3, "name_status" + temp);

    stmt.setLong (4, i);

    int updatedNumber = stmt.executeUpdate ();

    System.out.println (counter + ".") updatedNumber = "+ updatedNumber);

    } catch (SQLException e) {}

    e.printStackTrace ();

    } {Finally

    try {}

    stmt. Close();

    } catch (SQLException e) {}

    e.printStackTrace ();

    }

    If (conn2! = null) {}

    closeConnection (conn2);

    }

    }

    }

    private public static void removeAllRecords (String deleteAllSQL) {}

    Statement stmt = null;

    Connection conn2 = getConnection().

    try {}

    stmt = conn2.createStatement ();

    int updatedNumber = stmt.executeUpdate (deleteAllSQL);

    System.out.println ("remove all records. updatedNumber = "+ updatedNumber);

    stmt. Close();

    } catch (SQLException e) {}

    e.printStackTrace ();

    } {Finally

    If (conn2! = null) {}

    closeConnection (conn2);

    }

    }

    }

    {} public static void retrieveRecords (String sql)

    List = new ArrayList();

    Statement stmt = null;

    ResultSet resultset = null;

    int recordsCounter = 0;

    Output connection getConnection() =;

    try {}

    stmt = connection.createStatement ();

    ResultSet = stmt.executeQuery (sql);

    While (resultset.next ()) {}

    Record NewRecord = new Record();

    recordsCounter ++;

    newRecord.setId (resultset.getLong ("id"));

    newRecord.setName (resultset.getString ('name'));

    newRecord.setDesc (resultset.getString ("description"));

    newRecord.setStatus (resultset.getString ("status"));

    newRecord.setStartDate (resultset.getDate ("start_Date"));

    newRecord.setEndDate (resultset.getDate ("end_Date"));

    List.Add (NewRecord);

    }

    } catch (SQLException e) {}

    e.printStackTrace ();

    } {Finally

    If (resultset! = null)

    try {}

    ResultSet.Close ();

    } catch (Exception e) {}

    e.printStackTrace ();

    }

    If (stmt! = null)

    try {}

    stmt. Close();

    } catch (Exception e) {}

    e.printStackTrace ();

    }

    If (connection! = null) {}

    closeConnection (connection);

    }

    }

    StringBuilder sb2 is new StringBuilder ("list.size () =" + list.size () + "\n");.

    for (int i = 0; i & lt; list.size (); i ++) {}

    Record (Record) = list.get (i);

    SB2. Append ("" + record.toString () + "\n");

    }

    System.out.println ("" + sb2);

    }

    {} public static void insertRecord (long counter, String sql)

    PreparedStatement stmt = null;

    Connection conn2 = getConnection().

    try {}

    stmt = conn2.prepareStatement (sql);

    stmt.setLong (1 wicket);

    stmt.setString (2, "a" + counter);

    stmt.setString (3, "b" + counter);

    stmt.setString (4 "c" + counter);

    stmt.setTimestamp (5, java.sql.Timestamp (System.currentTimeMillis ())) of new;

    stmt.setTimestamp (6, java.sql.Timestamp (System.currentTimeMillis ())) new;

    int updatedNumber = stmt.executeUpdate ();

    System.out.println (".insertNumber =" + counter + updatedNumber);

    } catch (SQLException e) {}

    e.printStackTrace ();

    } {Finally

    try {}

    stmt. Close();

    } catch (SQLException e) {}

    e.printStackTrace ();

    }

    If (conn2! = null) {}

    closeConnection (conn2);

    }

    }

    }

    Initial methods

    private static Sub setupDataSource(OracleDataSource oracleDataSource) throws SQLException {}

    OracleDataSource ds = oracleDataSource;

    ds.setUser ("akhlystov");

    ds.setPassword ("xallex");

    ds.setURL ("jdbc:oracle:thin:@localhost:1521:abc");

    dataSource = ds;

    }

    public static {DataSource getDataSource()

    Returns the data source;

    }

    private public static void closeConnection (connection) {}

    If (conn! = null) {}

    return;

    }

    System.out.println ("Connection.Close () =" + login + "\n");

    try {}

    Connection.Close;

    } catch (SQLException e) {}

    throw new RuntimeException)

    "application should not run when the database cannot close the connection");

    }

    }

    static connection Conn;

    public static {connection getConnection()

    /*

    * Uncomment to test without any source of data, unique connection if (conn is

    * null) {try {conn = getDataSource () .getConnection () ;} catch}}

    * (SQLException e) {e.printStackTrace () ;}} return conn;

    */

    try {}

    Fitting out = null;

    If (instanceof ConnectionPoolDataSource getDataSource()) {}

    connection = ((ConnectionPoolDataSource) getDataSource ()) .getPooledConnection () .getConnection ();

    } else {}

    connection = getDataSource () .getConnection ();

    }

    System.out.println ("connection =" + connection);

    return of connection;

    } catch (SQLException e) {}

    e.printStackTrace ();

    throw new RuntimeException ("application should not run when the database is not available");

    }

    }

    Record class

    public static class {Record

    long ID;

    The name of the string;

    String desc;

    Status string;

    Date startDate;

    Date endDate;

    {} public long getId()

    return the id;

    }

    public void setId (long id) {}

    This.ID = id;

    }

    public String getName() {}

    return the name.

    }

    public void setName (String name) {}

    myIdName = name;

    }

    public String getDesc() {}

    return of ESCR;

    }

    {} public void setDesc (String desc)

    This.DESC = desc;

    }

    public String getStatus() {}

    return the situation;

    }

    {} public void setStatus (string status)

    This.Status = status;

    }

    public Date getStartDate() {}

    return startDate;

    }

    {} public void setStartDate (Date startDate)

    this.startDate = startDate;

    }

    public Date getEndDate() {}

    return endDate;

    }

    {} public void setEndDate (Date endDate)

    this.endDate = endDate;

    }

    public String toString() {}

    return the id + ',' + name + ',' + desc + ',' + status + ',' startDate + ', ' + endDate + ".";

    }

    }

    }

    Published by: Alexandr Khlystov on 04.11.2008 14:20

    Relevant documentation for JDBC 9i drivers here is http://download.oracle.com/docs/cd/B10501_01/java.920/a96654/connpoca.htm#1056354.

    In the world of JDBC 9i driver, there was a distinction between a connection pool (consolidated connection) and a cache of connections.

    A connection pool is trying to eliminate overhead consumption and resources of connection / disconnection from the database. If the connection is going to be only reused so no reason to close the connection, just open it again.

    What a performance gain were you looking for? Only, you would see a performance gain if your application was constantly opening and closing of connections, demanding that all resources for Setup and take down communications database. When the connection is established there is no difference in the performance of the execution of SQL.

    You can see with

    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    
    import oracle.jdbc.pool.OracleConnectionPoolDataSource;
    import oracle.jdbc.pool.OracleDataSource;
    import oracle.jdbc.pool.OraclePooledConnection;
    
    public class TestConnectionCache {
    
      public static void exec(Connection conn) throws SQLException {
        ResultSet rs = conn.prepareStatement("select sys_context('USERENV','SESSIONID') from dual").executeQuery();
        rs.next();
        System.out.println("Session id: " + rs.getInt(1));
        conn.close();
      }
    
      public static void main(String[] args) throws SQLException {
    
        OracleDataSource ods = new OracleConnectionPoolDataSource();
        ods.setUser("...");
        ods.setPassword("...");
    
        // Construct the jdbc url.
        String host     = "...";
        String port     = "...";
        String instance = "...";
    
        String url =
          "jdbc:oracle:thin:@//" + host + ":" + port + "/" + instance
          ;
        ods.setURL(url);
    
        // No connection re-use.
        exec(ods.getConnection());
        exec(ods.getConnection());
    
        // Connection re-use. (Connection pooling)
        OraclePooledConnection opc = (OraclePooledConnection)((OracleConnectionPoolDataSource)ods).getPooledConnection();
        exec(opc.getConnection());
        exec(opc.getConnection());
      }
    }
    

    Product output similar to:

    Session id: 4110149
    Session id: 4110150
    Session id: 4110151
    Session id: 4110151
    

    Note: when the pooliing connection is used, the session of database id is the same. Call close() has not closed the physical connection.

    A cache of connections is a layer on top of pooled connections that manages the creation and destruction of the connections. There usually limits this link how much should be open and the maximum number of connections to allow. Then the cache is queried for a connection, it can return the one that is not in use or perhaps create a new.

    Later versions of the JDBC driver will greatly simplify managing your connections and here is the note of documentation:

    Note:
    The previous cache architecture, based on OracleConnectionCache and OracleConnectionCacheImpl, is discouraged. Oracle recommends that you take advantage of the new architecture, which is more powerful and offers better performance.

    Any reason you're not not using a newer driver?

Maybe you are looking for

  • Error Windows Update - 8E5E152, 8E5E03FA

    Original title: How can I fix the error message 8E5E152 I tried several times to download updates for Windows Vista, but get the error message 8E5E152.  How can I erase this?  Also 8E5E03FA

  • Error 'Check' [Fail] media startup

    Hello My laptop Dell XPS 14 purchased recently started throwing strange error 'Check' media [Fail] at boot time and does not start. I ran the Diagnostics but not found error. I did a few trails as allowing the start of the legacy, changing device boo

  • How can I quickly add a stroke color identical to a filled shape for hundreds of items selected at the same time

    I have an illustration with hundreds small Traoré forms are exactly adjacent. But Illustrator seems to show a small seemed however.Is there a way to select all objects of my and have a script their race with the same color as their individual filling

  • File Portal 4.3 not working-Mirage

    Does anyone have this feature work?-J' activated file Portal-tried a url setting and leave empty-restart IIS-restartedI can't get the file portal page. Even on the administration server. I don't see a portal or file Explorer page in IIS. I don't see

  • Upgrade and migration

    Hello Experts,I have a task to migrate RAC with physical standby on Windows 2008 for Oracle Linux with minimal downtime. The current version is 11.2.0.2 and target version can be 11.2.0.4 or 12cr1.I found a possible solution which follows measures1 u