Welcome Guest, Not a member yet? Register   Sign In
My query returns empty results with big tables. Any advice?

I have never had problems with CI so far, but yesterday I started a project in which I have to handle big amounts of data, the database has approximately 10m rows on several tables and I'm struggling with a simple search function

My controller looks something like this. Its need to retrieve the username of the user by entering the email, ID or viceversa:

PHP Code:
public function username_finder() {

  $type $this->input->post('type');

  if ($type == 'email') {
    $this->form_validation->set_rules('input_string''Input String''trim|required|valid_email');
    if($this->form_validation->run() == FALSE) { } else {

      $input_string $this->input->post('input_string');
      $result $this->user_model->finder_engine($input_string$type);
      return $result;

The finder_engine on my model:

PHP Code:
public function finder_engine($input_string$type) {

 if ($type == 'email') {
    $query $this->db->get('members');
    return $query->result();

My members table looks like this:
id  | username | email | id_number | password

When I run this on the members table (10m rows) it returns and empty string.

I have tried with different versions but it always returns an empty array:
if ($type == 'email') {

   $query = "SELECT * FROM members WHERE email=?";
   $query = $this->db->query($query, array($input_string));
   return $query->result_array();


I duplicated the table and cut it off to 25000 rows, still empty, but when I run the same queries on the same table with 5000 records it returns the values perfectly. I guess this is a problem with the memory or with the execution time, but I have no idea. How can I approach this properly? What are good measures for CI regarding handling this amount of data?

Thanks a lot in advance!

Messages In This Thread
My query returns empty results with big tables. Any advice? - by HeyDarling - 09-14-2016, 02:08 PM

Theme © iAndrew 2016 - Forum software by © MyBB