Speeding up large numbers of mysql updates and inserts

前端 未结 4 1630
自闭症患者
自闭症患者 2020-12-05 16:38

I have an app that needs to update a large amount of data over a large number of entries. Basically it does some 7,000 inserts and/or updates but it takes a looooong time (l

4条回答
  •  一整个雨季
    2020-12-05 17:08

    If you're not already, use prepared statements (via either mysqli, PDO, or some other DB library that supports them). Reusing the same prepared statement and simply changing the parameter values will help speed things up, since the MySQL server only has to parse the query once.

    INSERTs can be batched by providing multiple sets of VALUES - a single query that inserts many rows is much faster than an equivalent number of individual queries each inserting one row.

提交回复
热议问题