MySQL“即发即忘"插入/更新/删除 - 建议使用 mysql_unbuffered_query 吗? [英] MySQL "Fire-And-Forget" INSERT / UPDATE / DELETE - mysql_unbuffered_query usage advisable?

查看:59
本文介绍了MySQL“即发即忘"插入/更新/删除 - 建议使用 mysql_unbuffered_query 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们认为有很多查询是即发即忘".

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.

这听起来像是 mysql_unbuffered_query 的理想情况.

This sounds like an ideal case for mysql_unbuffered_query.

这是可取的吗?

我们使用的是 innodb,所以使用类似 INSERT DELAYED 的东西是不可能的.

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

谢谢!

推荐答案

阅读后 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.

似乎无缓冲查询select有用,因为更新、插入和删除没有结果集.

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".

那么,last_insert_idaffected_rows 是结果吗?我不相信,因为没有使用 mysql_fetch* 来获取这些信息.

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!

这篇关于MySQL“即发即忘"插入/更新/删除 - 建议使用 mysql_unbuffered_query 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