title: mysqli_query single query gerenating PHP fatal error: Allowed memory size exhausted
body: <p>I have a Mysql table (named "base") with <strong>3 million records</strong>, which is composed of only <strong>3 int(10) fields</strong>.</p>
  
  <p><a href="https://i.stack.imgur.com/joPTa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/joPTa.png" alt="enter image description here"></a></p>
  
  <p>When I try to run this simple query <code>$result = mysqli_query($db, 'SELECT * FROM base')</code>, php shows the error:</p>
  
  <blockquote>
    <p>PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted
    (tried to allocate 10485768 bytes) in C:\xampp\htdocs\combina.php on
    line 17</p>
  </blockquote>
  
  <p>I think mysqli_query should not load all the table records into memory, right?</p>
  
  <p>So why the memory overflow?</p>
  
  <p>I'm using <strong>XAMPP installation on Windows 10, PHP 7.2.</strong></p>
  
  <p>Here is the code: </p>
  
  <pre><code>$servername = "localhost";
  $username = "root";
  $password = "";
  $dbname = "comb";
  
  $db = mysqli_connect($servername, $username, $password, $dbname);
  if (!$db) {
      die("Falha na conexão: " . mysqli_connect_error());
  }
  $result = mysqli_query($db, 'SELECT * FROM base');
  </code></pre>