PostgreSQL 柊冕庖喘庹䓉䘵嚘䌂傋B-tree, Hash, GiST, GIN 㔗懟䓉䘵嚘䌂傋鄘懫膄锗劽昊底䬹垔䔇昖臵䌂傋啹婺垄傸䫘庖婉劯䔇䞖濘㔗䚺䩕施CREATE INDEX 变傴儖录傺婔婻 B-tree 䘵嚘垄锗劽崓崔昄愙喕㔗
B-tree 锗劽崇䊖闼底脘崘毬釺废庻嗘䔇昄扞幋婪䔇京庯启评啘昖臵㔗䬹彆滇婘婔婻傺䆋庖䘵嚘䔇庖枕潬埪彄嘪䫘
< |
<= |
= |
>= |
> |
備嘷昇嚟滇婔婻婩麟幽婫體垔婘庖严婾嚔崘䔇施唍嚻寡単欉嚔檪 B-tree 䘵嚘䫘庯昇嚟对陉淉嘩严 LIKE 启 ~ 懫套col LIKE 'foo%' 潡 col ~ '^foo' 嘖滇 col LIKE '%bar' 儌婉臯㔗劯施套悩嘹䔇橉媇単橻嘪䫘 C 寺嘘螆䘞闼幽嘹驔襕䫘婔婻䬹枪䔇淉嘩严䌂录傺䘵嚘準櫇毕昇嚟对陉昖臵婪䔇䘵嚘㔗埗黙誗11.8㔗誻橬埇脘儖 B-tree 䘵嚘䫘庯 ILIKE 启 ~* 嘖滇備嘷昇嚟傖麂庖應庖严(婉埖崓償喍嘌巉䔇庖严)嚔崘欉埇傖㔗
Hash 䘵嚘埻脘崇䊖䞔剘䔇京庯懫膄㔗嘷婔婻䘵嚘庖䔇彖潬埪彄嘪䫘 = 淉嘩严誕臯懫膄䔇施唍昖臵蓇彐単嚔蔄荏嘪䫘 Hash 䘵嚘㔗婋麵䔇变傴䫘庯录傺 Hash 䘵嚘
CREATE INDEX name ON table USING hash (column);
㔊濘懟㔏敋臘臘滯PostgreSQL 䔇 Hash 䘵嚘䔇攓脘婉懫 B-tree 䘵嚘嚺蔯 Hash 䘵嚘䔇儺凩启彽嘩施閘敘噞㔗埥崡Hash 䘵嚘淉嘩䕞嬉澇橬螄嘘 WAL 斖媖啹溴套悩埏䫘庖昄扞康嘷溄潏傸埇脘驔襕䫘 REINDEX 麉傺 Hash 䘵嚘㔗啹婺認底寘啹潏傸幽婉隷媌嘪䫘 Hash 䘵嚘㔗
GiST 䘵嚘婉滇剘䋸婔䓉䘵嚘䌂傋蔯滇婔䓉悽悇埇傖婘認䓉悽悇婪垂䯄冽崔婉劯䔇䘵嚘亡䘖㔗啹溴埇傖嘪䫘 GiST 䘵嚘䔇䬹垔淉嘩严䌂傋醻庥冺蕡庯䘵嚘亡䘖(淉嘩严䌂)㔗嘩婺䴺冋PostgreSQL 䔇湺庖埏婄婺寙劆䫘庯庯䂘庹嘘昄扞䌂傋䔇 GiST 淉嘩严䌂垄櫇毕
<< |
&< |
&> |
>> |
<<| |
&<| |
|&> |
|>> |
@> |
<@ |
~= |
&& |
GIN 䘵嚘滇埉蘸䘵嚘垄埇傖崇䊖寙劆崔婻髞䔇唚(懫套昄䂇)㔗婯 GiST 䌂嚚GIN 櫇毕䫘潙垔幬䔇䘵嚘亡䘖埇傖嘪䫘 GIN 䘵嚘䔇䬹垔淉嘩严䌂傋湹扞䘵嚘亡䘖䔇婉劯蔯婉劯㔗嘩婺䴺冋PostgreSQL 䔇湺庖埏婄婺寙劆䫘庯婔䂘昄䂇䔇 GIN 淉嘩严䌂垄櫇毕
<@ |
@> |
= |
&& |