Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ For more information on the relationship between partitions and regions, refer t

## Partition

In GreptimeDB, a table can be horizontally partitioned in multiple ways and it uses the same
partitioning types (and corresponding syntax) as in MySQL. Currently, GreptimeDB supports "RANGE COLUMNS partitioning".
In GreptimeDB, a table can be horizontally partitioned by column value ranges.
Currently, GreptimeDB supports range partitioning with the `PARTITION ON COLUMNS` syntax.

Each partition includes only a portion of the data from the table, and is
grouped by some column(s) value range. For example, we can partition a table in GreptimeDB like
Expand All @@ -59,10 +59,10 @@ The syntax mainly consists of two parts:

1. `PARTITION ON COLUMNS` followed by a comma-separated list of column names. This specifies which columns will be used for partitioning. The columns specified here must be of the Tag type (as specified by the PRIMARY KEY). Note that the ranges of all partitions must **not** overlap.

2. `RULE LIST` is a list of multiple partition rules. Each rule is a combination of a partition name and a partition condition. The expressions here can use `=`, `!=`, `>`, `>=`, `<`, `<=`, `AND`, `OR`, column names, and literals.
2. `RULE LIST` is a list of multiple partition rules. Each rule is a partition condition, and GreptimeDB generates partition names such as `p0`, `p1`, and so on for these rules. The expressions here can use `=`, `!=`, `>`, `>=`, `<`, `<=`, `AND`, `OR`, column names, and literals.

:::tip Note
Currently expressions are not supported in "PARTITION BY RANGE" syntax.
The parentheses in `PARTITION ON COLUMNS (...)` only accept column names (e.g., `device_id`, `area`), not expressions like `device_id + 1`. GreptimeDB does not support MySQL's `PARTITION BY RANGE` syntax.
:::

### Example
Expand Down Expand Up @@ -179,15 +179,16 @@ FROM sensor_readings;

```sql
SELECT * FROM sensor_readings
WHERE area = 'North' AND device_id < 50;
WHERE area = 'North' AND device_id < 50
ORDER BY device_id;
```

```sql
+-----------+-------+---------------+---------------------+
| device_id | area | reading_value | ts |
+-----------+-------+---------------+---------------------+
| 10 | North | 21.8 | 2023-09-19 09:45:00 |
| 1 | North | 22.5 | 2023-09-19 08:30:00 |
| 10 | North | 21.8 | 2023-09-19 09:45:00 |
+-----------+-------+---------------+---------------------+
2 rows in set (0.03 sec)
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@ GreptimeDB 中的一个 region 具有相对固定的吞吐量,

## 分区

在 GreptimeDB 中,
表可以通过多种方式进行水平分区,
并且它使用与 MySQL 相同的分区类型(及相应的语法)。
目前,GreptimeDB 支持 RANGE COLUMNS 分区。
在 GreptimeDB 中,表可以按列值范围进行水平分区。
目前,GreptimeDB 支持使用 `PARTITION ON COLUMNS` 语法进行范围分区。

每个分区仅包含表中的一部分数据,
并按某些列的值范围进行分组。
Expand All @@ -61,10 +59,10 @@ PARTITION ON COLUMNS (<COLUMN LIST>) (

1. `PARTITION ON COLUMNS` 后跟一个用逗号分隔的列名列表,指定了将用于分区的列。这里指定的列必须是 Tag 类型(由 PRIMARY KEY 指定)。请注意,所有分区的范围必须**不能**重叠。

2. `RULE LIST` 是多个分区规则的列表。每个规则是分区名称和分区条件的组合。这里的表达式可以使用 `=`, `!=`, `>`, `>=`, `<`, `<=`, `AND`, `OR`, 列名和字面量。
2. `RULE LIST` 是多个分区规则的列表。每个规则是一个分区条件,GreptimeDB 会为这些规则生成 `p0`、`p1` 等分区名称。这里的表达式可以使用 `=`, `!=`, `>`, `>=`, `<`, `<=`, `AND`, `OR`, 列名和字面量。

:::tip 提示
目前在“PARTITION BY RANGE”语法中不支持表达式
`PARTITION ON COLUMNS` 括号里只能写列名(如 `device_id`、`area`),不支持表达式。GreptimeDB 不支持 MySQL 的 `PARTITION BY RANGE` 语法
:::

### 示例
Expand Down Expand Up @@ -181,15 +179,16 @@ FROM sensor_readings;

```sql
SELECT * FROM sensor_readings
WHERE area = 'North' AND device_id < 50;
WHERE area = 'North' AND device_id < 50
ORDER BY device_id;
```

```sql
+-----------+-------+---------------+---------------------+
| device_id | area | reading_value | ts |
+-----------+-------+---------------+---------------------+
| 10 | North | 21.8 | 2023-09-19 09:45:00 |
| 1 | North | 22.5 | 2023-09-19 08:30:00 |
| 10 | North | 21.8 | 2023-09-19 09:45:00 |
+-----------+-------+---------------+---------------------+
2 rows in set (0.03 sec)
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@ GreptimeDB 中的一个 region 具有相对固定的吞吐量,

