如何在postgres中查询现有索引的类型?

时间:2016-11-14 19:00:36

标签: postgresql

pg_index表提供索引信息,它似乎没有描述索引类型的列(btree hash,gin等...)

了解现有索引类型的正确方法是什么?

1 个答案:

答案 0 :(得分:1)

索引的访问方法在目录pg_am中定义,由目录pg_class的列relam指向,例如:

select c.relname, a.amname
from pg_index i
join pg_class c on c.oid = i.indexrelid
join pg_am a on a.oid = c.relam
where relnamespace = 2200

       relname        | amname 
----------------------+--------
 array_test_arr_idx   | gin
 students_topics_pkey | btree
 images_pkey          | btree