iis服务器助手广告广告
返回顶部
首页 > 资讯 > 数据库 >怎么理解PostgreSQL的PG Index Properties
  • 570
分享到

怎么理解PostgreSQL的PG Index Properties

2024-04-02 19:04:59 570人浏览 独家记忆
摘要

本篇内容介绍了“怎么理解postgresql的PG Index Properties”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家

本篇内容介绍了“怎么理解postgresql的PG Index Properties”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

在Postgresql 9.6之后,PG提供了三个函数来判定Index AM/Index/Index Column是否具备某些属性,包括pg_indexam_has_property/pg_index_has_property/pg_index_column_has_property.

pg_indexam_has_property
test whether an index access method has a specified property

属性名称说明
can_orderDoes the access method support ASC, DESC and related keyWords in CREATE INDEX?
can_uniqueDoes the access method support unique indexes?
can_multi_colDoes the access method support indexes with multiple columns?
can_excludeDoes the access method support exclusion constraints?
can_includevDoes the access method support the INCLUDE clause of CREATE INDEX?

下面是本机AM的查询结果,其中heap是堆AM/blackhole_am是先前介绍过的黑洞AM.

testdb=# select a.amname, p.name, pg_indexam_has_property(a.oid,p.name)
testdb-# from pg_am a,
testdb-#      unnest(array['can_order','can_unique','can_multi_col','can_exclude']) p(name)
testdb-# order by a.amname;
    amname    |     name      | pg_indexam_has_property 
--------------+---------------+-------------------------
 blackhole_am | can_unique    | 
 blackhole_am | can_exclude   | 
 blackhole_am | can_multi_col | 
 blackhole_am | can_order     | 
 brin         | can_order     | f
 brin         | can_exclude   | f
 brin         | can_multi_col | t
 brin         | can_unique    | f
 btree        | can_order     | t
 btree        | can_unique    | t
 btree        | can_multi_col | t
 btree        | can_exclude   | t
 gin          | can_unique    | f
 gin          | can_order     | f
 gin          | can_multi_col | t
 gin          | can_exclude   | f
 GISt         | can_unique    | f
 gist         | can_multi_col | t
 gist         | can_exclude   | t
 gist         | can_order     | f
 hash         | can_order     | f
 hash         | can_unique    | f
 hash         | can_multi_col | f
 hash         | can_exclude   | t
 heap         | can_multi_col | 
 heap         | can_unique    | 
 heap         | can_order     | 
 heap         | can_exclude   | 
 spgist       | can_multi_col | f
 spgist       | can_exclude   | t
 spgist       | can_unique    | f
 spgist       | can_order     | f
(32 rows)

PostgreSQL根据上述属性判断在创建索引时指定的option,如Hash索引不能是唯一索引(hash         | can_unique    | f):

testdb=# create unique index idx_t_idx1_id on t_idx1 using hash(id);
psql: ERROR:  access method "hash" does not support unique indexes

pg_index_has_property
test whether an index has a specified property

属性名称说明
clusterableCan the index be used in a CLUSTER command?
index_scanDoes the index support plain (non-bitmap) scans?
bitmap_scanDoes the index support bitmap scans?
backward_scanCan the scan direction be changed in mid-scan (to support FETCH BACKWARD on a cursor without needing materialization)?

创建hash索引,查询该索引的相关属性

