MySQL “Fire-And-Forget” INSERT / UPDATE / DELETE - mysql_unbuffered_query usage advisable?

左心房为你撑大大i 提交于 2019-12-10 20:38:17

问题


We have quite a few queries we consider "fire and forget".

In the sense that these are just logging inserts, updates and such. Things that are not as critical, and data from which is never used on the front end the users sees.

This sounds like an ideal case for mysql_unbuffered_query.

Is this advisable?

We are using innodb so using something like INSERT DELAYED is not possible.

Thanks!


回答1:


After reading http://www.php.net/manual/en/mysqlinfo.concepts.buffering.php:

Following these characteristics buffered queries should be used in cases where you expect only a limited result set or need to know the amount of returned rows before reading all rows. Unbuffered mode should be used when you expect larger results.

Seem that unbuffered query are usefull only on select, because update, insert and delete have no result set.

I don't see any problem using unbuffered update, insert and delete except this:

Unless the full result set was fetched from the server no further queries can be sent over the same connection. Unbuffered queries can also be referred to as "use result".

So, are last_insert_id and affected_rows a result? I don't belive it, because no mysql_fetch* is done to get these infos.

So, if you experience an improve of performances using unbuffered query, use it!



来源:https://stackoverflow.com/questions/11065735/mysql-fire-and-forget-insert-update-delete-mysql-unbuffered-query-usage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!