0

I am using code igniter(PHP) n MYSQL .I am extracting huge amount of data (around 60 thousand records from XML) into my mysql database.Then i am trying to load this data onto my web pages.I am successfully inserting data into my database using insert batch method of code igniter .But when I try to retrieve these records,it takes ages to load and display on the web page.

The approach I am using to insert data:

  $data = array(array('title' => 'My title' ,
  'name' => 'My Name' ,
  'date' => 'My date' ),
   array('title' =>'Another title','name'=> 'Another Name','date' =>'Another date'));

   $this->db->insert_batch('mytable', $data); 

I am simply using select statement to retrieve records from single table.

My question :

How can I retrieve huge amount of records efficiently without having delays in page loading and display??

2 Answers 2

5

You should look into pagination unless there is a very good reason to display 60,000 records to the user in one go.

CodeIgniter provides a pagination class, see documentation for details on how to use it along with example code:

http://ellislab.com/codeigniter/user-guide/libraries/pagination.html

If you need more guidance on how to use this than provided by the documentation above, the following tutorial may help:

http://phpmaster.com/pagination-with-codeigniter/

Sign up to request clarification or add additional context in comments.

2 Comments

@MitchS.i have got no problem with pagination and it is working fine if i test it with small amount of data.The problem is : I can't load huge amount of data and i can't display data onto the browser as it is is taking ages to read data from mysql.Any idea??
If you use pagination, you won't need to read and display huge amounts of data - you display a set amount per page instead and only need to load that.
1

If for some VERY GOOD reason you have to display ALL records together than you may want to looking into flushing the buffer periodically (every 100 records or so). Otherwise see MitchS's answer

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.