官术网_书友最值得收藏!

Understanding PostgreSQL index types

So far, only binary trees have been discussed. However, in many cases, b-trees are just not enough. Why is that the case? As discussed in this chapter, b-trees are basically based on sorting. Operators <, <=, =, >=, and > can be handled using b-trees. The trouble is, not all.

Data types can be sorted in a useful way. Just imagine a polygon. How would you sort these objects in a useful way? Sure, you can sort by the area covered, its length or so, but doing this won't allow you to actually find them using a geometric search.

The solution to the problem is to provide more than just one index type. Each index will serve a special purpose and do exactly what is needed. The following index types are available (as of PostgreSQL 10.0):

test=# SELECT * FROM pg_am;
amname | amhandler | amtype
---------+-------------+--------
btree | bthandler | i
hash | hashhandler | i
GiST | GiSThandler | i
gin | ginhandler | i
spGiST | spghandler | i
brin | brinhandler | i
(6 rows)

There are six types of indexes. B-trees have already been discussed in great detail, but what are those other index types good for? The following sections will outline the purpose of each index type available in PostgreSQL.

Note that there are some extensions out there that can be used on top of what you can see here. Additional index types available on the web are rum, vodka, and in the future, cognac.

主站蜘蛛池模板: 苏尼特右旗| 视频| 防城港市| 临高县| 温泉县| 遵义市| 雅安市| 隆安县| 庐江县| 射阳县| 皮山县| 集安市| 徐水县| 封丘县| 鄯善县| 台山市| 高雄县| 沾化县| 铅山县| 云龙县| 乐亭县| 凤凰县| 都安| 商河县| 宜都市| 澄城县| 灵丘县| 江西省| 久治县| 双鸭山市| 潼南县| 昌宁县| 高雄县| 灌南县| 巴东县| 奉节县| 宝丰县| 保德县| 乌兰察布市| 牡丹江市| 拜泉县|