Bilal Khalid
Bilal Khalid

Reputation: 95

Efficient Way of Loading Huge Amount of Data on PHP Web Page

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??

Upvotes: 0

Views: 2493

Answers (2)

Mitch Satchwell
Mitch Satchwell

Reputation: 4830

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/

Upvotes: 5

Germann Arlington
Germann Arlington

Reputation: 3353

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

Upvotes: 1

Related Questions