title: CodeIgniter incredibly slow on small page load
body: <p>So i am experiencing a problem I should probably only be having on big pages but instead im getting that on ANY page.</p>
  
  <p>I am trying to make a REST api using CodeIgniter and it works but any page I load is very very slow. I am talking 20-30 seconds page loads for a page worth 504 Bytes.</p>
  
  <p>I've added extra benchmarks and it displays it takes roughly 0.04 sec to download the data.</p>
  
  <p>Rankings.php (Controller)</p>
  
  <pre class="lang-php prettyprint-override"><code>class Rankings extends CI_Controller
  {
  
      public function __construct()
      {
          parent::__construct();
          $this-&gt;load-&gt;model('rankingsmodel');
      }
  
      /**
       * Index Page for this controller.
       */
      public function index()
      {
          $this-&gt;benchmark-&gt;mark('code_start');
  
          $rankings =$this-&gt;rankingsmodel-&gt;getAllRankings();
          $mappedRankings = array_map(array($this, 'mapRank'), $rankings, array_keys($rankings));
  
          $this-&gt;benchmark-&gt;mark('code_end');
          echo $this-&gt;benchmark-&gt;elapsed_time('code_start', 'code_end');
  
          return $this-&gt;jsonIFy($mappedRankings);
      }
  
      public function mapRank($ranking, $k)
      {
          $ranking['rank'] = $k;
          return $ranking;
      }
  
      public function jsonIFy(array $data = array())
      {
          echo json_encode($data);
      }
  }
  </code></pre>
  
  <p>And my rankingsmodel</p>
  
  <pre><code>class RankingsModel extends CI_Model
  {
      public function __construct()
      {
          parent::__construct();
      }
  
      public function getAllRankings()
      {
          $this-&gt;benchmark-&gt;mark('code_start2');
  
          $query =$this-&gt;db-&gt;query('SELECT * FROM characters3 WHERE gm &lt; 3 ORDER BY rebirths DESC')-&gt;result_array();
  
          $this-&gt;benchmark-&gt;mark('code_end2');
          echo $this-&gt;benchmark-&gt;elapsed_time('code_start2', 'code_end2');
          return $query;
      }
  }
  </code></pre>
  
  <p>I have absolutely no idea why page loads so incredibly slow while my benchmarks are saying it would take 0.03/0.04 to load. I've tried setting up xdebug but i've not had any luck setting it up. Im using regular mysqli drivers that come with codeigniter.</p>
  
  <p>Does anyone have any idea why it is so slow or any tool i can setup easily to debug?</p>
  
  <p>Thank you</p>