作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
现在,我有一个在 python 中执行以下操作的脚本:
infinite loop:
select 1 row from MySQL
works with row data
updates 1 row if needed in MySQL (<10% of the time)
一次选择和更新多于 1 行会加速我的脚本并处理更多行吗?如果是这样,我应该下拉多少行?我有一个带有 512 MB RAM 的小型 VPS。一次 1000 行会太多吗?太少了?
新的脚本逻辑将是:
infinite loop:
select 1000 rows from MySQL
loop 1000 times:
work with row data
appends mysql statement to string if update is required
runs the single update statement containing 10-50 commands
新逻辑将有 1 个大选择请求和 1 个大更新请求。这会比许多小的选择和更新请求更好吗?
我找不到关于此的太多信息。非常感谢!
最佳答案
关于性能,不应做出任何假设。您应该衡量事物才能做出决定。您应该定义性能目标,然后测试您的系统。我建议使用一些负载测试工具,例如 mysqlslap或hammerdb 。如果您遇到问题,那么您可以使用某种分析器,例如 neor .
希望我有帮助!
关于mysql - 效率: How many MySQL rows should I pull at a time?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21340706/
我是一名优秀的程序员,十分优秀!