简体   繁体   English

同时数据库查询导致数据库错误 max_user_connections

[英]Simultaneous database query causing database error max_user_connections

I'm trying to import the excel data to mysql database by PHP Ajax method.我正在尝试通过 PHP Z3EB7106C3477A560E6BBF5DBFDE1DAZ 方法将 excel 数据导入 mysql 数据库。 When the user upload an excel, the jQuery will fetch each row by loop and send it to PHP via ajax but there are about 500++ rows. When the user upload an excel, the jQuery will fetch each row by loop and send it to PHP via ajax but there are about 500++ rows. Due to that, the PHP is running the query simultaneously and causing the database error already has more than 'max_user_connections' active connections .因此,PHP 同时运行查询并导致数据库错误already has more than 'max_user_connections' active connections Some of the query are working but some not.一些查询正在工作,但有些没有。

the jQuery will fetch each row by loop and send it to PHP via ajax jQuery 将循环获取每一行并通过 ajax 将其发送到 PHP

...this is a design flaw. ...这是一个设计缺陷。 If you try to generate 500 AJAX requests in a short space of time it's inevitable, due to its asynchronous nature, that a lot of them will overlap and overload the server and database...but I think you've realised that already, from your description.如果您尝试在短时间内生成 500 个 AJAX 请求,由于其异步性质,它们中的许多将不可避免地重叠并使服务器和数据库过载……但我认为您已经意识到,从你的描述。

So you didn't really ask a question, but are you just looking for alternative implementation options?因此,您并没有真正提出问题,而是您只是在寻找替代实施方案吗?

It would make more sense to either这将更有意义

  1. just upload the whole file as-is and let the server-side code process it.只需按原样上传整个文件并让服务器端代码处理它。

Or或者

  1. If you must read it on the client-side, you should at least send all the rows in one AJAX request (eg as a JSON array or something).如果您必须在客户端读取它,您至少应该在一个 AJAX 请求中发送所有行(例如,作为 JSON 数组或其他东西)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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