title: Export large dataset (JSON) from PostgreSQL
body: <p>I have a postgres database with geospatial data and I want to export certain parts of those as a GeoJSON.</p>
  
  <p>So I have a SQL-Command like the following:</p>
  
  <pre><code>SELECT jsonb_build_object ( 'some_test_data', jsonb_agg (ST_AsGeoJSON (ST_Transform (way, 4326))::jsonb)) as json
  FROM (
    SELECT way, name, highway
    FROM planet_osm_line
    LIMIT 10) result
  </code></pre>
  
  <p>and that basically works fine. I can also save it to a file and dump it directly to a file like so:</p>
  
  <pre><code>psql -qtAX -d my-database -f my_cool_sql_command.sql &gt; result.json
  </code></pre>
  
  <p>So my data is correct and usable, but now I'd like to remove the <code>LIMIT 10</code> and I get <code>ERROR:  total size of jsonb array elements exceeds the maximum of 268435455 bytes</code></p>
  
  <p>I've read that it's not easy to remove this 256MB limit of postgres... But I guess there are other ways to get my result?</p>