> For the complete documentation index, see [llms.txt](https://docs.postgresql.tw/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-amop.md). Agents can also search and read this documentation through its [MCP server](https://docs.postgresql.tw/~gitbook/mcp).

# 52.4. pg\_amop \#

### 52.4. `pg_amop` [#](#catalog-pg-amop) <a href="#catalog-pg-amop" id="catalog-pg-amop"></a>

系統目錄 `pg_amop` 存放與存取方法運算子家族相關聯之運算子的資訊。 每個身為運算子家族成員的運算子各有一筆資料列。家族成員可以是*搜尋*運算子， 也可以是*排序*運算子。一個運算子 可以出現在超過一個家族中，但在同一個家族內，既不能出現在超過一個搜尋位置， 也不能出現在超過一個排序位置。 （允許一個運算子同時用於搜尋與排序兩種用途，雖然這種情況不太可能出現。）

#### 表 52.4. `pg_amop` 欄位 [#](#catalog-pg-amop-columns) <a href="#catalog-pg-amop-columns" id="catalog-pg-amop-columns"></a>

| <p>欄位類型</p><p>說明</p>                                                                                                                                                                                                                         |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p><code>oid</code> <code>oid</code></p><p>資料列識別碼</p>                                                                                                                                                                                        |
| <p><code>amopfamily</code> <code>oid</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-opfamily.md"><code>pg\_opfamily</code></a>.<code>oid</code>）</p><p>此項目所屬的運算子家族</p>                                      |
| <p><code>amoplefttype</code> <code>oid</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-type.md"><code>pg\_type</code></a>.<code>oid</code>）</p><p>運算子的左側輸入資料型別</p>                                           |
| <p><code>amoprighttype</code> <code>oid</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-type.md"><code>pg\_type</code></a>.<code>oid</code>）</p><p>運算子的右側輸入資料型別</p>                                          |
| <p><code>amopstrategy</code> <code>int2</code></p><p>運算子策略編號</p>                                                                                                                                                                             |
| <p><code>amoppurpose</code> <code>char</code></p><p>運算子用途，<code>s</code> 表示搜尋， <code>o</code> 表示排序</p>                                                                                                                                       |
| <p><code>amopopr</code> <code>oid</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-operator.md"><code>pg\_operator</code></a>.<code>oid</code>）</p><p>運算子的 OID</p>                                            |
| <p><code>amopmethod</code> <code>oid</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-am.md"><code>pg\_am</code></a>.<code>oid</code>）</p><p>此運算子家族所屬的索引存取方法</p>                                              |
| <p><code>amopsortfamily</code> <code>oid</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-opfamily.md"><code>pg\_opfamily</code></a>.<code>oid</code>）</p><p>若為排序運算子，則為此項目排序所依據的 B-tree 運算子家族； 若為搜尋運算子則為零</p> |

<br>

「搜尋」運算子項目表示，可以搜尋此運算子家族的索引，以找出所有滿足 `WHERE` *`indexed_column`* *`operator`* *`constant`* 的資料列。 顯然，這樣的運算子必須傳回 `boolean`，且其左側輸入 型別必須與索引欄位的資料型別相符。

「排序」運算子項目表示，可以掃描此運算子家族的索引，以依照 `ORDER BY` *`indexed_column`* *`operator`* *`constant`* 所表示的順序傳回資料列。 這樣的運算子可以傳回任何可排序的資料型別，不過同樣地， 其左側輸入型別必須與索引欄位的資料型別相符。 `ORDER BY` 的確切語意由 `amopsortfamily` 欄位指定，該欄位必須參照 適用於該運算子結果型別的 B-tree 運算子家族。

#### 注意

目前假設排序運算子的排序順序就是所參照運算子家族的預設順序，也就是 `ASC NULLS LAST`。日後可能會藉由新增額外欄位來明確指定排序選項，以放寬此限制。

項目的 `amopmethod` 必須與其所屬運算子家族的 `opfmethod` 相符（在此包含 `amopmethod`，是基於效能考量而刻意對 系統目錄結構所做的反正規化）。此外， `amoplefttype` 與 `amoprighttype` 必須與 所參照之 [`pg_operator`](https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-operator.md) 項目的 `oprleft` 與 `oprright` 欄位相符。

***

原文：[PostgreSQL 18.6 Documentation](https://www.postgresql.org/docs/18/catalog-pg-amop.html)（原文版本：18.6；核對日期：2026-10-17）


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-amop.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
