When trying to speed it up, there are two things to consider:
- Run this request only once for all
- Make sure you run the same query every time without encoding the values. Since these values ββmay change, each request will look like a previous request, but with only a few different values. This prevents Oracle from reusing the previous query and results in incompatible SQL in the shared pool. This will populate the shared pool. Do this long enough and you will receive ORA-04031 error messages.
The way to use is to use SQL types. Here is an example in PL / SQL. You can use the same principle in Java.
First create a table with ten thousand sheets:
SQL> create table worksheet (sheetid) 2 as 3 select level 4 from dual 5 connect by level <= 10000 6 / Table created.
Create an SQL Type:
SQL> create type mynumbers is table of number; 2 / Type created.
In your code, populate an instance of the SQL type with the values ββin your "valuelist" and use the TABLE statement to convert the type to table values:
SQL> 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.
Now you have only one SQL in your shared pool and only one execution of this query, not thousands.
Rob van Wijk
source share