Usually, I try to dig out some info on my problems from the Internet without asking questions, but this time - I'm kinda stuck... The problem is, that I have few huge tables containing JSON objects in rows. The final output is a JSON string with all of the objects, so it can be sent to our headquarters as a operational report. One, single report contains approx. 15GB of data in very specific structure. The report has this structure:
{header1:value,
header2:value,
[...]
sub_objects:[
sub_object1:[{row1tab1},{row2tab1}...(6GB of data, 14 milions of rows)],
sub_object2:[{row1tab2},{row2tab2}...(another 5GB of data, 6 milions of rows)],
sub_object3:[...]
]}
Now, the problem is that my query builds whole, complete 15GB's string on the database side, and then, it's unloaded to a text file using a Java console app, that I've written some time ago. It's nothing fancy - simple query and fetching data as binary stream directly to file.
The above process works fine, but the time is killing me (and soon - my boss will want to kill me also). It takes approx. 5 hours to build the complete string. What's funny - if I'll store the string in database - the unloading process takes only 5 minutes. But still - storing the string in database takes 5 hours.
I'm trying to find some different angle here to fetch the data during query execution on the server's side, so I'd build the complete string directly in file, and not on the database side.
Any help would be much appreciated! If you'll need any extra info on this - don't hesitate to ask - I'll try to provide as much as I can.
Thank you in advance! Tom