简体   繁体   中英

Importing data from files to database by the users of the site

It's necessary to allow users to import their data on the site (in mysql database). Every user who logs in, can import data from a file to the database and then work with them on the site. It takes a long time to import the data and creates a high load on the database as well. Could you please tell how to queue importing better? So the data would be imported at one online, but to queue data to be written periodically to the database. Thank you.

Perhaps insert delayed would help. From the manual:

Another major benefit of using INSERT DELAYED is that inserts from many clients are bundled together and written in one block. This is much faster than performing many separate inserts.

My suggestion would be to upload the .CSV file and post a message into a queue (or post the message on some other event like click on "Import" button). This way you will be able to return immediately and display a message like "Please wait for import". Then once the import is done and the database is updated the HTML page can refresh itself and display proper status. Depending on the servers and/or database load you can have only one or multiple simultaneous imports going on at the same time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM