45.4. pg_amop #
目录pg_amop存储关于与访问方法操作符族相关的操作符信息。对于操作符族中的每个成员操作符,此目录中都有一行。一个成员可以是搜索操作符,也可以是排序操作符。一个操作符可以出现在多个族中,但在同一个族中既不能出现在多个搜索位置,也不能出现在多个排序位置(虽然不太可能,但允许一个操作符同时用于搜索和排序)。
表 45.4. pg_amop 列
| Name | Type | References | Description |
|---|---|---|---|
amopfamily | oid | | The operator family this entry is for |
amoplefttype | oid | | Left-hand input data type of operator |
amoprighttype | oid | | Right-hand input data type of operator |
amopstrategy | int2 | Operator strategy number | |
amoppurpose | char | Operator purpose, either s for search or
o for ordering | |
amopopr | oid | | OID of the operator |
amopmethod | oid | | Index access method operator family is for |
amopsortfamily | oid | | The btree operator family this entry sorts according to, if an ordering operator; zero if a search operator |
“搜索”操作符项表明可以搜索该操作符族的一个索引来找到所有满足 WHERE indexed_column operator constant 的行。显然,这样的操作符必须返回布尔值,并且其左输入类型必须匹配索引列的数据类型。
“排序”操作符项表明可以扫描该操作符族的一个索引,按照 ORDER BY indexed_column operator constant 所表示的顺序返回行。这样的操作符可以返回任何可排序的数据类型,但其左输入类型同样必须匹配索引列的数据类型。ORDER BY 的确切语义由 amopsortfamily 列指定,该列必须引用操作符结果类型的一个 btree 操作符族。
注意
当前假定排序操作符的排序顺序是被引用操作符族的默认值,即 ASC NULLS LAST。将来可能会通过增加额外的列来显式指定排序选项,从而放宽这一假定。
一个项的amopmethod必须和其所属操作符族的opfmethod相匹配(此处加入amopmethod是出于性能原因而对目录结构故意做出的反规范化)。此外,amoplefttype和amoprighttype也必须匹配被引用的pg_operator项的oprleft和oprright域。