Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are two things to consider when trying to speed this up:</p> <ol> <li>Execute this query only once for all sheetid's</li> <li>Make sure you are executing the same query each time, by not hardcoding the values in. Since these values possibly change, each query will look like the previous query, but with only a few different values. This won't allow Oracle to re-use the previous query and leads to non sharable SQL in the shared pool. This will fill up the shared pool. Do this long enough and you'll receive ORA-04031 error messages.</li> </ol> <p>The way to go is to use SQL types. Here is an example in PL/SQL. You can use the same principle in Java.</p> <p>First create a table with ten thousand sheetId's:</p> <pre><code>SQL&gt; create table worksheet (sheetid) 2 as 3 select level 4 from dual 5 connect by level &lt;= 10000 6 / Table created. </code></pre> <p>Create a SQL type:</p> <pre><code>SQL&gt; create type mynumbers is table of number; 2 / Type created. </code></pre> <p>In your code, fill an instance of the SQL type with the values in your "valuelist" and use the TABLE operator to transform the type to table values:</p> <pre><code>SQL&gt; declare 2 valuelist mynumbers := mynumbers(23,124,987,6123,8923,1,7139); 3 begin 4 for r in 5 ( select ws.sheetid 6 from worksheet ws 7 , table(valuelist) vl 8 where ws.sheetid = vl.column_value 9 ) 10 loop 11 dbms_output.put_line(r.sheetid); 12 end loop; 13 end; 14 / 1 23 124 987 6123 7139 8923 PL/SQL procedure successfully completed. </code></pre> <p>Now you have just one SQL in your shared pool and just one execution of this query, instead of thousands.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload