内射老阿姨1区2区3区4区_久久精品人人做人人爽电影蜜月_久久国产精品亚洲77777_99精品又大又爽又粗少妇毛片

PostgreSQLDBA(46)-PGOperatorclassesandfamilies

先前章節(jié)已簡單提到pg_am,以hash為例介紹了hash index不能支持大于等于,小于等于等相關(guān)操作,我們了解到需要信息來確認(rèn)訪問方法接受哪些數(shù)據(jù)類型和哪些操作符.

成都創(chuàng)新互聯(lián)公司主要從事網(wǎng)站建設(shè)、成都網(wǎng)站制作、網(wǎng)頁設(shè)計(jì)、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)武夷山,十載網(wǎng)站建設(shè)經(jīng)驗(yàn),價(jià)格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):18980820575


[pg12@localhost ~]$ psql -d testdb
psql (12beta1)
Type "help" for help.
testdb=# select * from pg_am;
  oid  |    amname    |      amhandler       | amtype 
-------+--------------+----------------------+--------
     2 | heap         | heap_tableam_handler | t
   403 | btree        | bthandler            | i
   405 | hash         | hashhandler          | i
   783 | gist         | gisthandler          | i
  2742 | gin          | ginhandler           | i
  4000 | spgist       | spghandler           | i
  3580 | brin         | brinhandler          | i
 24597 | blackhole_am | blackhole_am_handler | t
(8 rows)

本節(jié)在此基礎(chǔ)上介紹Operator classes and families.

基礎(chǔ)知識(shí)
PostgreSQL提供了 operator class operator family 兩個(gè)概念來說明訪問方法接受哪些數(shù)據(jù)類型和哪些操作符. operator class 包含了索引操作特定數(shù)據(jù)類型的最小操作符集合, operator class 被歸類為 operator family ,也就是或一個(gè)family可能包含多個(gè) operator class .


testdb=# select * from pg_opfamily;
 oid  | opfmethod |        opfname        | opfnamespace | opfowner 
------+-----------+-----------------------+--------------+----------
  397 |       403 | array_ops             |           11 |       10
  627 |       405 | array_ops             |           11 |       10
  423 |       403 | bit_ops               |           11 |       10
  424 |       403 | bool_ops              |           11 |       10
  426 |       403 | bpchar_ops            |           11 |       10
  427 |       405 | bpchar_ops            |           11 |       10
  428 |       403 | bytea_ops             |           11 |       10
...
(107 rows)

上面是系統(tǒng)中存在的所有的opfamily,包括數(shù)組array_ops/位bit_ops/字符串bpchar_ops/整型integer_ops等數(shù)據(jù)類型等op family.比如integer_ops family包括了int8_ops, int4_ops, and int2_ops classes,分別對(duì)應(yīng)bigint, integer, 和 smallint這幾個(gè)類型.
pg_opfamily中的opfmethod字段與pg_am.oid關(guān)聯(lián),比如查詢hash am的opfamily和opclass:


testdb=# select am.amname,opfname, opcname, opcintype::regtype
testdb-# from pg_opclass opc, pg_opfamily opf, pg_am am
testdb-# where opc.opcfamily = opf.oid
testdb-# and opf.opfmethod = am.oid
testdb-# and am.amname = 'hash'
testdb-# order by opf.opfname;
 amname |      opfname       |       opcname       |          opcintype          
--------+--------------------+---------------------+-----------------------------
 hash   | aclitem_ops        | aclitem_ops         | aclitem
 hash   | array_ops          | array_ops           | anyarray
 hash   | bool_ops           | bool_ops            | boolean
 hash   | bpchar_ops         | bpchar_ops          | character
 hash   | bpchar_pattern_ops | bpchar_pattern_ops  | character
 hash   | bytea_ops          | bytea_ops           | bytea
 hash   | char_ops           | char_ops            | "char"
 hash   | cid_ops            | cid_ops             | cid
 hash   | date_ops           | date_ops            | date
 hash   | enum_ops           | enum_ops            | anyenum
 hash   | float_ops          | float8_ops          | double precision
 hash   | float_ops          | float4_ops          | real
 hash   | integer_ops        | int2_ops            | smallint
 hash   | integer_ops        | int8_ops            | bigint
 hash   | integer_ops        | int4_ops            | integer
 hash   | interval_ops       | interval_ops        | interval
 hash   | jsonb_ops          | jsonb_ops           | jsonb
 hash   | macaddr8_ops       | macaddr8_ops        | macaddr8
 hash   | macaddr_ops        | macaddr_ops         | macaddr
 hash   | network_ops        | cidr_ops            | inet
 hash   | network_ops        | inet_ops            | inet
 hash   | numeric_ops        | numeric_ops         | numeric
 hash   | oid_ops            | oid_ops             | oid
 hash   | oidvector_ops      | oidvector_ops       | oidvector
 hash   | pg_lsn_ops         | pg_lsn_ops          | pg_lsn
 hash   | range_ops          | range_ops           | anyrange
 hash   | text_ops           | text_ops            | text
 hash   | text_ops           | name_ops            | name
 hash   | text_ops           | varchar_ops         | text
 hash   | text_pattern_ops   | text_pattern_ops    | text
 hash   | text_pattern_ops   | varchar_pattern_ops | text
 hash   | tid_ops            | tid_ops             | tid
 hash   | time_ops           | time_ops            | time without time zone
 hash   | timestamp_ops      | timestamp_ops       | timestamp without time zone
 hash   | timestamptz_ops    | timestamptz_ops     | timestamp with time zone
 hash   | timetz_ops         | timetz_ops          | time with time zone
 hash   | uuid_ops           | uuid_ops            | uuid
 hash   | xid_ops            | xid_ops             | xid
