gpt4 book ai didi

mysql - 效率: How many MySQL rows should I pull at a time?

转载 作者:行者123 更新时间:2023-11-29 08:12:14 25 4
gpt4 key购买 nike

现在,我有一个在 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 个大更新请求。这会比许多小的选择和更新请求更好吗?

我找不到关于此的太多信息。非常感谢!

最佳答案

关于性能,不应做出任何假设。您应该衡量事物才能做出决定。您应该定义性能目标,然后测试您的系统。我建议使用一些负载测试工具,例如 mysqlslaphammerdb 。如果您遇到问题,那么您可以使用某种分析器,例如 neor .

希望我有帮助!

关于mysql - 效率: How many MySQL rows should I pull at a time?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21340706/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com