# DROP DATABASE 功能初步实现 | Greptime 双周精选

Source: https://greptime.cn/blogs/2024-03-27-biweekly

## 内容概述

作为一个成长中的开源项目，GreptimeDB 的进展离不开来自全球的社区贡献者们，感谢各位！

最近的内容更新如下：

- 目前 `DROP DATABASE` 功能初步可用，提供 database 实例的快速删除能力
- Memtable 持续优化，实现 append 模式底层支持
- Metric engine 功能进一步迭代，提供基于 SQL 的的底层物理数据访问接口

## 社区贡献者名单

在过去的两周里，GreptimeDB 共合并了 54 个 PR，其中有 5 位独立贡献者，累计 6 个 PR 被成功合并，还有很多待合并的 PR。

祝贺以下各位在过去 2 周内成为我们活跃的贡献者：

- @[dimbtp](https://github.com/dimbtp) ([db#3582](https://github.com/GreptimeTeam/greptimedb/pull/3582))

- @[JetSquirrel](https://github.com/JetSquirrel) ([go#20](https://github.com/GreptimeTeam/greptimedb-ingester-go/pull/29))

- @[xifyang](https://github.com/xifyang) ([db#2211](https://github.com/GreptimeTeam/greptimedb/pull/2211#issuecomment-1705103538))

- @[xxxuuu](https://github.com/xxxuuu) ([db#3571](https://github.com/GreptimeTeam/greptimedb/pull/3571) [db#3568](https://github.com/GreptimeTeam/greptimedb/pull/3568))

- @[YCCDSZXH](https://github.com/YCCDSZXH) ([db#3539](https://github.com/GreptimeTeam/greptimedb/pull/3539))

🎉 热烈欢迎 @[xifyang](https://github.com/xifyang) @[xxxuuu](https://github.com/xxxuuu) @[JetSquirrel](https://github.com/JetSquirrel) @[YCCDSZXH](https://github.com/YCCDSZXH) 作为新的贡献者加入社区并成功合并了首个 PR，还有更多来自其他独立贡献者的 PR 正在等待合并。

<img src="/zh/blogs/2024-03-27-biweekly/image1.png" alt="Contributor of GreptimeDB" style="width: 80%; margin: 0 auto"/>

同时衷心感谢我们所有的成员和贡献者！是你们的付出让我们的项目得以成功，也是你们让 GreptimeDB 成为一个更优质的产品。让我们一起努力，建立一个更棒的社区！

## PR 亮点

### [db#3494](https://github.com/GreptimeTeam/greptimedb/pull/3494) 在 InfluxDB line protocol 写入 API 中支持 Gzip 压缩

通过为 InfluxDB line protocol 的 HTTP API 增加一个解压缩扩展层支持了 Gzip 压缩后的数据写入。

### [db#3501](https://github.com/GreptimeTeam/greptimedb/pull/3501) Memtable 支持按时间范围分区

通过将 Memtable 中写入的时序数据严格按照时间分区，GreptimeDB 可以确保 flush 到磁盘上的 SST 文件的时间范围彼此不重叠，从而加快点查询的性能。

注意：此特性仅在用户建表时明确指定了 `compaction.twcs.time_window` 参数时生效。

### [db#3527](https://github.com/GreptimeTeam/greptimedb/pull/3527) 增加集群维护模式接口

为 GreptimeDB 的 metasrv 节点增加了维护模式。例如：当集群处于计划内的滚动升级状态时，metasrv 需要能够容忍 datanode 短暂的不可用，避免发起不必要的故障转移。

### [db#3524](https://github.com/GreptimeTeam/greptimedb/pull/3524) 支持建表时指定 Memtable 参数

随着新 memtable 实现的加入，GreptimeDB 也提供了更多的 memtable 选项供用户在创建表时配置，从而更好地适应不同的工作负载。此外，在 [db#3547](https://github.com/GreptimeTeam/greptimedb/pull/3547) 中，`MergeTreeMemtable` 已经被重命名为 `PartitionTreeMemtable`。

### [db#3541](https://github.com/GreptimeTeam/greptimedb/pull/3541)[db#3534](https://github.com/GreptimeTeam/greptimedb/pull/3534) 初步实现 `DROP DATABASE` 语句

`DROP DATABASE` 语句可以快速删除一个 database 实例下的所有表和资源。

`DROP DATABASE` 是 GreptimeDB 功能设计中的一环，得益于用户的积极反馈，我们加快了该需求的实现。在此诚邀大家使用 GreptimeDB 并提供宝贵意见，您的反馈可能会加速我们下一个需求的实现。

### [db#3508](https://github.com/GreptimeTeam/greptimedb/pull/3508) 实现流计算中的共享状态存储（`Arrangement`）

部分流计算算子需要将一部分状态存储在一个共享的存储中以便其他的算子访问，本 PR 提供一个基于 BTreeMap 的共享状态存储。更多关于 Greptime Flow 的开发进展，请关注 [#3187](https://github.com/GreptimeTeam/greptimedb/pull/3187)。

## Good First Issue

### [db#3511 在 `COPY FROM` 语句中支持指定时间范围，从而避免导入不需要的数据](https://github.com/GreptimeTeam/greptimedb/issues/3511) 

`COPY FROM` 语句常常用于从备份文件中恢复表的数据，如果能够支持过滤指定时间范围，可以避免导入不需要的数据，加快数据恢复的速度。

关键词：备份/恢复、过滤、时间戳

难度：中等

### [db#3511 在 COPY FROM 语句中支持指定时间范围，从而避免导入不需要的数据](https://github.com/GreptimeTeam/greptimedb/issues/3511)

COPY FROM 语句常常用于从备份文件中恢复表的数据，如果能够支持过滤指定时间范围，可以避免导入不需要的数据，加快数据恢复的速度。

关键词：备份/恢复、过滤、时间戳

难度：中等

### [db#3477 在 `to_timezone` 函数的入参中支持将 UNIX 时间戳数值类型转换为特定时区的时间戳 ](https://github.com/GreptimeTeam/greptimedb/issues/3477) 

`to_timezone` 函数用于将一个时间戳转换为另一个指定时区的时间戳。当前 `to_timezone` 函数只支持接收时间戳字符串表示作为参数，如 "`2024-03-27T11:01:50+08:00`" 。此 issue 需要使 `to_timezone` 支持 UNIX 毫秒时间戳数值类型，如 `1711508510000`。

关键词：时间戳

难度：简单

## 关于 Greptime

[Greptime 格睿科技](https://greptime.cn/)专注于为可观测、物联网及车联网等领域提供实时、高效的数据存储和分析服务，帮助客户挖掘数据的深层价值。目前基于云原生的时序数据库 [GreptimeDB](https://github.com/GreptimeTeam/greptimedb) 已经衍生出多款适合不同用户的解决方案，更多信息或 demo 展示请联系下方小助手（微信号：greptime）。

欢迎对开源感兴趣的朋友们参与贡献和讨论，从带有 good first issue 标签的 issue 开始你的开源之旅吧～期待在开源社群里遇见你！添加小助手微信即可加入“技术交流群”与志同道合的朋友们面对面交流哦~

Star us on GitHub Now: https://github.com/GreptimeTeam/greptimedb

官网：https://greptime.cn/

文档：https://docs.greptime.cn/

Twitter: https://twitter.com/Greptime

Slack: https://greptime.com/slack

LinkedIn: https://www.linkedin.com/company/greptime/