testdb=# create index idx_t_idx1_id on t_idx1 using hash(id);
CREATE INDEX
testdb=# select p.name, pg_index_has_property('idx_t_idx1_id'::reGClass,p.name)
testdb-# from unnest(array[
testdb(#        'clusterable','index_scan','bitmap_scan','backward_scan'
testdb(#      ]) p(name);
     name      | pg_index_has_property 
---------------+-----------------------
 clusterable   | f
 index_scan    | t
 bitmap_scan   | t
 backward_scan | t
(4 rows)

pg_index_column_has_property
test whether an index column has a specified property

属性名称说明
ascDoes the column sort in ascending order on a forward scan?
descDoes the column sort in descending order on a forward scan?
nulls_firstDoes the column sort with nulls first on a forward scan?
nulls_lastDoes the column sort with nulls last on a forward scan?
orderableDoes the column possess any defined sort ordering?
distance_orderableCan the column be scanned in order by a “distance” operator, for example ORDER BY col <-> constant ?
returnableCan the column value be returned by an index-only scan?
search_arrayDoes the column natively support col = ANY(array) searches?
search_nullsDoes the column support IS NULL and IS NOT NULL searches?

查询hash索引列的相关属性(全为f - false)

testdb=# select p.name,
testdb-#      pg_index_column_has_property('idx_t_idx1_id'::regclass,1,p.name)
testdb-# from unnest(array[
testdb(#        'asc','desc','nulls_first','nulls_last','orderable','distance_orderable',
testdb(#        'returnable','search_array','search_nulls'
testdb(#      ]) p(name);
        name        | pg_index_column_has_property 
--------------------+------------------------------
 asc                | f
 desc               | f
 nulls_first        | f
 nulls_last         | f
 orderable          | f
 distance_orderable | f
 returnable         | f
 search_array       | f
 search_nulls       | f
(9 rows)

“怎么理解PostgreSQL的PG Index Properties”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注编程网网站,小编将为大家输出更多高质量的实用文章!

您可能感兴趣的文档:

--结束END--

本文标题: 怎么理解PostgreSQL的PG Index Properties

本文链接: https://www.lsjlt.com/news/63853.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • 怎么理解PostgreSQL的PG Index Properties
    本篇内容介绍了“怎么理解PostgreSQL的PG Index Properties”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家...
    99+
    2024-04-02
  • 怎么搭建postgresql-pg简易异步流复制
    这篇文章主要讲解了“怎么搭建postgresql-pg简易异步流复制”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“怎么搭建postgresql-pg简易异步...
    99+
    2024-04-02
  • 怎么理解PostgreSQL的分区表
    本篇内容主要讲解“怎么理解PostgreSQL的分区表”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“怎么理解PostgreSQL的分区表”吧!在PG中,分区表通...
    99+
    2024-04-02
  • 怎么理解PostgreSQL事务管理
    本篇内容介绍了“怎么理解PostgreSQL事务管理”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!一、Th...
    99+
    2024-04-02
  • Fedora中怎么使用Gnu PG代理
    本篇内容主要讲解“Fedora中怎么使用Gnu PG代理”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Fedora中怎么使用Gnu PG代理”吧!有时使用某个应用程序的时候,你需要非常频繁地使用...
    99+
    2023-06-16
  • 怎么理解PostgreSQL中的参数autovacuum_max_workers
    这篇文章主要介绍“怎么理解PostgreSQL中的参数autovacuum_max_workers”,在日常操作中,相信很多人在怎么理解PostgreSQL中的参数autovacuum_max_worker...
    99+
    2024-04-02
  • 怎么理解PostgreSQL的词法分析
    这篇文章主要讲解了“怎么理解PostgreSQL的词法分析”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“怎么理解PostgreSQL的词法分析”吧!一、词法...
    99+
    2024-04-02
  • 怎么理解PostgreSQL表继承
    这篇文章主要介绍“怎么理解PostgreSQL表继承”,在日常操作中,相信很多人在怎么理解PostgreSQL表继承问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”怎么理解Po...
    99+
    2024-04-02
  • 怎么理解PG的物理存储结构、版本控制、空间回收
    本篇内容主要讲解“怎么理解PG的物理存储结构、版本控制、空间回收”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“怎么理解PG的物理存储结构、版本控制、空间回收”吧...
    99+
    2024-04-02
  • 怎么理解PostgreSQL的后台进程autovacuum
    本篇内容介绍了“怎么理解PostgreSQL的后台进程autovacuum”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!一、数据结构Auto...
    99+
    2023-05-31
  • 怎么理解PostgreSQL Locks中的Fast Path Locking
    这篇文章主要讲解了“怎么理解PostgreSQL Locks中的Fast Path Locking”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“怎么理解Po...
    99+
    2024-04-02
  • 怎么理解PostgreSQL DBA settings选项
    本篇内容介绍了“怎么理解PostgreSQL DBA settings选项”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,...
    99+
    2024-04-02
  • 怎么理解PostgreSQL Locks中的Lock Manager Internal Locking
    本篇内容主要讲解“怎么理解PostgreSQL Locks中的Lock Manager Internal Locking”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家...
    99+
    2024-04-02
  • 怎么理解PostgreSQL事务管理中的子事务
    本篇内容主要讲解“怎么理解PostgreSQL事务管理中的子事务”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“怎么理解PostgreSQL事务管理中的子事务”吧...
    99+
    2024-04-02
  • 怎么理解PostgreSQL Locks中的The Deadlock Detection Algorithm
    这篇文章主要讲解了“怎么理解PostgreSQL Locks中的The Deadlock Detection Algorithm”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,...
    99+
    2024-04-02
  • 怎么理解PostgreSQL中Clock Sweep算法
    本篇内容介绍了“怎么理解PostgreSQL中Clock Sweep算法”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能...
    99+
    2024-04-02
  • 怎么理解PostgreSQL中session hang情况
    这篇文章主要介绍“怎么理解PostgreSQL中session hang情况”,在日常操作中,相信很多人在怎么理解PostgreSQL中session hang情况问题上存在疑惑,小编查阅了各式资料,整理出...
    99+
    2022-11-30
    postgresql
  • 怎么理解PostgreSQL行安全策略
    这篇文章主要讲解了“怎么理解PostgreSQL行安全策略”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“怎么理解PostgreSQL行安全策略”吧!行安全策...
    99+
    2024-04-02
  • sqoop怎么指定pg库的模式
    这篇“sqoop怎么指定pg库的模式”文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一起来看看这篇“sqoop怎么指定pg库的模式”文章吧。s...
    99+
    2023-06-28
  • 怎么理解PostgreSQL全表扫描问题
    这篇文章主要讲解了“怎么理解PostgreSQL全表扫描问题”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“怎么理解PostgreSQL全表扫描问题”吧!本节...
    99+
    2024-04-02
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作