Encoding a large result set into a JSON
<p>I'm trying to encode a result set of more than 1 million rows x 50 columns, into a json, i'm creating a histogram with D3, and the queries works fine for small results like 50k or 100k rows, but when i started to use a bigger DB i get the following error:</p>

<blockquote>
  <p>Fatal error: Allowed memory size of 1073741824 bytes exhausted</p>
</blockquote>

<p>is there a solution that don't involve just giving all the memory to the process? (also, i can't limit the query, because for the histogram i need all the data)</p>