From 3b5011938e9701bcc23c80a435479531d7311126 Mon Sep 17 00:00:00 2001 From: Weny Xu Date: Thu, 16 May 2024 14:10:44 +0800 Subject: [PATCH] chore: add `Add missing Tine Index constraint` --- docs/nightly/en/user-guide/upgrade.md | 36 +++++++++++++++++++++++-- docs/nightly/zh/user-guide/upgrade.md | 38 +++++++++++++++++++++++++-- 2 files changed, 70 insertions(+), 4 deletions(-) diff --git a/docs/nightly/en/user-guide/upgrade.md b/docs/nightly/en/user-guide/upgrade.md index e988b5245..ff6fa17e1 100644 --- a/docs/nightly/en/user-guide/upgrade.md +++ b/docs/nightly/en/user-guide/upgrade.md @@ -150,8 +150,40 @@ CREATE TABLE IF NOT EXISTS "phy" ( ) ENGINE=metric WITH( - physical_metric_table = '', - regions = 1 + physical_metric_table = '' +); +``` + +#### Add missing Time Index constraint + +Before: +```sql +CREATE TABLE IF NOT EXISTS "phy" ( + "ts" TIMESTAMP(3) NOT NULL, + "val" DOUBLE NULL, + "host" STRING NULL, + "job" STRING NULL, + PRIMARY KEY ("host", "job") +) +ENGINE=metric +WITH( + physical_metric_table = '' +); +``` + +After: +```sql +CREATE TABLE IF NOT EXISTS "phy" ( + "ts" TIMESTAMP(3) NOT NULL, + "val" DOUBLE NULL, + "host" STRING NULL, + "job" STRING NULL, + PRIMARY KEY ("host", "job") + TIME INDEX ("ts") +) +ENGINE=metric +WITH( + physical_metric_table = '' ); ``` diff --git a/docs/nightly/zh/user-guide/upgrade.md b/docs/nightly/zh/user-guide/upgrade.md index 0f45254cc..9e95545e9 100644 --- a/docs/nightly/zh/user-guide/upgrade.md +++ b/docs/nightly/zh/user-guide/upgrade.md @@ -169,11 +169,45 @@ CREATE TABLE IF NOT EXISTS "phy" ( ) ENGINE=metric WITH( - physical_metric_table = '', - regions = 1 + physical_metric_table = '' ); ``` + +#### 添加缺失的 Time Index 约束 + +修改前: +```sql +CREATE TABLE IF NOT EXISTS "phy" ( + "ts" TIMESTAMP(3) NOT NULL, + "val" DOUBLE NULL, + "host" STRING NULL, + "job" STRING NULL, + PRIMARY KEY ("host", "job") +) +ENGINE=metric +WITH( + physical_metric_table = '' +); +``` + +修改后: +```sql +CREATE TABLE IF NOT EXISTS "phy" ( + "ts" TIMESTAMP(3) NOT NULL, + "val" DOUBLE NULL, + "host" STRING NULL, + "job" STRING NULL, + PRIMARY KEY ("host", "job") + TIME INDEX ("ts") +) +ENGINE=metric +WITH( + physical_metric_table = '' +); +``` + + ### 导入表结构和数据 然后您需要执行上一步生成的 SQL 文件。首先是 `greptime-public.sql`。在之前的步骤中导出的 SQL 语句使用的是 PostgreSQL 方言,接下来的操作都将通过 [PG 协议](/user-guide/clients/postgresql.md)来进行。本文档假设客户端为 `psql`。