If you use 10g or later, you can make the CONCAT () function more efficient with the MULTISET UNION statement:
FUNCTION concat ( iList1 IN ID_ARRAY, iList2 IN ID_ARRAY ) RETURN ID_ARRAY IS lConcat ID_ARRAY; BEGIN lConcat := iList1 MULTISET UNION iList2 A ; RETURN lConcat; END concat;
You can make things more efficient by filling in several different arrays and then calling MULTISET UNION once for all of them:
lConcat := iList1 MULTISET UNION iList2 MULTISET UNION iList3 MULTISET UNION iList4;
Using dynamic SQL - presumably to replace the various get_idsN()
functions - may be suitable for learning, but probably will not give you much, it will improve performance.
Temporary tables are not a good idea, because they work very poorly compared to what happens in memory.
source share