title: Understanding memory usage of MySQL result in PHP (PDO)
body: <p>I am trying to understand why the memory usage for a single PDO result is so high. Here are a few things to know about the query/result:</p>
  
  <ul>
  <li>I am pulling a single <code>VARCHAR(6)</code> column from a single table</li>
  <li>The result is less than 30K rows</li>
  <li>This fetching this result uses ~12MB of memory in PHP (source: <code>memory_get_usage</code>)</li>
  <li>If I <code>json_encode</code> the result and dump it to a file, the actual data (in text form) is only ~1MB</li>
  <li>Using PHP7, MySQL 5.7, deployed on Ubuntu 14.04.</li>
  </ul>
  
  <p>My question is, where exactly does the 11MB of bloat come in? If the actual data in text form is only about 1MB, then 11MB seems like a lot of overhead just to parse the data in PHP. Is there a reason for this? Am I missing something?</p>
  
  <p>Edit:</p>
  
  <p>Just to clarify, I am looking for a technical explanation as to why the bloat exists, not a workaround for the issue.</p>