## 分区

在 GreptimeDB 中,
表可以通过多种方式进行水平分区,
并且它使用与 MySQL 相同的分区类型(及相应的语法)。
目前,GreptimeDB 支持 RANGE COLUMNS 分区。
在 GreptimeDB 中,表可以按列值范围进行水平分区。
目前,GreptimeDB 支持使用 `PARTITION ON COLUMNS` 语法进行范围分区。

每个分区仅包含表中的一部分数据,
并按某些列的值范围进行分组。
Expand All @@ -61,10 +59,10 @@ PARTITION ON COLUMNS (<COLUMN LIST>) (

1. `PARTITION ON COLUMNS` 后跟一个用逗号分隔的列名列表,指定了将用于分区的列。这里指定的列必须是 Tag 类型(由 PRIMARY KEY 指定)。请注意,所有分区的范围必须**不能**重叠。

2. `RULE LIST` 是多个分区规则的列表。每个规则是分区名称和分区条件的组合。这里的表达式可以使用 `=`, `!=`, `>`, `>=`, `<`, `<=`, `AND`, `OR`, 列名和字面量。
2. `RULE LIST` 是多个分区规则的列表。每个规则是一个分区条件,GreptimeDB 会为这些规则生成 `p0`、`p1` 等分区名称。这里的表达式可以使用 `=`, `!=`, `>`, `>=`, `<`, `<=`, `AND`, `OR`, 列名和字面量。

:::tip 提示
目前在“PARTITION BY RANGE”语法中不支持表达式
`PARTITION ON COLUMNS` 括号里只能写列名(如 `device_id`、`area`),不支持表达式。GreptimeDB 不支持 MySQL 的 `PARTITION BY RANGE` 语法
:::

### 示例
Expand Down Expand Up @@ -181,15 +179,16 @@ FROM sensor_readings;

```sql
SELECT * FROM sensor_readings
WHERE area = 'North' AND device_id < 50;
WHERE area = 'North' AND device_id < 50
ORDER BY device_id;
```

```sql
+-----------+-------+---------------+---------------------+
| device_id | area | reading_value | ts |
+-----------+-------+---------------+---------------------+
| 10 | North | 21.8 | 2023-09-19 09:45:00 |
| 1 | North | 22.5 | 2023-09-19 08:30:00 |
| 10 | North | 21.8 | 2023-09-19 09:45:00 |
+-----------+-------+---------------+---------------------+
2 rows in set (0.03 sec)
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ For more information on the relationship between partitions and regions, refer t

## Partition

In GreptimeDB, a table can be horizontally partitioned in multiple ways and it uses the same
partitioning types (and corresponding syntax) as in MySQL. Currently, GreptimeDB supports "RANGE COLUMNS partitioning".
In GreptimeDB, a table can be horizontally partitioned by column value ranges.
Currently, GreptimeDB supports range partitioning with the `PARTITION ON COLUMNS` syntax.

Each partition includes only a portion of the data from the table, and is
grouped by some column(s) value range. For example, we can partition a table in GreptimeDB like
Expand All @@ -59,10 +59,10 @@ The syntax mainly consists of two parts:

1. `PARTITION ON COLUMNS` followed by a comma-separated list of column names. This specifies which columns will be used for partitioning. The columns specified here must be of the Tag type (as specified by the PRIMARY KEY). Note that the ranges of all partitions must **not** overlap.

2. `RULE LIST` is a list of multiple partition rules. Each rule is a combination of a partition name and a partition condition. The expressions here can use `=`, `!=`, `>`, `>=`, `<`, `<=`, `AND`, `OR`, column names, and literals.
2. `RULE LIST` is a list of multiple partition rules. Each rule is a partition condition, and GreptimeDB generates partition names such as `p0`, `p1`, and so on for these rules. The expressions here can use `=`, `!=`, `>`, `>=`, `<`, `<=`, `AND`, `OR`, column names, and literals.

:::tip Note
Currently expressions are not supported in "PARTITION BY RANGE" syntax.
The parentheses in `PARTITION ON COLUMNS (...)` only accept column names (e.g., `device_id`, `area`), not expressions like `device_id + 1`. GreptimeDB does not support MySQL's `PARTITION BY RANGE` syntax.
:::

### Example
Expand Down Expand Up @@ -179,15 +179,16 @@ FROM sensor_readings;

```sql
SELECT * FROM sensor_readings
WHERE area = 'North' AND device_id < 50;
WHERE area = 'North' AND device_id < 50
ORDER BY device_id;
```

```sql
+-----------+-------+---------------+---------------------+
| device_id | area | reading_value | ts |
+-----------+-------+---------------+---------------------+
| 10 | North | 21.8 | 2023-09-19 09:45:00 |
| 1 | North | 22.5 | 2023-09-19 08:30:00 |
| 10 | North | 21.8 | 2023-09-19 09:45:00 |
+-----------+-------+---------------+---------------------+
2 rows in set (0.03 sec)
```
Expand Down
Loading