Delay in Massive CodeIgniter ajax processing

0

My code imports data from one database to another. To avoid server overhead, I'm importing 100 out of 100 records in each ajax. I noticed that in the first requests, it takes about 40ms, but as it sends more requests, the return time grows a lot to 80ms, 100ms to 400ms. I am using the mysql connection to the CodeIgniter framework; I'm also using, in a single part of the code, a mysqli connection from php, and closing it on every request. I do not understand why the number of requests is increasing, it will take longer. Is the CodeIgniter connection not closing as expected?

    
asked by anonymous 07.11.2016 / 15:27

1 answer

0

Vinicius, are you using AJAX to perform this import, why should it be triggered by the user only?

If possible, you can set up a cron job and run it automatically at a specific time.

In the cron job you can have a routine that would be as follows:

Make a select by getting the data to be imported, one table at a time, stores that data in variables (they will be an array or object), and then use CodeIgniter's batch process.

$this->db->insert_batch()

link

    
08.11.2016 / 20:14