CodeIgniter Forums
How to handle Large no of inputs - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: How to handle Large no of inputs (/showthread.php?tid=81658)



How to handle Large no of inputs - lazyme114 - 04-04-2022

I have a form with dynamic number of inputs and it could reach up to 100k input fields. When I submit the form it is taking way to long to process and insert into database. Is there any way to make this process faster. I am using PHP (Codeignite 3) as programming language and mysql as database. Also when the form is in process of submitting all other pages will not load either. 
Its a software with inventory and POS and and when they buy the product I have to keep track of the product by serial no which is unique for each product. When they buy product sometimes its in tens of thousands in quantities so it requires all the fields.
It has a serial number auto generator which takes starting serial number and quantity and generates that number of serial numbers. eg. if I have 10 products coming with 3 having sn01-sn03, mn01-mn04 and ss01-ss-03. I would provide relative data like starting number sn01 and quantity 3 and it will generate that . and you don't need to scan/enter every item since the package cartoon box comes with the starting no and no of item in it. and since they might have some mismatch as well so I need all the input for that.
I need to send all the serial numbers which can amount to thousands of input fields. and when submitting the form it takes to long to insert in database and if I have any other active pages and wants to navigate to other pages, it will not, it waits for the process to be complete. I am using xampp. input fields can amount to 100k input fields
Stackoverflow link: php - How to handle Large no of inputs - Stack Overflow

Thanks for the help in advance...


RE: How to handle Large no of inputs - ignitedcms - 04-04-2022

Initial thoughts, 100K input fields sounds like a very very bad idea.


RE: How to handle Large no of inputs - demyr - 04-04-2022

For this kind of high volume things you can get benefit of php fpm or road runner etc. Keep your data tables INNODB not MYISAM.

But still your project design looks incorrect. I believe that you should redesign it. Or give us more detail with a real example so that we can help you better to design it.


RE: How to handle Large no of inputs - luckmoshy - 04-04-2022

I think you are asking for 100 form users simultaneously is it?????


RE: How to handle Large no of inputs - lazyme114 - 04-04-2022

Example in form
PHP Code:
for($i 1$i <= 100000$i++) {
    echo "<input type='hidden' name='serial_no[]' value='sn_{rand(10, 1000000)}' >";


in modal
PHP Code:
foreach($_POST['serial_no'] as $sn) {
  $data = array(some required data);
  $data['serial_no'] = $sn;
  $this->db->insert("table_name"$data);



I have updated the question in stackoverflow. Feel free to look at it.


RE: How to handle Large no of inputs - InsiteFX - 04-05-2022

If you have that many form inputs then I would be rethinking my application.


RE: How to handle Large no of inputs - lazyme114 - 04-05-2022

I only need to reduce the time taken to store in the database, the application is fine as it is. if the input fields are what making the issue, will autogenerating the serial number and inserting the data in the database 1000000 times take less times the inputing from the form? I don't think the impact will differ that much. I haven't face that kind of problems before so I don't know much about it. Plz help..


RE: How to handle Large no of inputs - lazyme114 - 04-11-2022

It seems that I only need to change the insert query to insert_batch it reduced the time significantly. Thanks for all your suggestions anyway.