过期的 PostgreSQL 统计信息如何让一条查询慢 580 倍
📊 核心数据与事实(2026-11-24):
作者在 PostgreSQL 18.7 上复现:一次回填把 463,418 条订单标为 archived,而 ANALYZE 从未见过该状态,规划器估计只有 1 行,单客户查询从 0.05 ms 变成 29 ms,慢 580 倍。
• 原文实测切片:customer_id has no common list, and its n_distinct is -0.202, meaning 20.2% of the rows: about 1,012,000 customers, so five rows each, which is exact.
• 原文实测切片:From its file size and a default row width the planner put it at 187,200 rows, then took 0.5% of that for an equality: status = 'shipped' came out at 936 rows against 120,138.
• 原文实测切片:For country = 'PT' AND city = 'Lisbon' it multiplies the two shares as if they were independent, 1.99% × 1.54%, and gets 1,650 rows.
💡 对独立开发者的启发:
1/ 供给端造工具的门槛已被 AI 和开源抹平,独立开发者真正的护城河是「找准垂直业务场景 + 做好分发」。
2/ 面对新模型或开源组件先看三件事:许可证是否商用安全、API/推理边际成本降了多少、能不能直接嵌进现有变现工作流。
3/ 别去卷通用开发者轮子,把底层新能力包装成面向具体行业人群(电商、创作者、中小商家)傻瓜式交付结果的产品。
📅 日期:2026-11-24(北京时间)
📰 信息源出处:HackerNoon · Anatolii Zhadan(hackernoon.com)
🔗 原文:https://hackernoon.com/how-stale-postgresql-statistics-made-a-query-580-times-slower?source=rss
📡 归档:https://billionare.me/items/oc85npddfiev65y7vnjqfqv60
社媒成稿工作台 · 一键复制
飞书同步推送 · 含数据/日期/出处/启发