How many rows does your script process? sqlplus running as a coprocessor is still interactive from sqlplus' perspective. Setting TERMOUT OFF obviously can't be done and your bottleneck is probably the KSH read loop (if you have thousands of records that you expect back). I had to reengineer a process for this very reason to open a REFCURSOR and spool the output to a file using sqlplus PRINT (from my coprocessor). If you are required to loop through the records, you can do this after-the-fact. The performance gain was dramatic in my case.
The coprocessor I/O pipe is apparently chocked by thousands of records or is simply an inefficient channel for passing many large character stings (mine where 250 bytes in one case and 3000 bytes in another).
On another note, you mentioned one thing that intrigues me:
Quote:
There is one more piece to this. Since I cannot predict how many lines will be output from the coprocessor, I use a "suicidal read" technique to stop the script waiting indefinitely on the pipe.
I would like to test this suicidal read myself. However, It isn't necessary if you post known termination messages from your script. That is to say, output something like "SQL-COMPLETE" after the SELECT, DBMS_OUTPUT, or REFCURSOR messages that you are expecting back. When you read messages back from the coprocessor, break when you find your termination message. My coprocessors never "freeze" since my resuls are allways predictable.