(38 rows)

可以看到,對(duì)于integer_ops opfamily,可以支持int2_ops/int4_ops/int8_ops這幾類op clas,類型分別是smallint/integer/bigint.
op family可以包括額外的操作符用以比較不同類型的值,之所以歸為同一個(gè)family是因?yàn)樵谑褂胕ndex時(shí),謂詞可以適配不同的數(shù)據(jù)類型(如smallint/integer/bigint等).在大多數(shù)情況下,不需要知道op family和op class,只需要?jiǎng)?chuàng)建索引然后使用就好了.但,可以顯式指定op lcass.

System catalog
下面是op family和op class的相關(guān)系統(tǒng)目錄關(guān)系圖:
PostgreSQL DBA(46) - PG Operator classes and families

通過上圖,可找出相關(guān)的信息.
找出AM可處理的數(shù)據(jù)類型


testdb=# select am.amname,opcname, opcintype::regtype
testdb-# from pg_opclass opc, pg_am am 
testdb-# where opc.opcmethod = am.oid
testdb-# and am.amname = 'hash'
testdb-# order by opcintype::regtype::text;
 amname |       opcname       |          opcintype          
--------+---------------------+-----------------------------
 hash   | aclitem_ops         | aclitem
 hash   | array_ops           | anyarray
 hash   | enum_ops            | anyenum
 hash   | range_ops           | anyrange
 hash   | int8_ops            | bigint
 hash   | bool_ops            | boolean
 hash   | bytea_ops           | bytea
 hash   | char_ops            | "char"
 hash   | bpchar_pattern_ops  | character
 hash   | bpchar_ops          | character
 hash   | cid_ops             | cid
 hash   | date_ops            | date
 hash   | float8_ops          | double precision
 hash   | cidr_ops            | inet
 hash   | inet_ops            | inet
 hash   | int4_ops            | integer
 hash   | interval_ops        | interval
 hash   | jsonb_ops           | jsonb
 hash   | macaddr_ops         | macaddr
 hash   | macaddr8_ops        | macaddr8
 hash   | name_ops            | name
 hash   | numeric_ops         | numeric
 hash   | oid_ops             | oid
 hash   | oidvector_ops       | oidvector
 hash   | pg_lsn_ops          | pg_lsn
 hash   | float4_ops          | real
 hash   | int2_ops            | smallint
 hash   | text_ops            | text
 hash   | varchar_ops         | text
 hash   | text_pattern_ops    | text
 hash   | varchar_pattern_ops | text
 hash   | tid_ops             | tid
 hash   | timestamp_ops       | timestamp without time zone
 hash   | timestamptz_ops     | timestamp with time zone
 hash   | time_ops            | time without time zone
 hash   | timetz_ops          | time with time zone
 hash   | uuid_ops            | uuid
 hash   | xid_ops             | xid
(38 rows)

哪些op在op class中?(索引訪問可用于該操作符的謂詞)


testdb=# select amop.amopopr::regoperator
testdb-# from pg_opclass opc, pg_opfamily opf, pg_am am, pg_amop amop
testdb-# where opc.opcname = 'int8_ops'
testdb-# and opf.oid = opc.opcfamily
testdb-# and am.oid = opf.opfmethod
testdb-# and amop.amopfamily = opc.opcfamily
testdb-# and am.amname = 'hash'
testdb-# and amop.amoplefttype = opc.opcintype;
      amopopr       
--------------------
 =(bigint,bigint)
 =(bigint,smallint)
 =(bigint,integer)
(3 rows)

參考資料
Indexes in PostgreSQL — 2

文章題目:PostgreSQLDBA(46)-PGOperatorclassesandfamilies
網(wǎng)頁地址:http://www.rwnh.cn/article24/ghcice.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信公眾號(hào)微信小程序、網(wǎng)站設(shè)計(jì)公司網(wǎng)站建設(shè)、關(guān)鍵詞優(yōu)化網(wǎng)站改版

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都app開發(fā)公司
延安市| 和龙市| 西青区| 延川县| 德阳市| 黄山市| 石楼县| 来宾市| 随州市| 沙洋县| 大埔县| 望谟县| 香港| 岫岩| 咸宁市| 海丰县| 铜鼓县| 玉山县| 石棉县| 荥经县| 洞口县| 宣城市| 贵南县| 米易县| 库车县| 两当县| 万山特区| 南涧| 修文县| 海伦市| 普安县| 内黄县| 集安市| 南漳县| 景洪市| 永济市| 凯里市| 永定县| 增城市| 扶风县| 梁山县|