【问题标题】:how can I detect gin and gist如何检测杜松子酒和 gist
【发布时间】:2013-01-20 17:57:35
【问题描述】:

如何在 postgresql 中检测 GIN 和 GiST 索引?我正在寻找 postgres 数据库是否使用全文。我认为一个表使用 GIN o GiST 然后使用全文。

我接受 GIN 或 GiST 索引并不一定意味着它们用于全文搜索,但我如何区分它们与其他索引类型?我想列出 Gin an Gist 索引

【问题讨论】:

  • 存在 GIN 或 GiST 索引并不一定意味着它们用于全文搜索。

标签: postgresql indexing gwt-gin gist-index


【解决方案1】:

可以使用System Catalog Information Functions 中的pg_get_indexdef() 重新创建索引定义,并由pg_index 系统视图提供。从理论上讲,解析输出并不简单,但在实践中,一个简单的正则表达式足以过滤某些索引类型的这些定义。

例如,要查找gistgin 索引,您可以使用如下查询:

SELECT pg_get_indexdef(indexrelid) from pg_index
 WHERE pg_get_indexdef(indexrelid) ~ 'USING (gin |gist )';

要查找某个数据库是否使用全文,我可能会搜索 tsvector 列,使用如下查询:

SELECT table_schema,table_name, column_name
 FROM information_schema.columns
 WHERE data_type='tsvector';

【讨论】:

  • 非常感谢丹尼尔
【解决方案2】:

我在Postgres source code里翻了一圈,发现这个信息存放在pg_am表中:

select i.relname, a.amname
from pg_index ix
left join pg_class i on ix.indexrelid = i.oid
left join pg_class t on ix.indrelid = t.oid
left join pg_am a on i.relam = a.oid

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-01-15
    • 1970-01-01
    • 1970-01-01
    • 2012-01-12
    • 2019-04-13
    • 2016-11-24
    • 2020-10-17
    • 1970-01-01
    相关资源
    最近更新 更多