Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

PL/SQL sending compressed clob to AJAX Javascript

Hi everyone,

I'm sending huge huge information from my PL/SQL backend to my Javascript frontend, specifically I use apex.server.plugin to request my info and htp.prn to send the info.

Before, I used to send the information with apex_json.write, however, this takes too much time and right now I use htp.prn. Because the CLOB that I send to Javascript is around of 50MB, it takes 10 seconds to be sent, and 20 seconds to be downloaded in my frontend… right now, I'm sending my data as:

lc_res_clob := ‘{"data": “value1” … “data_99999999”: “value99999999”}’; --This is just an example
--I chunk my clob because it's really huge and can't be sent in one htp.prn
loop
       begin
           dbms_lob.read(lc_res_clob, v_amount, v_pos, v_buffer);
           v_pos := v_pos + v_amount;
           htp.prn(v_buffer);
       exception
           when no_data_found then
               exit;
           when others then
               null;
       end;
   end loop;

Basically, what I wanted to do is to compress this lc_res_clob, send it and decompress it in my front end, so I did:

DBMS_LOB.CREATETEMPORARY(l_blob, TRUE);
DBMS_LOB.CREATETEMPORARY(l_compressed_blob, TRUE);
DBMS_LOB.ConvertToBlob(l_blob, lc_res_clob, DBMS_LOB.LOBMAXSIZE, o1, o2, 0, c, w);
   
utl_compress.lz_compress(src => l_blob, dst => l_compressed_blob, quality => 1);

This reduces the time from 30 seconds to just 10, which is great (because time is really important in my app)… but I don't really know anything about gzip or other algorithms, so I don't know how to handle my http response in Javascript… maybe using lz_compress isn't the right way, I don't really know.

I will appreciate your help!

Comments
Post Details
Added on Jul 2 2024
3 comments
416 views