I have to perform many selects from an Oracle external table.
I have 10 cursors that look a lot like this (ext_temp is the external table)
CURSOR F_CURSOR (day IN varchar,code Number,orig Number)
IS
select NVL(sum(table_4.f),0)
from ext_temp table_4
where
--couple of conditions here, irrelevant for the question at hand.
AND TO_CHAR(table_4.day,'YYYYMMDD') = day
AND table_4.CODE = code
AND table_4.ORIG = orig;
And the external table has about 22659 registers.
My script main loop looks like this
for each register in some_query: --22659 registers
open F_cursor(register.day,register.code,register.orig);
--open 9 more cursors
fetch F_cursor into some_var;
--fetch 9 more cursors, with the same structure
Queries are taking way to much. And I know from here that i can't have any indexes or DML.
So, is there a way of getting it to run faster? I can rewrite my plsql script, but i don't think I have time left.
Update: missed an important detail.
I'm not the owner or DBA of the database. That guy doesn't want any extra info (its about 3gb of data) in his database, and external tables is all we could get out of him. He doesnt allow us to create temporary tables. I don't pretend to question his reasons, but external tables is not the solution for this. So, we are stuck with them.