Ask HN:在生产环境中运行 UPDATE 操作总是感觉比实际更耗时
2 分•作者: Lucy_Bai•20 天前
我很好奇,你们有多少人有过这种感觉:
你正在生产环境中。
改动很“简单”。
一个带有 WHERE 子句的小小的 UPDATE 或 DELETE 语句,你已经反复阅读过好几遍了。
然而,在按下回车键之前,总会有一个停顿。
这并不是因为你不懂 SQL。
也不是因为你没有仔细思考过。
而是因为你明白:
• 如果出错,责任在你
• 回滚操作并不总是干净或即时的
• 而最安全的选项往往是……“不要动它”
实际上,我见过人们通过以下方式来应对这种情况:
• 手动备份数据,“以防万一”
• 让另一个人和你一起盯着查询语句看
• 限制允许运行任何操作的人员
• 或者干脆避免直接在生产环境中修复问题
我不是在寻求最佳实践或工具建议。
我真心好奇:
当您必须更改数据,但无法 100% 确定它无害时,您个人会怎么做?
这仅仅是使用生产数据库时不可避免的一部分吗?
查看原文
I’m curious how many of you have felt this:<p>You’re in production.
The change is “simple”.
A small UPDATE or DELETE with a WHERE clause you’ve read over multiple times.<p>Still, right before hitting enter, there’s that pause.<p>Not because you don’t know SQL.
Not because you didn’t think it through.
But because you know:
•If this goes wrong, it’s on you
•Rollback isn’t always clean or instant
•And the safest option is often… “don’t touch it”<p>In reality, I’ve seen people deal with this by:
•Manually backing up data “just in case”
•Having someone else stare at the query with them
•Restricting who’s allowed to run anything at all
•Or simply avoiding fixing things directly in prod<p>I’m not asking for best practices or tooling advice.<p>I’m genuinely curious:<p>What do you personally do, when you have to change data and can’t be 100% sure it’s harmless?<p>Is this just an unavoidable part of working with production databases?