MySQL “Fire-And-Forget” INSERT / UPDATE / DELETE -

2019-07-04 02:13发布

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条回答
混吃等死
2楼-- · 2019-07-04 02:47

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!

查看更多
登录 后发表回答