Help writing a query to transform rows with json data into 1 download file
Don't store JSON as bytea. Store it as jsonb or json.

Maybe I don't understand your question

ALTER TABLE table
  ALTER COLUMN data
  SET DATA TYPE jsonb USING encode(data, 'escape')::jsonb;


Then just do.. SELECT * FROM table WHERE job_id = 1


  My concern is if the bytea size is too large, I need to get one-row at a time, and extract the data from it.


Why? What does too large mean there? The way this works, you'll only encode one row at a time and send it to the client...