> 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/appendixes/contrib/btree-gin.md). Agents can also search and read this documentation through its [MCP server](https://docs.postgresql.tw/~gitbook/mcp).

# F.7. btree\_gin — 具有 B-tree 行為的 GIN 運算子類別

### F.7. btree\_gin — 具有 B-tree 行為的 GIN 運算子類別 [#](#btree-gin) <a href="#btree-gin" id="btree-gin"></a>

[F.7.1. 使用範例](#btree-gin-example-usage)

[F.7.2. 作者](#btree-gin-authors)

`btree_gin` 提供 GIN 運算子類別，為下列資料型別實作等同於 B-tree 的行為：`int2`、`int4`、`int8`、`float4`、`float8`、`timestamp with time zone`、`timestamp without time zone`、`time with time zone`、`time without time zone`、`date`、`interval`、`oid`、`money`、`"char"`、`varchar`、`text`、`bytea`、`bit`、`varbit`、`macaddr`、`macaddr8`、`inet`、`cidr`、`uuid`、`name`、`bool`、`bpchar` 及所有 `enum` 型別。

一般而言，這些運算子類別不會優於等效的標準 B-tree 索引方法，且缺少標準 B-tree 程式碼的一項主要功能：強制唯一性的能力。不過，它們適用於 GIN 測試，也可作為開發其他 GIN 運算子類別的基礎。此外，對同時測試可建立 GIN 索引欄位與可建立 B-tree 索引欄位的查詢，建立使用其中一個運算子類別的多欄位 GIN 索引，可能比建立兩個必須經由 bitmap AND 合併的獨立索引更有效率。

此模組被視為「受信任」，也就是可由在目前資料庫中具有 `CREATE` 權限的非超級使用者安裝。

#### F.7.1. 使用範例 [#](#btree-gin-example-usage) <a href="#btree-gin-example-usage" id="btree-gin-example-usage"></a>

```

CREATE TABLE test (a int4);
-- create index
CREATE INDEX testidx ON test USING GIN (a);
-- query
SELECT * FROM test WHERE a < 10;
```

#### F.7.2. 作者 [#](#btree-gin-authors) <a href="#btree-gin-authors" id="btree-gin-authors"></a>

Teodor Sigaev（`<teodor@stack.net>`）及 Oleg Bartunov（`<oleg@sai.msu.su>`）。其他資訊請參閱 <http://www.sai.msu.su/~megera/oddmuse/index.cgi/Gin>。

***

原文：[PostgreSQL 18.6 Documentation](https://www.postgresql.org/docs/18/btree-gin.html)


---

# 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/appendixes/contrib/btree-gin.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.
