# Introducing the Cluster Info Table for Optimized Cluster Management, Support Alter Column Type | Greptime Biweekly Report

Source: https://greptime.com/blogs/2024-05-08-biweekly-report

## Summary

Together with our global community of contributors, GreptimeDB continues to evolve and flourish as a growing open-source project. We are grateful to each and every one of you.

Below are the highlights among recent commits:

- Add the `cluster_info` table to `information_schema`: This allows users to query the status of each node in the cluster via SQL.

- Support alters column type: GreptimeDB currently supports modifying column data types in tables. 

- Introduce new optimizer rules to optimize `count(*)` query performance.

## Contributors

For the past two weeks, our community has been super active with a total of 62 PRs merged. 13 PRs from 5 individual contributors merged successfully, and lots are pending to be merged.

Congrats on becoming our most active contributors in the past 2 weeks:

- @[CookiePieWw](https://github.com/CookiePieWw) ([#3842](https://github.com/GreptimeTeam/greptimedb/pull/3842) [#3840](https://github.com/GreptimeTeam/greptimedb/pull/3840) [#3818](https://github.com/GreptimeTeam/greptimedb/pull/3818) [#3756](https://github.com/GreptimeTeam/greptimedb/pull/3756))

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

- @[irenjj](https://github.com/irenjj) ([#3819](https://github.com/GreptimeTeam/greptimedb/pull/3819) [#3744](https://github.com/GreptimeTeam/greptimedb/pull/3744) [docs#894](https://github.com/GreptimeTeam/docs/pull/894))

- @[Kelvinyu1117](https://github.com/Kelvinyu1117) ([#3829](https://github.com/GreptimeTeam/greptimedb/pull/3829))

- @[KKould](https://github.com/KKould) ([docs#935](https://github.com/GreptimeTeam/docs/pull/935) [#3796](https://github.com/GreptimeTeam/greptimedb/pull/3796) [#3745](https://github.com/GreptimeTeam/greptimedb/pull/3745) [#3757](https://github.com/GreptimeTeam/greptimedb/pull/3757))

👏  Welcome contributor @[Kelvinyu1117](https://github.com/Kelvinyu1117) join to the community as the new individual contributor, and congratulations on successfully merging their first PR, more PRs are waiting to be merged.

<p><img src="/blogs/2024-05-08-biweekly-report/contributorpost.png" alt="New Contributor of GreptimeDB" style="width: 70%; margin: 0 auto"></p>

A big THANK YOU to all our members and contributors! It is people like you who are making GreptimeDB a great product. Let's build an even greater community together.

## Highlights of Recent PRs

### [#3796](https://github.com/GreptimeTeam/greptimedb/pull/3796) [#3757](https://github.com/GreptimeTeam/greptimedb/pull/3757) [#3745](https://github.com/GreptimeTeam/greptimedb/pull/3745) Support column type changes in tables

This patch supports altering column type. It allows users to easily change the data type of columns in the table without rebuilding the table or manually migrating data, which improves the flexibility and maintainability of the database.

For example, the following statement changes the `load_15` column of the `monitor` table to the `STRING` type:

```sql
ALTER TABLE monitor MODIFY COLUMN load_15 STRING;
```

Note: The modified column cannot be a tag (primary key) or the time index. It must be nullable to ensure that the data can be safely converted (returns `NULL` on cast failures).

### [#3709](https://github.com/GreptimeTeam/greptimedb/pull/3709) Write manifests in background tasks

This PR supports writing manifest files in the background thread instead of in the region worker thread. 

If the region worker thread is responsible for writing the manifest file, it may cause the region worker thread to be blocked. So we move this operation to background thread to reduce the time the worker thread is blocked.

### [#3832](https://github.com/GreptimeTeam/greptimedb/pull/3832) Add cluster_info table to information_schema

This patch adds the `cluster_info` table to `information_schema`. `cluster_info` provides the current cluster info, like node topology. This feature can assist administrators in monitoring and managing the health status of the database cluster, promptly identifying and resolving issues.

Give an example:

```shell
mysql> USE INFORMATION_SCHEMA;
mysql> SELECT * FROM CLUSTER_INFO;
```

The result in standalone mode is as follows:

```shell
mysql> SELECT * FROM CLUSTER_INFO;
+---------+------------+-----------+---------+------------+-------------------------+--------+-------------+
| peer_id | peer_type  | peer_addr | version | git_commit | start_time              | uptime | active_time |
+---------+------------+-----------+---------+------------+-------------------------+--------+-------------+
| 0       | STANDALONE |           | 0.7.2   | 86ab3d9    | 2024-04-30T06:40:02.074 | 18ms   |             |
+---------+------------+-----------+---------+------------+-------------------------+--------+-------------+
```

The result in distributed mode is as follows:

```shell
+---------+-----------+----------------+---------+------------+-------------------------+----------+-------------+
| peer_id | peer_type | peer_addr      | version | git_commit | start_time              | uptime   | active_time |
+---------+-----------+----------------+---------+------------+-------------------------+----------+-------------+
| 1       | DATANODE  | 127.0.0.1:4101 | 0.7.2   | 86ab3d9    | 2024-04-30T06:40:04.791 | 4s 478ms | 1s 467ms    |
| 2       | DATANODE  | 127.0.0.1:4102 | 0.7.2   | 86ab3d9    | 2024-04-30T06:40:06.098 | 3s 171ms | 162ms       |
| 3       | DATANODE  | 127.0.0.1:4103 | 0.7.2   | 86ab3d9    | 2024-04-30T06:40:07.425 | 1s 844ms | 1s 839ms    |
| -1      | FRONTEND  | 127.0.0.1:4001 | 0.7.2   | 86ab3d9    | 2024-04-30T06:40:08.815 | 454ms    | 47ms        |
| 0       | METASRV   | 127.0.0.1:3002 | unknown | unknown    |                         |          |             |
+---------+-----------+----------------+---------+------------+-------------------------+----------+-------------+
```

### [#3845](https://github.com/GreptimeTeam/greptimedb/pull/3845) Optimize count(*) query performance

`count()` is a commonly used aggregate function for counting the number of rows in a table. To enhance query performance, new optimizer rules have been introduced to optimize the execution plan of `count()` queries. This reduces query time and improves the system's response speed, which is particularly important for scenarios involving large datasets and frequent statistical queries.

The new optimization rules transform `count()` into `count(<TIME INDEX>)`. This change has improved the performance of `count()` by five times. This optimization is based on the fact that the underlying storage engine scans the time index column faster than the primary key column. Reading the time index column does not require decoding like reading the primary key column does.

### [#3858](https://github.com/GreptimeTeam/greptimedb/pull/3858) Mirror insert req to flow node

- Add a path in `do_request` of Inserter to allow copy source table insert requests and send to flow node.

- Also added `TableFlowManager` field in `Inserter`  to allow query which insert request should go which flownode, but since  we only have standalone flownode for now, they are mostly blanket impl.

- Some minor refactors, including `flownode` `handle_request` change to `handle_requests` for batching request, and add XXXRef for Flow related managers.

## Good First Issue

### [#3336](https://github.com/GreptimeTeam/greptimedb/issues/3336) TLS for gRPC service

Currently, GreptimeDB's gRPC service does not support encryption. Adding TLS protocol support will enhance the security when using the gRPC protocol.

Keywords: gRPC, TLS, security

Difficulty: Medium

### [#3265](https://github.com/GreptimeTeam/greptimedb/issues/3265) Add more tests for Copy From

Add more tests for Copy from to ensure Copy from behaves as expected.

Keywords: test

Difficulty: Simple

### [#3004](https://github.com/GreptimeTeam/greptimedb/issues/3004) Checksum for manifests

The manifest doesn't have any checksum for data validation. We need a way to do the checksum validation for region manifests. A possible way is to save the checksum as the part of manifest  file name, for example, `000000000001-{checksum}.json`.

After reading the file content, we can calculate the  content checksum by CRC32 or other algorithms and ensure the value is  equal to the checksum in the file name.

Keywords: manifests, CRC32

Difficulty: Medium

---

#### About Greptime


Greptime offers industry-leading time series database products and solutions to empower IoT and Observability scenarios, enabling enterprises to uncover valuable insights from their data with less time, complexity, and cost.

[GreptimeDB](https://github.com/GreptimeTeam/greptimedb) is an open-source, high-performance time-series database offering unified storage and analysis for metrics, logs, and events. Try it out instantly with [GreptimeCloud](https://www.greptime.com/product/cloud), a fully-managed DBaaS solution—no deployment needed!

The [Edge-Cloud Integrated Solution](https://greptime.com/product/carcloud) combines multimodal edge databases with cloud-based GreptimeDB to optimize IoT edge scenarios, cutting costs while boosting data performance.

Star us on [GitHub](https://github.com/GreptimeTeam/greptimedb) or join GreptimeDB Community on [Slack](https://www.greptime.com/slack) to get connected.
