# v1.4 研发进展：PostgreSQL COPY 批量写入与原生 PromQL 引擎｜Greptime 月度精选 - No. 90

Source: https://greptime.cn/blogs/2026-11-30-greptimedb-monthly-report

## 内容概述

*2026 年 11 月 · 2026-11-01 – 2026-11-30*

11 月的主要工作是 v1.4 研发，v1.3 发布了 [v1.3.1](/blogs/2026-11-16-greptimedb-v1-3-1-release) 和 [v1.3.2](/blogs/2026-12-01-greptimedb-v1-3-2-release) 两个维护版本。本月主要更新：

- PostgreSQL `COPY` 写入新增 JSONL、Arrow、OTLP 和 Remote Write 格式。
- 原生 PromQL 引擎在内部测试中明显更快，欢迎试用。
- JSON2 嵌套字段索引、exemplar 存储，以及安全和性能修复。

## v1.4 研发进展

以下改动已合入 `main`，将随 v1.4 发布，可以通过 [nightly 构建](https://github.com/GreptimeTeam/greptimedb/releases)试用。

### 通过 PostgreSQL COPY 批量写入

[10 月](/blogs/2026-10-31-greptimedb-monthly-report) PostgreSQL `COPY FROM STDIN` 支持了 CSV 和 InfluxDB 行协议，本月新增 JSONL、Arrow IPC、OTLP 和 Prometheus Remote Write。PostgreSQL 客户端可以用它批量导入表数据，也可以写入指标、日志和 trace，写入使用当前会话的用户和数据库。各格式的用法和选项见 [COPY FROM STDIN 文档](https://docs.greptime.cn/nightly/user-guide/protocols/postgresql-copy-in)。

```sql
-- 按行分隔的 JSON 对象，key 按列名匹配
COPY readings FROM STDIN WITH (FORMAT jsonl);

-- Arrow IPC 流，经由 Arrow Flight 批量写入路径
COPY readings FROM STDIN WITH (FORMAT arrow);

-- 一条 OTLP protobuf 消息；signal 可选 'metrics'（默认）、'logs'、'traces'
COPY FROM STDIN WITH (FORMAT otlp);
COPY app_logs FROM STDIN WITH (FORMAT otlp, signal 'logs');

-- 一个压缩后的 Prometheus Remote Write 请求体
COPY FROM STDIN WITH (FORMAT promwrite, version 2);
```

在基于 `main` 分支 release 构建的[写入基准测试](https://github.com/killme2008/greptimedb-ingestion-benchmark/pull/4)中，`COPY` 写入 Arrow IPC 达到每秒 253 万个数据点，比 gRPC Arrow Flight 批量写入高 11%；JSONL 和 CSV 分别为每秒 112 万和 96 万个数据点，PostgreSQL `INSERT` 约为每秒 5.1 万个。测试在同一台机器上运行 standalone 服务端和 Go 客户端，共写入 20 万行，每批 1000 行，4 个并发写入。

| 写入方式 | 数据点/秒 | 批次 p95（毫秒） |
|---|---:|---:|
| COPY Arrow IPC | 2,525,233 | 2.2 |
| gRPC Bulk（Arrow Flight） | 2,265,344 | 2.3 |
| COPY JSONL | 1,119,562 | 5.1 |
| COPY CSV | 962,540 | 5.8 |
| COPY InfluxDB 行协议 | 785,246 | 7.0 |
| PostgreSQL INSERT | 51,258 | 90.6 |


### 原生 PromQL 引擎

现有引擎把 PromQL 转成 DataFusion 执行计划来运行。新引擎直接读取原始时间线，在 range 函数、聚合和 native histogram 计算中都按时间线处理数据（[db#10480](https://github.com/GreptimeTeam/greptimedb/pull/10480)）。内部测试中，新引擎明显快于现有引擎。引擎仍在完善，测试数据敬请期待。

新引擎默认关闭。如需测试，在 frontend 或 standalone 配置中设置 `query.experimental_native_promql = true`，或在会话中执行 `SET query.experimental_native_promql = true`。欢迎用自己的查询测试，结果错误或查询变慢的情况请在 [GitHub Issues](https://github.com/GreptimeTeam/greptimedb/issues) 反馈。

### JSON2 嵌套字段索引

[JSON2](/blogs/2026-09-23-greptimedb-json2-deep-dive) 类型提示可以为每个嵌套路径声明索引。[10 月](/blogs/2026-10-31-greptimedb-monthly-report)支持了 `INVERTED INDEX` 和 `SKIPPING INDEX`，本月新增 `FULLTEXT INDEX`，支持 `bloom` 和 `tantivy` 两种后端，`matches`、`matches_term` 和符合条件的 `LIKE` 过滤会用到该索引（[db#10064](https://github.com/GreptimeTeam/greptimedb/pull/10064)）。按已建索引的路径过滤时，查询可以跳过不相关的 SST，不必扫描整个 JSON 列。

```sql
CREATE TABLE logs (
    ts TIMESTAMP TIME INDEX,
    attrs JSON2 (
        service.name STRING INVERTED INDEX,
        status BIGINT SKIPPING INDEX,
        message STRING FULLTEXT INDEX WITH (backend = 'bloom')
    )
) WITH ('append_mode' = 'true');

SELECT * FROM logs WHERE matches_term(attrs.message, 'timeout');
```

语法和选项见[子路径全文索引](https://docs.greptime.cn/nightly/user-guide/logs/json2#子路径全文索引)。

### Exemplar

通过 Prometheus Remote Write v1/v2 和 OTLP 指标写入的 exemplar 会被存储，`/v1/prometheus/api/v1/query_exemplars` 按 Prometheus exemplar API 的格式返回 exemplar（[db#9922](https://github.com/GreptimeTeam/greptimedb/pull/9922)、[db#9923](https://github.com/GreptimeTeam/greptimedb/pull/9923)、[db#9924](https://github.com/GreptimeTeam/greptimedb/pull/9924)）。每个 exemplar 保留自身的标签（如 `trace_id`），可据此从指标样本关联到对应的 trace。

Exemplar 存储在各数据库的 `greptime_metrics_exemplars` 表中。Grafana 的 Prometheus 数据源可以像读取 Prometheus 一样从 GreptimeDB 读取 exemplar：

<figure style="text-align: center">
  <img src="/zh/blogs/2026-11-30-greptimedb-monthly-report/exemplars-grafana.png" alt="Grafana 面板展示 GreptimeDB 中存储的 exemplar 与 p99 延迟" style="max-width: 960px; width: 100%; display: block; margin: 0 auto">
  <figcaption>p99 延迟面板上的 exemplar，通过 Prometheus 数据源从 GreptimeDB 读取</figcaption>
</figure>

### 安全、正确性与性能

- 安全：本月的大部分安全加固也已在 v1.3.1 和 v1.3.2 中发布（见 [v1.3 维护](#v1-3-维护)）。`main` 上，`COPY ... TO` 还会拒绝不安全的本地文件名（[db#10462](https://github.com/GreptimeTeam/greptimedb/pull/10462)）。
- 性能：分布式查询会把列投影下推到 datanode（[db#10221](https://github.com/GreptimeTeam/greptimedb/pull/10221)）。带过滤条件的 TopK 查询更早填充堆（[db#10515](https://github.com/GreptimeTeam/greptimedb/pull/10515)），扫描在读取 SST footer 之前先按主键范围跳过文件（[db#10564](https://github.com/GreptimeTeam/greptimedb/pull/10564)），SST 元数据占用的内存更少（[db#10356](https://github.com/GreptimeTeam/greptimedb/pull/10356)）。来自社区的改动：时间索引列上的 `date_bin(...)` 过滤也能按时间范围裁剪，为 Grafana 按时间分桶的视图查询更快（[db#10345](https://github.com/GreptimeTeam/greptimedb/pull/10345)）。
- 运维：`information_schema.compaction_tasks` 列出正在执行的 compaction 任务，`ADMIN cancel_region_compaction` 可以取消单个任务（[db#10173](https://github.com/GreptimeTeam/greptimedb/pull/10173)、[db#10229](https://github.com/GreptimeTeam/greptimedb/pull/10229)）。自动 compaction 在各 region 之间分配并发额度，积压较多的 region 不会再让其他 region 长期等待（[db#9947](https://github.com/GreptimeTeam/greptimedb/pull/9947)）。维护 datanode 前，可以调用 metasrv 的 `POST /admin/datanode/drain` 将其 leader region 迁移到其他 datanode（[db#10083](https://github.com/GreptimeTeam/greptimedb/pull/10083)）。

## v1.3 维护

v1.3 本月发布了两个维护版本，都支持原地升级。建议 v1.3 用户升级到 v1.3.2。

- [v1.3.1](/blogs/2026-11-16-greptimedb-v1-3-1-release)（11 月 13 日）修复了 repartition 回滚或 datanode 重启后已写入数据可能丢失的问题，以及默认配置下本地 WAL 定期 sync 没有落盘的问题。通过 HTTP、MySQL 或 PostgreSQL 切换数据库时会检查用户权限，管理函数需要 `ADMIN` 权限，诊断输出、日志和表选项中不再显示凭据。直接写入 OTLP 日志时新建的表采用 `greptime_log_v1` schema，主键包含 `service_name`，`trace_id` 建有跳数索引。
- [v1.3.2](/blogs/2026-12-01-greptimedb-v1-3-2-release)（11 月 30 日）修复了 `last_non_null` 表中已删除数据重新出现、按 Field 列分区的表执行 `DELETE` 后数据未删除、`COPY FROM` 丢失精度，以及字段值达到 1 MiB 及以上时查询失败等问题。配置了 `user_provider` 时，`/debug/*` 接口需要认证。

有两项变更可能影响现有客户端：从 v1.3.1 起，MySQL 和 PostgreSQL 连接必须使用当前用户有权限访问的数据库；从 v1.3.2 起，调用 `/debug/*` 的脚本必须携带凭据。其余升级注意事项见两篇发版博客。

## 生态更新

- Dashboard [v0.14.3](https://github.com/GreptimeTeam/dashboard/releases/tag/v0.14.3)–[v0.14.7](https://github.com/GreptimeTeam/dashboard/releases/tag/v0.14.7) 在 Traces 视图中新增 Service Map，新增日语界面。v1.3.1 内置 v0.14.6，v1.3.2 内置 v0.14.7。[在线 Demo](https://live.greptime.cloud/) 接入了 OpenTelemetry Demo 的数据，使用方法见[在线 Demo 使用指南](/blogs/2026-11-25-explore-greptimedb-live-demo)。
- Helm Charts [greptimedb-cluster 1.3.3](https://github.com/GreptimeTeam/helm-charts/releases/tag/greptimedb-cluster-1.3.3) 和 [greptimedb-standalone 1.3.2](https://github.com/GreptimeTeam/helm-charts/releases/tag/greptimedb-standalone-1.3.2) 默认部署 v1.3.1。
- Grafana 数据源插件 [v3.0.5](https://github.com/GreptimeTeam/greptimedb-grafana-datasource/releases/tag/v3.0.5) 修复了 TLS 主机名校验和 SNI 的问题。
- Rust Ingester [v0.20.0](https://github.com/GreptimeTeam/greptimedb-ingester-rust/releases/tag/v0.20.0) 新增 `BulkStreamWriter::alloc_backfill_rows_buffer`，用于跨小时回填数据。

## 贡献者

过去一个月，来自 **33 位贡献者**的 **404 个 PR** 被合并。其中 **21 位社区贡献者**贡献了 **38 个 PR**。
欢迎新贡献者：**[@dayan02dev](https://github.com/dayan02dev)**、**[@shuxiachai](https://github.com/shuxiachai)**、**[@florissmit10](https://github.com/florissmit10)**、**[@SAMARTHJAISWAL](https://github.com/SAMARTHJAISWAL)**、**[@AbstractBike](https://github.com/AbstractBike)**、**[@andrewmains12](https://github.com/andrewmains12)**、**[@arpitjain099](https://github.com/arpitjain099)**、**[@boaz2026](https://github.com/boaz2026)**、**[@g4lb](https://github.com/g4lb)**、**[@luckysxx](https://github.com/luckysxx)**、**[@pcbeingused33](https://github.com/pcbeingused33)**、**[@vishalkotak](https://github.com/vishalkotak)**、**[@zaidrain06](https://github.com/zaidrain06)**！

感谢本月提交代码的社区贡献者：

- **[@dayan02dev](https://github.com/dayan02dev)** *[db#10726](https://github.com/GreptimeTeam/greptimedb/pull/10726)* *[db#10718](https://github.com/GreptimeTeam/greptimedb/pull/10718)* *[db#10491](https://github.com/GreptimeTeam/greptimedb/pull/10491)* *[db#10481](https://github.com/GreptimeTeam/greptimedb/pull/10481)* *[db#10443](https://github.com/GreptimeTeam/greptimedb/pull/10443)* *[db#10397](https://github.com/GreptimeTeam/greptimedb/pull/10397)* *[db#10386](https://github.com/GreptimeTeam/greptimedb/pull/10386)*
- **[@Alorun](https://github.com/Alorun)** *[db#10588](https://github.com/GreptimeTeam/greptimedb/pull/10588)* *[db#10465](https://github.com/GreptimeTeam/greptimedb/pull/10465)* *[db#10306](https://github.com/GreptimeTeam/greptimedb/pull/10306)*
- **[@shuxiachai](https://github.com/shuxiachai)** *[db#10458](https://github.com/GreptimeTeam/greptimedb/pull/10458)* *[db#10446](https://github.com/GreptimeTeam/greptimedb/pull/10446)* *[db#10445](https://github.com/GreptimeTeam/greptimedb/pull/10445)*
- **[@Aumnertic](https://github.com/Aumnertic)** *[db#10090](https://github.com/GreptimeTeam/greptimedb/pull/10090)* *[db#9891](https://github.com/GreptimeTeam/greptimedb/pull/9891)*
- **[@BootstrapperSBL](https://github.com/BootstrapperSBL)** *[db#10679](https://github.com/GreptimeTeam/greptimedb/pull/10679)* *[db#10112](https://github.com/GreptimeTeam/greptimedb/pull/10112)*
- **[@florissmit10](https://github.com/florissmit10)** *[db#10345](https://github.com/GreptimeTeam/greptimedb/pull/10345)* *[db#9986](https://github.com/GreptimeTeam/greptimedb/pull/9986)*
- **[@SAMARTHJAISWAL](https://github.com/SAMARTHJAISWAL)** *[db#10643](https://github.com/GreptimeTeam/greptimedb/pull/10643)* *[db#10560](https://github.com/GreptimeTeam/greptimedb/pull/10560)*
- **[@Tyagiquamar](https://github.com/Tyagiquamar)** *[db#10251](https://github.com/GreptimeTeam/greptimedb/pull/10251)* *[db#9057](https://github.com/GreptimeTeam/greptimedb/pull/9057)*
- **[@AbstractBike](https://github.com/AbstractBike)** *[db#9518](https://github.com/GreptimeTeam/greptimedb/pull/9518)*
- **[@andrewmains12](https://github.com/andrewmains12)** *[db#10205](https://github.com/GreptimeTeam/greptimedb/pull/10205)*
- **[@arpitjain099](https://github.com/arpitjain099)** *[db#10299](https://github.com/GreptimeTeam/greptimedb/pull/10299)*
- **[@boaz2026](https://github.com/boaz2026)** *[db#10519](https://github.com/GreptimeTeam/greptimedb/pull/10519)*
- **[@fengyue-xve](https://github.com/fengyue-xve)** *[db#9452](https://github.com/GreptimeTeam/greptimedb/pull/9452)*
- **[@g4lb](https://github.com/g4lb)** *[db#10728](https://github.com/GreptimeTeam/greptimedb/pull/10728)*
- **[@lczllx](https://github.com/lczllx)** *[db#10045](https://github.com/GreptimeTeam/greptimedb/pull/10045)*
- **[@luckysxx](https://github.com/luckysxx)** *[db#10022](https://github.com/GreptimeTeam/greptimedb/pull/10022)*
- **[@pcbeingused33](https://github.com/pcbeingused33)** *[db#10639](https://github.com/GreptimeTeam/greptimedb/pull/10639)*
- **[@QuakeWang](https://github.com/QuakeWang)** *[db#10751](https://github.com/GreptimeTeam/greptimedb/pull/10751)*
- **[@tian1220A](https://github.com/tian1220A)** *[db#10200](https://github.com/GreptimeTeam/greptimedb/pull/10200)*
- **[@vishalkotak](https://github.com/vishalkotak)** *[db#10717](https://github.com/GreptimeTeam/greptimedb/pull/10717)*
- **[@zaidrain06](https://github.com/zaidrain06)** *[db#10710](https://github.com/GreptimeTeam/greptimedb/pull/10710)*

v1.3.2 中有多项修复来自社区贡献者：`last_non_null` 表中已删除数据重新出现（[db#10717](https://github.com/GreptimeTeam/greptimedb/pull/10717)、[db#10726](https://github.com/GreptimeTeam/greptimedb/pull/10726)），按 Field 列分区的表执行 `DELETE` 不生效（[db#10710](https://github.com/GreptimeTeam/greptimedb/pull/10710)），`COPY FROM` 丢失精度（[db#10560](https://github.com/GreptimeTeam/greptimedb/pull/10560)），以及表 reconcile 后列顺序错误（[db#10251](https://github.com/GreptimeTeam/greptimedb/pull/10251)）。

## Good First Issues

第一次给 GreptimeDB 提 PR？下面这些 issue 适合上手，想认领可以直接在 issue 下留言。

### [Issue#6621](https://github.com/GreptimeTeam/greptimedb/issues/6621) Add config option to host on subpath

新增配置项，支持把 GreptimeDB 部署在 URL 前缀路径下（例如 `/monitoring/greptimedb`），避免跳转到错误的根路径。

关键词：Configuration, HTTP, Dashboard

难度：Medium

### [Issue#10737](https://github.com/GreptimeTeam/greptimedb/issues/10737) Disallow non-NULL primary-key tag defaults in CREATE and ALTER TABLE for sparse Mito tables

对使用 `WITH ('primary_key_encoding'='sparse')` 创建的表，在 `CREATE TABLE`、`ALTER TABLE ADD COLUMN` 和 `ALTER COLUMN ... SET DEFAULT` 中拒绝为主键（Tag）列设置非 `NULL` 默认值，不设默认值和 `DEFAULT NULL` 仍然允许。issue 中说明了这类默认值为什么会导致写入的行缺失 Tag 值。

关键词：DDL, SQL validation, sparse primary key

难度：Medium

## 参与社区

- 文档：https://docs.greptime.cn
- GitHub：https://github.com/GreptimeTeam/greptimedb
- X：https://x.com/Greptime

有 bug 或功能需求，欢迎提 issue，也可以到社区群里交流。
