2026-06-16 | database · kernel | #postgresql #pg-kernel #gist #index #consistent #penalty #picksplit #point-ops #tsvector-ops #full-text-search #geometric-index #generalized-search-tree
拆解 PostgreSQL GiST 索引的抽象算子接口(Consistent/Union/Penalty/PickSplit)、深度优先搜索与 Consistent 过滤的组合逻辑、Penalty 引导插入路径与 PickSplit 决定分裂策略的完整流程,以及 point_ops 的几何距离搜索和 tsvector_ops 的全文搜索两种典型实现。读完你会理解为什么 GiST 能用一个通用框架支持十几种数据类型,以及它什么时候比 B-Tree 好、什么时候该用 GIN 替代。
2026-06-16 | database · kernel | #postgresql #pg-kernel #gin #inverted-index #full-text-search #tsvector #fast-update #pending-list #bitmap-scan #intarray
拆解 PostgreSQL GIN 索引的内部结构:entry tree、posting list、posting tree 三者各在什么条件下使用;Fast Update 的 pending list 设计与 gin_clean_pending_list 合并时机;gingetbitmap() 的 bitmap AND/OR 多关键词搜索合并流程;全文搜索 tsvector 与数组 _int4 的 GIN 实现;以及 GIN 与 GiST 在写性能、读性能、存储开销上的三角权衡和具体场景下的选择建议。