+
+
+
+
+TDengine 社区致力于让更多的开发者理解和使用它。
+请填写**贡献者提交表**以选择您想收到的礼物。
+
+- [贡献者提交表](https://page.ma.scrmtech.com/form/index?pf_uid=27715_2095&id=12100)
+
+## 联系我们
+
+如果您有什么问题需要解决,或者有什么问题需要解答,可以添加微信:TDengineECO
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 3b1a66839d3d4779f00090a84e6895bd0d660d0d..5be84bec3483ac2f79f43941465df3b50047e661 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,15 +1,64 @@
# Contributing
-We appreciate contributions from all developers. Feel free to follow us, fork the repository, report bugs and even submit your code on GitHub. However, we would like developers to follow our guides to contribute for better corporation.
+We appreciate contributions from all developers. Feel free to follow us, fork the repository, report bugs, and even submit your code on GitHub. However, we would like developers to follow the guidelines in this document to ensure effective cooperation.
-## Report bugs
+## Reporting a bug
-Any users can report bugs to us through the [github issue tracker](https://github.com/taosdata/TDengine/issues). We appreciate a detailed description of the problem you met. It is better to provide the detailed steps on reproducing the bug. Otherwise, an appendix with log files generated by the bug is welcome.
+- Any users can report bugs to us through the **[GitHub issue tracker](https://github.com/taosdata/TDengine/issues)**. We would appreciate if you could provide **a detailed description** of the problem you encountered, including steps to reproduce it.
-## Read the contributor license agreement
+- Attaching log files caused by the bug is really appreciated.
-It is required to agree the Contributor Licence Agreement(CLA) before a user submitting his/her code patch. Follow the [TaosData CLA](https://www.taosdata.com/en/contributor/) link to read through the agreement.
+## Guidelines for committing code
-## Submit your code
+- You must agree to the **Contributor License Agreement(CLA) before submitting your code patch**. Follow the **[TAOSData CLA](https://cla-assistant.io/taosdata/TDengine)** link to read through and sign the agreement. If you do not accept the agreement, your contributions cannot be accepted.
-Before submitting your code, make sure to [read the contributor license agreement](#read-the-contributor-license-agreement) beforehand. If you don't accept the aggreement, please stop submitting. Your submission means you have accepted the agreement. Your submission should solve an issue or add a feature registered in the [github issue tracker](https://github.com/taosdata/TDengine/issues). If no corresponding issue or feature is found in the issue tracker, please create one. When submitting your code to our repository, please create a pull request with the issue number included.
+- Please solve an issue or add a feature registered in the **[GitHub issue tracker](https://github.com/taosdata/TDengine/issues)**.
+- If no corresponding issue or feature is found in the issue tracker, please **create one**.
+- When submitting your code to our repository, please create a pull request with the **issue number** included.
+
+## Guidelines for communicating
+
+1. Please be **nice and polite** in the description.
+2. **Active voice is better than passive voice in general**. Sentences in the active voice will highlight who is performing the action rather than the recipient of the action highlighted by the passive voice.
+3. Documentation writing advice
+
+- Spell the product name "TDengine" correctly. "TD" is written in capital letters, and there is no space between "TD" and "engine" (**Correct spelling: TDengine**).
+- Please **capitalize the first letter** of every sentence.
+- Leave **only one space** after periods or other punctuation marks.
+- Use **American spelling**.
+- When possible, **use second person** rather than first person (e.g.“You are recommended to use a reverse proxy such as Nginx.” rather than “We recommend to use a reverse proxy such as Nginx.”).
+
+5. Use **simple sentences**, rather than complex sentences.
+
+## Gifts for the contributors
+
+Developers, as long as you contribute to TDengine, whether it's code contributions to fix bugs or feature requests, or documentation changes, **you are eligible for a very special Contributor Souvenir Gift!**
+
+**You can choose one of the following gifts:**
+
+
+
+
+
+
+The TDengine community is committed to making TDengine accepted and used by more developers.
+
+Just fill out the **Contributor Submission Form** to choose your desired gift.
+
+- [Contributor Submission Form](https://page.ma.scrmtech.com/form/index?pf_uid=27715_2095&id=12100)
+
+## Contact us
+
+If you have any problems or questions that need help from us, please feel free to add our WeChat account: TDengineECO.
diff --git a/Jenkinsfile2 b/Jenkinsfile2
index 754617f99f71fa90380e42fa2b9b5f3248620d7c..d7df07f06afd8e1e483455e3ce925a03f28740fd 100644
--- a/Jenkinsfile2
+++ b/Jenkinsfile2
@@ -1,6 +1,7 @@
import hudson.model.Result
import hudson.model.*;
import jenkins.model.CauseOfInterruption
+docs_only=0
node {
}
@@ -29,6 +30,49 @@ def abort_previous(){
if (buildNumber > 1) milestone(buildNumber - 1)
milestone(buildNumber)
}
+def check_docs() {
+ if (env.CHANGE_URL =~ /\/TDengine\//) {
+ sh '''
+ hostname
+ date
+ env
+ '''
+ sh '''
+ cd ${WKC}
+ git reset --hard
+ git clean -fxd
+ rm -rf examples/rust/
+ git remote prune origin
+ git fetch
+ '''
+ script {
+ sh '''
+ cd ${WKC}
+ git checkout ''' + env.CHANGE_TARGET + '''
+ '''
+ }
+ sh '''
+ cd ${WKC}
+ git remote prune origin
+ git pull >/dev/null
+ git fetch origin +refs/pull/${CHANGE_ID}/merge
+ git checkout -qf FETCH_HEAD
+ '''
+ def file_changed = sh (
+ script: '''
+ cd ${WKC}
+ git --no-pager diff --name-only FETCH_HEAD `git merge-base FETCH_HEAD ${CHANGE_TARGET}`|grep -v "^docs/en/"|grep -v "^docs/zh/" || :
+ ''',
+ returnStdout: true
+ ).trim()
+ if (file_changed == '') {
+ echo "docs PR"
+ docs_only=1
+ } else {
+ echo file_changed
+ }
+ }
+}
def pre_test(){
sh '''
hostname
@@ -43,6 +87,7 @@ def pre_test(){
cd ${WKC}
git reset --hard
git clean -fxd
+ rm -rf examples/rust/
git remote prune origin
git fetch
'''
@@ -306,10 +351,27 @@ pipeline {
WKPY = '/var/lib/jenkins/workspace/taos-connector-python'
}
stages {
+ stage('check') {
+ when {
+ allOf {
+ not { expression { env.CHANGE_BRANCH =~ /docs\// }}
+ not { expression { env.CHANGE_URL =~ /\/TDinternal\// }}
+ }
+ }
+ parallel {
+ stage('check docs') {
+ agent{label " worker03 || slave215 || slave217 || slave219 || Mac_catalina "}
+ steps {
+ check_docs()
+ }
+ }
+ }
+ }
stage('run test') {
when {
allOf {
not { expression { env.CHANGE_BRANCH =~ /docs\// }}
+ expression { docs_only == 0 }
}
}
parallel {
diff --git a/README-CN.md b/README-CN.md
index 7df2733a2e76f602363f219d61cc1f877f48f12e..0b7e42d4fa19045e94f004ab61159a8d79e4bb82 100644
--- a/README-CN.md
+++ b/README-CN.md
@@ -21,17 +21,17 @@
TDengine 是一款开源、高性能、云原生的时序数据库 (Time-Series Database, TSDB)。TDengine 能被广泛运用于物联网、工业互联网、车联网、IT 运维、金融等领域。除核心的时序数据库功能外,TDengine 还提供缓存、数据订阅、流式计算等功能,是一极简的时序数据处理平台,最大程度的减小系统设计的复杂度,降低研发和运营成本。与其他时序数据库相比,TDengine 的主要优势如下:
-- 高性能:通过创新的存储引擎设计,无论是数据写入还是查询,TDengine 的性能比通用数据库快 10 倍以上,也远超其他时序数据库,存储空间不及通用数据库的1/10。
+- **高性能**:通过创新的存储引擎设计,无论是数据写入还是查询,TDengine 的性能比通用数据库快 10 倍以上,也远超其他时序数据库,存储空间不及通用数据库的1/10。
-- 云原生:通过原生分布式的设计,充分利用云平台的优势,TDengine 提供了水平扩展能力,具备弹性、韧性和可观测性,支持k8s部署,可运行在公有云、私有云和混合云上。
+- **云原生**:通过原生分布式的设计,充分利用云平台的优势,TDengine 提供了水平扩展能力,具备弹性、韧性和可观测性,支持k8s部署,可运行在公有云、私有云和混合云上。
-- 极简时序数据平台:TDengine 内建消息队列、缓存、流式计算等功能,应用无需再集成 Kafka/Redis/HBase/Spark 等软件,大幅降低系统的复杂度,降低应用开发和运营成本。
+- **极简时序数据平台**:TDengine 内建消息队列、缓存、流式计算等功能,应用无需再集成 Kafka/Redis/HBase/Spark 等软件,大幅降低系统的复杂度,降低应用开发和运营成本。
-- 分析能力:支持 SQL,同时为时序数据特有的分析提供SQL扩展。通过超级表、存储计算分离、分区分片、预计算、自定义函数等技术,TDengine 具备强大的分析能力。
+- **分析能力**:支持 SQL,同时为时序数据特有的分析提供SQL扩展。通过超级表、存储计算分离、分区分片、预计算、自定义函数等技术,TDengine 具备强大的分析能力。
-- 简单易用:无任何依赖,安装、集群几秒搞定;提供REST以及各种语言连接器,与众多第三方工具无缝集成;提供命令行程序,便于管理和即席查询;提供各种运维工具。
+- **简单易用**:无任何依赖,安装、集群几秒搞定;提供REST以及各种语言连接器,与众多第三方工具无缝集成;提供命令行程序,便于管理和即席查询;提供各种运维工具。
-- 核心开源:TDengine 的核心代码包括集群功能全部开源,截止到2022年8月1日,全球超过 135.9k 个运行实例,GitHub Star 18.7k,Fork 4.4k,社区活跃。
+- **核心开源**:TDengine 的核心代码包括集群功能全部开源,截止到2022年8月1日,全球超过 135.9k 个运行实例,GitHub Star 18.7k,Fork 4.4k,社区活跃。
# 文档
@@ -210,14 +210,14 @@ cmake .. -G "NMake Makefiles"
nmake
```
-### macOS 系统
+
# 安装
@@ -303,14 +303,14 @@ Query OK, 2 row(s) in set (0.001700s)
TDengine 提供了丰富的应用程序开发接口,其中包括 C/C++、Java、Python、Go、Node.js、C# 、RESTful 等,便于用户快速开发应用:
-- [Java](https://docs.taosdata.com/reference/connector/java/)
-- [C/C++](https://www.taosdata.com/cn/documentation/connector#c-cpp)
-- [Python](https://docs.taosdata.com/reference/connector/python/)
-- [Go](https://docs.taosdata.com/reference/connector/go/)
-- [Node.js](https://docs.taosdata.com/reference/connector/node/)
-- [Rust](https://docs.taosdata.com/reference/connector/rust/)
-- [C#](https://docs.taosdata.com/reference/connector/csharp/)
-- [RESTful API](https://docs.taosdata.com/reference/rest-api/)
+- [Java](https://docs.taosdata.com/connector/java/)
+- [C/C++](https://docs.taosdata.com/connector/cpp/)
+- [Python](https://docs.taosdata.com/connector/python/)
+- [Go](https://docs.taosdata.com/connector/go/)
+- [Node.js](https://docs.taosdata.com/connector/node/)
+- [Rust](https://docs.taosdata.com/connector/rust/)
+- [C#](https://docs.taosdata.com/connector/csharp/)
+- [RESTful API](https://docs.taosdata.com/connector/rest-api/)
# 成为社区贡献者
diff --git a/README.md b/README.md
index c915fe3aef8d46389af223708146a6a47dc8af0a..611d97aac9436bdcc732efcf98822f2dd11d74ab 100644
--- a/README.md
+++ b/README.md
@@ -15,43 +15,33 @@
[](https://coveralls.io/github/taosdata/TDengine?branch=develop)
[](https://bestpractices.coreinfrastructure.org/projects/4201)
-
English | [简体中文](README-CN.md) | We are hiring, check [here](https://tdengine.com/careers)
# What is TDengine?
+TDengine is an open source, high-performance, cloud native [time-series database](https://tdengine.com/tsdb/what-is-a-time-series-database/) optimized for Internet of Things (IoT), Connected Cars, and Industrial IoT. It enables efficient, real-time data ingestion, processing, and monitoring of TB and even PB scale data per day, generated by billions of sensors and data collectors. TDengine differentiates itself from other time-seires databases with the following advantages:
-TDengine is an open source, high performance , cloud native time-series database (Time-Series Database, TSDB).
-
-TDengine can be optimized for Internet of Things (IoT), Connected Cars, and Industrial IoT, IT operation and maintenance, finance and other fields. In addition to the core time series database functions, TDengine also provides functions such as caching, data subscription, and streaming computing. It is a minimalist time series data processing platform that minimizes the complexity of system design and reduces R&D and operating costs. Compared with other time series databases, the main advantages of TDengine are as follows:
-
+- **[High-Performance](https://tdengine.com/tdengine/high-performance-time-series-database/)**: TDengine is the only time-series database to solve the high cardinality issue to support billions of data collection points while out performing other time-series databases for data ingestion, querying and data compression.
-- High-Performance: TDengine is the only time-series database to solve the high cardinality issue to support billions of data collection points while out performing other time-series databases for data ingestion, querying and data compression.
+- **[Simplified Solution](https://tdengine.com/tdengine/simplified-time-series-data-solution/)**: Through built-in caching, stream processing and data subscription features, TDengine provides a simplified solution for time-series data processing. It reduces system design complexity and operation costs significantly.
-- Simplified Solution: Through built-in caching, stream processing and data subscription features, TDengine provides a simplified solution for time-series data processing. It reduces system design complexity and operation costs significantly.
+- **[Cloud Native](https://tdengine.com/tdengine/cloud-native-time-series-database/)**: Through native distributed design, sharding and partitioning, separation of compute and storage, RAFT, support for kubernetes deployment and full observability, TDengine is a cloud native Time-Series Database and can be deployed on public, private or hybrid clouds.
-- Cloud Native: Through native distributed design, sharding and partitioning, separation of compute and storage, RAFT, support for kubernetes deployment and full observability, TDengine is a cloud native Time-Series Database and can be deployed on public, private or hybrid clouds.
+- **[Ease of Use](https://docs.tdengine.com/get-started/docker/)**: For administrators, TDengine significantly reduces the effort to deploy and maintain. For developers, it provides a simple interface, simplified solution and seamless integrations for third party tools. For data users, it gives easy data access.
-- Ease of Use: For administrators, TDengine significantly reduces the effort to deploy and maintain. For developers, it provides a simple interface, simplified solution and seamless integrations for third party tools. For data users, it gives easy data access.
+- **[Easy Data Analytics](https://tdengine.com/tdengine/time-series-data-analytics-made-easy/)**: Through super tables, storage and compute separation, data partitioning by time interval, pre-computation and other means, TDengine makes it easy to explore, format, and get access to data in a highly efficient way.
-- Easy Data Analytics: Through super tables, storage and compute separation, data partitioning by time interval, pre-computation and other means, TDengine makes it easy to explore, format, and get access to data in a highly efficient way.
-
-- Open Source: TDengine’s core modules, including cluster feature, are all available under open source licenses. It has gathered 18.8k stars on GitHub, an active developer community, and over 137k running instances worldwide.
+- **[Open Source](https://tdengine.com/tdengine/open-source-time-series-database/)**: TDengine’s core modules, including cluster feature, are all available under open source licenses. It has gathered 18.8k stars on GitHub. There is an active developer community, and over 139k running instances worldwide.
# Documentation
-For user manual, system design and architecture, please refer to [TDengine Documentation](https://docs.taosdata.com) ([TDengine 文档](https://docs.taosdata.com))
+For user manual, system design and architecture, please refer to [TDengine Documentation](https://docs.tdengine.com) ([TDengine 文档](https://docs.taosdata.com))
# Building
+At the moment, TDengine server supports running on Linux and Windows systems. Any application can also choose the RESTful interface provided by taosAdapter to connect the taosd service . TDengine supports X64/ARM64 CPU, and it will support MIPS64, Alpha64, ARM32, RISC-V and other CPU architectures in the future.
-At the moment, TDengine server supports running on Linux, Windows systems.Any OS application can also choose the RESTful interface of taosAdapter to connect the taosd service . TDengine supports X64/ARM64 CPU , and it will support MIPS64, Alpha64, ARM32, RISC-V and other CPU architectures in the future.
-
-
-
-You can choose to install through source code according to your needs, [container](https://docs.taosdata.com/get-started/docker/), [installation package](https://docs.taosdata.com/get-started/package/) or [Kubenetes](https://docs.taosdata.com/deployment/k8s/) to install. This quick guide only applies to installing from source.
-
-
+You can choose to install through source code, [container](https://docs.tdengine.com/get-started/docker/), [installation package](https://docs.tdengine.com/get-started/package/) or [Kubernetes](https://docs.tdengine.com/deployment/k8s/). This quick guide only applies to installing from source.
TDengine provide a few useful tools such as taosBenchmark (was named taosdemo) and taosdump. They were part of TDengine. By default, TDengine compiling does not include taosTools. You can use `cmake .. -DBUILD_TOOLS=true` to make them be compiled with TDengine.
@@ -67,7 +57,6 @@ sudo apt-get install -y gcc cmake build-essential git libssl-dev
#### Install build dependencies for taosTools
-
To build the [taosTools](https://github.com/taosdata/taos-tools) on Ubuntu/Debian, the following packages need to be installed.
```bash
@@ -91,14 +80,13 @@ sudo dnf install -y gcc gcc-c++ make cmake epel-release git openssl-devel
#### Install build dependencies for taosTools on CentOS
-
#### CentOS 7.9
```
sudo yum install -y zlib-devel xz-devel snappy-devel jansson jansson-devel pkgconfig libatomic libstdc++-static openssl-devel
```
-#### CentOS 8/Rocky Linux
+#### CentOS 8/Rocky Linux
```
sudo yum install -y epel-release
@@ -109,14 +97,14 @@ sudo yum install -y zlib-devel xz-devel snappy-devel jansson jansson-devel pkgco
Note: Since snappy lacks pkg-config support (refer to [link](https://github.com/google/snappy/pull/86)), it leads a cmake prompt libsnappy not found. But snappy still works well.
-If the powertools installation fails, you can try to use:
+If the PowerTools installation fails, you can try to use:
+
```
-sudo yum config-manager --set-enabled Powertools
+sudo yum config-manager --set-enabled powertools
```
### Setup golang environment
-
TDengine includes a few components like taosAdapter developed by Go language. Please refer to golang.org official documentation for golang environment setup.
Please use version 1.14+. For the user in China, we recommend using a proxy to accelerate package downloading.
@@ -134,7 +122,7 @@ cmake .. -DBUILD_HTTP=false
### Setup rust environment
-TDengine includes a few compoments developed by Rust language. Please refer to rust-lang.org official documentation for rust environment setup.
+TDengine includes a few components developed by Rust language. Please refer to rust-lang.org official documentation for rust environment setup.
## Get the source codes
@@ -145,7 +133,6 @@ git clone https://github.com/taosdata/TDengine.git
cd TDengine
```
-
You can modify the file ~/.gitconfig to use ssh protocol instead of https for better download speed. You will need to upload ssh public key to GitHub first. Please refer to GitHub official documentation for detail.
```
@@ -155,14 +142,12 @@ You can modify the file ~/.gitconfig to use ssh protocol instead of https for be
## Special Note
-
[JDBC Connector](https://github.com/taosdata/taos-connector-jdbc), [Go Connector](https://github.com/taosdata/driver-go),[Python Connector](https://github.com/taosdata/taos-connector-python),[Node.js Connector](https://github.com/taosdata/taos-connector-node),[C# Connector](https://github.com/taosdata/taos-connector-dotnet) ,[Rust Connector](https://github.com/taosdata/taos-connector-rust) and [Grafana plugin](https://github.com/taosdata/grafanaplugin) has been moved to standalone repository.
## Build TDengine
### On Linux platform
-
You can run the bash script `build.sh` to build both TDengine and taosTools including taosBenchmark and taosdump as below:
```bash
@@ -178,7 +163,6 @@ cmake .. -DBUILD_TOOLS=true
make
```
-
You can use Jemalloc as memory allocator instead of glibc:
```
@@ -227,14 +211,14 @@ cmake .. -G "NMake Makefiles"
nmake
```
-### On macOS platform
+
# Installing
@@ -246,7 +230,7 @@ After building successfully, TDengine can be installed by
sudo make install
```
-Users can find more information about directories installed on the system in the [directory and files](https://docs.taosdata.com/reference/directory/) section.
+Users can find more information about directories installed on the system in the [directory and files](https://docs.taosdata.com/reference/directory/) section.
Installing from source code will also configure service management for TDengine.Users can also choose to [install from packages](https://docs.taosdata.com/get-started/package/) for it.
@@ -272,6 +256,7 @@ After building successfully, TDengine can be installed by:
nmake install
```
+
## Quick Run
@@ -318,16 +304,16 @@ Query OK, 2 row(s) in set (0.001700s)
## Official Connectors
-TDengine provides abundant developing tools for users to develop on TDengine. include C/C++、Java、Python、Go、Node.js、C# 、RESTful ,Follow the links below to find your desired connectors and relevant documentation.
+TDengine provides abundant developing tools for users to develop on TDengine. Follow the links below to find your desired connectors and relevant documentation.
-- [Java](https://docs.taosdata.com/reference/connector/java/)
-- [C/C++](https://docs.taosdata.com/reference/connector/cpp/)
-- [Python](https://docs.taosdata.com/reference/connector/python/)
-- [Go](https://docs.taosdata.com/reference/connector/go/)
-- [Node.js](https://docs.taosdata.com/reference/connector/node/)
-- [Rust](https://docs.taosdata.com/reference/connector/rust/)
-- [C#](https://docs.taosdata.com/reference/connector/csharp/)
-- [RESTful API](https://docs.taosdata.com/reference/rest-api/)
+- [Java](https://docs.tdengine.com/reference/connector/java/)
+- [C/C++](https://docs.tdengine.com/reference/connector/cpp/)
+- [Python](https://docs.tdengine.com/reference/connector/python/)
+- [Go](https://docs.tdengine.com/reference/connector/go/)
+- [Node.js](https://docs.tdengine.com/reference/connector/node/)
+- [Rust](https://docs.tdengine.com/reference/connector/rust/)
+- [C#](https://docs.tdengine.com/reference/connector/csharp/)
+- [RESTful API](https://docs.tdengine.com/reference/rest-api/)
# Contribute to TDengine
diff --git a/cmake/cmake.define b/cmake/cmake.define
index 5639d212d7308cbd452720b890ca79b442d9c47c..5d64815a9aa90741a0d6aca7e51518d2263932a2 100644
--- a/cmake/cmake.define
+++ b/cmake/cmake.define
@@ -2,8 +2,6 @@ cmake_minimum_required(VERSION 3.0)
set(CMAKE_VERBOSE_MAKEFILE OFF)
-SET(BUILD_SHARED_LIBS "OFF")
-
#set output directory
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/build/lib)
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/build/bin)
@@ -81,7 +79,7 @@ ENDIF ()
IF (TD_WINDOWS)
MESSAGE("${Yellow} set compiler flag for Windows! ${ColourReset}")
- SET(COMMON_FLAGS "/w /D_WIN32 /DWIN32 /Zi")
+ SET(COMMON_FLAGS "/w /D_WIN32 /DWIN32 /Zi /MTd")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO")
# IF (MSVC AND (MSVC_VERSION GREATER_EQUAL 1900))
# SET(COMMON_FLAGS "${COMMON_FLAGS} /Wv:18")
@@ -92,11 +90,20 @@ IF (TD_WINDOWS)
IF (CMAKE_DEPFILE_FLAGS_CXX)
SET(CMAKE_DEPFILE_FLAGS_CXX "")
ENDIF ()
+ IF (CMAKE_C_FLAGS_DEBUG)
+ SET(CMAKE_C_FLAGS_DEBUG "" CACHE STRING "" FORCE)
+ ENDIF ()
+ IF (CMAKE_CXX_FLAGS_DEBUG)
+ SET(CMAKE_CXX_FLAGS_DEBUG "" CACHE STRING "" FORCE)
+ ENDIF ()
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_FLAGS}")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAGS}")
ELSE ()
+ IF (${TD_DARWIN})
+ set(CMAKE_MACOSX_RPATH 0)
+ ENDIF ()
IF (${COVER} MATCHES "true")
MESSAGE(STATUS "Test coverage mode, add extra flags")
SET(GCC_COVERAGE_COMPILE_FLAGS "-fprofile-arcs -ftest-coverage")
diff --git a/cmake/cmake.install b/cmake/cmake.install
index 4e3d0b166aba447cf48fb664f429a885caece953..fd1e080ddab1478f73689e7cced405ae8404fbc2 100644
--- a/cmake/cmake.install
+++ b/cmake/cmake.install
@@ -1,38 +1,24 @@
-IF (EXISTS /var/lib/taos/dnode/dnodeCfg.json)
- INSTALL(CODE "MESSAGE(\"The default data directory /var/lib/taos contains old data of tdengine 2.x, please clear it before installing!\")")
-ELSEIF (EXISTS C:/TDengine/data/dnode/dnodeCfg.json)
- INSTALL(CODE "MESSAGE(\"The default data directory C:/TDengine/data contains old data of tdengine 2.x, please clear it before installing!\")")
-ELSEIF (TD_LINUX)
+SET(PREPARE_ENV_CMD "prepare_env_cmd")
+SET(PREPARE_ENV_TARGET "prepare_env_target")
+ADD_CUSTOM_COMMAND(OUTPUT ${PREPARE_ENV_CMD}
+ POST_BUILD
+ COMMAND echo "make test directory"
+ DEPENDS taosd
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${TD_TESTS_OUTPUT_DIR}/cfg/
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${TD_TESTS_OUTPUT_DIR}/log/
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${TD_TESTS_OUTPUT_DIR}/data/
+ COMMAND ${CMAKE_COMMAND} -E echo dataDir ${TD_TESTS_OUTPUT_DIR}/data > ${TD_TESTS_OUTPUT_DIR}/cfg/taos.cfg
+ COMMAND ${CMAKE_COMMAND} -E echo logDir ${TD_TESTS_OUTPUT_DIR}/log >> ${TD_TESTS_OUTPUT_DIR}/cfg/taos.cfg
+ COMMAND ${CMAKE_COMMAND} -E echo charset UTF-8 >> ${TD_TESTS_OUTPUT_DIR}/cfg/taos.cfg
+ COMMAND ${CMAKE_COMMAND} -E echo monitor 0 >> ${TD_TESTS_OUTPUT_DIR}/cfg/taos.cfg
+ COMMENT "prepare taosd environment")
+ADD_CUSTOM_TARGET(${PREPARE_ENV_TARGET} ALL WORKING_DIRECTORY ${TD_EXECUTABLE_OUTPUT_PATH} DEPENDS ${PREPARE_ENV_CMD})
+
+IF (TD_LINUX)
SET(TD_MAKE_INSTALL_SH "${TD_SOURCE_DIR}/packaging/tools/make_install.sh")
INSTALL(CODE "MESSAGE(\"make install script: ${TD_MAKE_INSTALL_SH}\")")
INSTALL(CODE "execute_process(COMMAND bash ${TD_MAKE_INSTALL_SH} ${TD_SOURCE_DIR} ${PROJECT_BINARY_DIR} Linux ${TD_VER_NUMBER})")
ELSEIF (TD_WINDOWS)
- SET(CMAKE_INSTALL_PREFIX C:/TDengine)
-
- # INSTALL(DIRECTORY ${TD_SOURCE_DIR}/src/connector/go DESTINATION connector)
- # INSTALL(DIRECTORY ${TD_SOURCE_DIR}/src/connector/nodejs DESTINATION connector)
- # INSTALL(DIRECTORY ${TD_SOURCE_DIR}/src/connector/python DESTINATION connector)
- # INSTALL(DIRECTORY ${TD_SOURCE_DIR}/src/connector/C\# DESTINATION connector)
- # INSTALL(DIRECTORY ${TD_SOURCE_DIR}/examples DESTINATION .)
- INSTALL(CODE "IF (NOT EXISTS ${CMAKE_INSTALL_PREFIX}/cfg/taos.cfg)
- execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${TD_SOURCE_DIR}/packaging/cfg/taos.cfg ${CMAKE_INSTALL_PREFIX}/cfg/taos.cfg)
- ENDIF ()")
- INSTALL(FILES ${TD_SOURCE_DIR}/include/client/taos.h DESTINATION include)
- INSTALL(FILES ${TD_SOURCE_DIR}/include/util/taoserror.h DESTINATION include)
- INSTALL(FILES ${TD_SOURCE_DIR}/include/libs/function/taosudf.h DESTINATION include)
- INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.lib DESTINATION driver)
- INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos_static.lib DESTINATION driver)
- INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.dll DESTINATION driver)
- INSTALL(FILES ${EXECUTABLE_OUTPUT_PATH}/taos.exe DESTINATION .)
- INSTALL(FILES ${EXECUTABLE_OUTPUT_PATH}/taosd.exe DESTINATION .)
- INSTALL(FILES ${EXECUTABLE_OUTPUT_PATH}/udfd.exe DESTINATION .)
- IF (BUILD_TOOLS)
- INSTALL(FILES ${EXECUTABLE_OUTPUT_PATH}/taosBenchmark.exe DESTINATION .)
- ENDIF ()
-
- IF (TD_MVN_INSTALLED)
- INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-2.0.38-dist.jar DESTINATION connector/jdbc)
- ENDIF ()
SET(TD_MAKE_INSTALL_SH "${TD_SOURCE_DIR}/packaging/tools/make_install.bat")
INSTALL(CODE "MESSAGE(\"make install script: ${TD_MAKE_INSTALL_SH}\")")
INSTALL(CODE "execute_process(COMMAND ${TD_MAKE_INSTALL_SH} :needAdmin ${TD_SOURCE_DIR} ${PROJECT_BINARY_DIR} Windows ${TD_VER_NUMBER})")
diff --git a/cmake/cmake.options b/cmake/cmake.options
index bec64f7bf00cdb0c6fddc713af0801eae08d45ea..3baccde4d711e7c7a535829c95a0ee8cdff3fae6 100644
--- a/cmake/cmake.options
+++ b/cmake/cmake.options
@@ -90,6 +90,12 @@ ELSE ()
ENDIF ()
ENDIF ()
+option(
+ BUILD_SHARED_LIBS
+ ""
+ OFF
+ )
+
option(
RUST_BINDINGS
"If build with rust-bindings"
diff --git a/cmake/cmake.platform b/cmake/cmake.platform
index 887fbd86d55d782cdf3c1d7c95dfee2dc2ec446d..3aa1ffc07e73acdf480a21b478d55e05153694f8 100644
--- a/cmake/cmake.platform
+++ b/cmake/cmake.platform
@@ -46,7 +46,7 @@ IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin
MESSAGE("Current system processor is ${CMAKE_SYSTEM_PROCESSOR}.")
IF (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64")
- MESSAGE("Current system arch is arm64")
+ MESSAGE("Current system arch is 64")
SET(TD_DARWIN_64 TRUE)
ADD_DEFINITIONS("-D_TD_DARWIN_64")
ENDIF ()
diff --git a/cmake/cmake.version b/cmake/cmake.version
index c8afc1a291d705e2da29042de3ac3299b7bfd265..db29644b387306ce8f3ee473921dab4c7d05b10a 100644
--- a/cmake/cmake.version
+++ b/cmake/cmake.version
@@ -2,7 +2,7 @@
IF (DEFINED VERNUMBER)
SET(TD_VER_NUMBER ${VERNUMBER})
ELSE ()
- SET(TD_VER_NUMBER "3.0.0.0")
+ SET(TD_VER_NUMBER "3.0.0.1")
ENDIF ()
IF (DEFINED VERCOMPATIBLE)
diff --git a/cmake/libuv_CMakeLists.txt.in b/cmake/libuv_CMakeLists.txt.in
index 14228b775f46fbde420b9e99117f3ebc0de03e88..9c48ddefef166b0bf0bdc5f3f0da7f501a351643 100644
--- a/cmake/libuv_CMakeLists.txt.in
+++ b/cmake/libuv_CMakeLists.txt.in
@@ -2,7 +2,7 @@
# libuv
ExternalProject_Add(libuv
GIT_REPOSITORY https://github.com/libuv/libuv.git
- GIT_TAG v1.42.0
+ GIT_TAG v1.44.2
SOURCE_DIR "${TD_CONTRIB_DIR}/libuv"
BINARY_DIR "${TD_CONTRIB_DIR}/libuv"
CONFIGURE_COMMAND ""
diff --git a/cmake/rust-bindings_CMakeLists.txt.in b/cmake/rust-bindings_CMakeLists.txt.in
deleted file mode 100644
index d16e86139b20fa94505953bc56108f1f61dbbffb..0000000000000000000000000000000000000000
--- a/cmake/rust-bindings_CMakeLists.txt.in
+++ /dev/null
@@ -1,12 +0,0 @@
-
-# rust-bindings
-ExternalProject_Add(rust-bindings
- GIT_REPOSITORY https://github.com/songtianyi/tdengine-rust-bindings.git
- GIT_TAG 7ed7a97
- SOURCE_DIR "${TD_SOURCE_DIR}/examples/rust"
- BINARY_DIR "${TD_SOURCE_DIR}/examples/rust"
- CONFIGURE_COMMAND ""
- BUILD_COMMAND ""
- INSTALL_COMMAND ""
- TEST_COMMAND ""
- )
diff --git a/cmake/taosadapter_CMakeLists.txt.in b/cmake/taosadapter_CMakeLists.txt.in
index ed8216be9127b8c5164c977420d3ccd8f6521d31..f182beed33c76200649f93d96b68c153ec452b9a 100644
--- a/cmake/taosadapter_CMakeLists.txt.in
+++ b/cmake/taosadapter_CMakeLists.txt.in
@@ -2,7 +2,7 @@
# taosadapter
ExternalProject_Add(taosadapter
GIT_REPOSITORY https://github.com/taosdata/taosadapter.git
- GIT_TAG 3d21433
+ GIT_TAG abed566
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosadapter"
BINARY_DIR ""
#BUILD_IN_SOURCE TRUE
diff --git a/cmake/taostools_CMakeLists.txt.in b/cmake/taostools_CMakeLists.txt.in
index 3a6eb3c25a553d588c9eb7eb703c6e4dd3da53db..68caf9a9acde518be86c143168245e1d01a4a389 100644
--- a/cmake/taostools_CMakeLists.txt.in
+++ b/cmake/taostools_CMakeLists.txt.in
@@ -2,7 +2,7 @@
# taos-tools
ExternalProject_Add(taos-tools
GIT_REPOSITORY https://github.com/taosdata/taos-tools.git
- GIT_TAG 53a0103
+ GIT_TAG 9cb965f
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools"
BINARY_DIR ""
#BUILD_IN_SOURCE TRUE
diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt
index b4e8825431475c09fbf925671e6d7f691c700b15..2dc7622f4601ad8b1fb5c578c6aa8b5f0df02daf 100644
--- a/contrib/CMakeLists.txt
+++ b/contrib/CMakeLists.txt
@@ -105,11 +105,6 @@ if(${BUILD_WITH_SQLITE})
cat("${TD_SUPPORT_DIR}/sqlite_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
endif(${BUILD_WITH_SQLITE})
-# rust-bindings
-if(${RUST_BINDINGS})
- cat("${TD_SUPPORT_DIR}/rust-bindings_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
-endif(${RUST_BINDINGS})
-
# lucene
if(${BUILD_WITH_LUCENE})
cat("${TD_SUPPORT_DIR}/lucene_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
@@ -140,24 +135,6 @@ execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY "${TD_CONTRIB_DIR}/deps-download")
execute_process(COMMAND "${CMAKE_COMMAND}" --build .
WORKING_DIRECTORY "${TD_CONTRIB_DIR}/deps-download")
-
-# clear submodule
-execute_process(COMMAND git submodule deinit -f tools/taos-tools
- WORKING_DIRECTORY "${TD_SOURCE_DIR}")
-execute_process(COMMAND git rm --cached tools/taos-tools
- WORKING_DIRECTORY "${TD_SOURCE_DIR}")
-execute_process(COMMAND git submodule deinit -f tools/taosadapter
- WORKING_DIRECTORY "${TD_SOURCE_DIR}")
-execute_process(COMMAND git rm --cached tools/taosadapter
- WORKING_DIRECTORY "${TD_SOURCE_DIR}")
-execute_process(COMMAND git submodule deinit -f tools/taosws-rs
- WORKING_DIRECTORY "${TD_SOURCE_DIR}")
-execute_process(COMMAND git rm --cached tools/taosws-rs
- WORKING_DIRECTORY "${TD_SOURCE_DIR}")
-execute_process(COMMAND git submodule deinit -f examples/rust
- WORKING_DIRECTORY "${TD_SOURCE_DIR}")
-execute_process(COMMAND git rm --cached examples/rust
- WORKING_DIRECTORY "${TD_SOURCE_DIR}")
# ================================================================================================
# Build
@@ -273,7 +250,7 @@ endif(${BUILD_WITH_NURAFT})
# pthread
if(${BUILD_PTHREAD})
- set(CMAKE_BUILD_TYPE release)
+ set(CMAKE_BUILD_TYPE debug)
add_definitions(-DPTW32_STATIC_LIB)
add_subdirectory(pthread EXCLUDE_FROM_ALL)
set_target_properties(libpthreadVC3 PROPERTIES OUTPUT_NAME pthread)
@@ -354,9 +331,11 @@ endif(${BUILD_WITH_TRAFT})
# LIBUV
if(${BUILD_WITH_UV})
- if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows")
- MESSAGE("Windows need set no-sign-compare")
- add_compile_options(-Wno-sign-compare)
+ if (TD_WINDOWS)
+ # There is no GetHostNameW function on win7.
+ file(READ "libuv/src/win/util.c" LIBUV_WIN_UTIL_CONTENT)
+ string(REPLACE "if (GetHostNameW(buf, UV_MAXHOSTNAMESIZE" "DWORD nSize = UV_MAXHOSTNAMESIZE;\n if (GetComputerNameW(buf, &nSize" LIBUV_WIN_UTIL_CONTENT "${LIBUV_WIN_UTIL_CONTENT}")
+ file(WRITE "libuv/src/win/util.c" "${LIBUV_WIN_UTIL_CONTENT}")
endif ()
add_subdirectory(libuv EXCLUDE_FROM_ALL)
endif(${BUILD_WITH_UV})
diff --git a/docs/assets/contributing-cup.jpg b/docs/assets/contributing-cup.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..2bf935132a9c2395a06efd92ff51ecb7244caac5
Binary files /dev/null and b/docs/assets/contributing-cup.jpg differ
diff --git a/docs/assets/contributing-notebook.jpg b/docs/assets/contributing-notebook.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..de32051cad6f659f6bf104290189076086bcb3a5
Binary files /dev/null and b/docs/assets/contributing-notebook.jpg differ
diff --git a/docs/assets/contributing-shirt.jpg b/docs/assets/contributing-shirt.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..bffe3aff1ac9bacbd008c997edbaf793af1e2de9
Binary files /dev/null and b/docs/assets/contributing-shirt.jpg differ
diff --git a/docs/en/01-index.md b/docs/en/01-index.md
index f5b7f3e0f61507efbb09506b48548c12317e700b..5265be42f81c4f43fa73e5b7d603d8989c2a5671 100644
--- a/docs/en/01-index.md
+++ b/docs/en/01-index.md
@@ -4,24 +4,24 @@ sidebar_label: Documentation Home
slug: /
---
-TDengine is a [high-performance](https://tdengine.com/fast), [scalable](https://tdengine.com/scalable) time series database with [SQL support](https://tdengine.com/sql-support). This document is the TDengine user manual. It introduces the basic, as well as novel concepts, in TDengine, and also talks in detail about installation, features, SQL, APIs, operation, maintenance, kernel design and other topics. It’s written mainly for architects, developers and system administrators.
+TDengine is an [open-source](https://tdengine.com/tdengine/open-source-time-series-database/), [cloud-native](https://tdengine.com/tdengine/cloud-native-time-series-database/) time-series database optimized for the Internet of Things (IoT), Connected Cars, and Industrial IoT. It enables efficient, real-time data ingestion, processing, and monitoring of TB and even PB scale data per day, generated by billions of sensors and data collectors. This document is the TDengine user manual. It introduces the basic, as well as novel concepts, in TDengine, and also talks in detail about installation, features, SQL, APIs, operation, maintenance, kernel design, and other topics. It’s written mainly for architects, developers, and system administrators.
To get an overview of TDengine, such as a feature list, benchmarks, and competitive advantages, please browse through the [Introduction](./intro) section.
-TDengine greatly improves the efficiency of data ingestion, querying and storage by exploiting the characteristics of time series data, introducing the novel concepts of "one table for one data collection point" and "super table", and designing an innovative storage engine. To understand the new concepts in TDengine and make full use of the features and capabilities of TDengine, please read [“Concepts”](./concept) thoroughly.
+TDengine greatly improves the efficiency of data ingestion, querying, and storage by exploiting the characteristics of time series data, introducing the novel concepts of "one table for one data collection point" and "super table", and designing an innovative storage engine. To understand the new concepts in TDengine and make full use of the features and capabilities of TDengine, please read [Concepts](./concept) thoroughly.
-If you are a developer, please read the [“Developer Guide”](./develop) carefully. This section introduces the database connection, data modeling, data ingestion, query, continuous query, cache, data subscription, user-defined functions, and other functionality in detail. Sample code is provided for a variety of programming languages. In most cases, you can just copy and paste the sample code, make a few changes to accommodate your application, and it will work.
+If you are a developer, please read the [Developer Guide](./develop) carefully. This section introduces the database connection, data modeling, data ingestion, query, continuous query, cache, data subscription, user-defined functions, and other functionality in detail. Sample code is provided for a variety of programming languages. In most cases, you can just copy and paste the sample code, and make a few changes to accommodate your application, and it will work.
-We live in the era of big data, and scale-up is unable to meet the growing needs of business. Any modern data system must have the ability to scale out, and clustering has become an indispensable feature of big data systems. Not only did the TDengine team develop the cluster feature, but also decided to open source this important feature. To learn how to deploy, manage and maintain a TDengine cluster please refer to ["cluster"](./cluster).
+We live in the era of big data, and scale-up is unable to meet the growing needs of the business. Any modern data system must have the ability to scale out, and clustering has become an indispensable feature of big data systems. Not only did the TDengine team develop the cluster feature, but also decided to open source this important feature. To learn how to deploy, manage and maintain a TDengine cluster please refer to [Cluster Deployment](../deployment).
-TDengine uses ubiquitious SQL as its query language, which greatly reduces learning costs and migration costs. In addition to the standard SQL, TDengine has extensions to better support time series data analysis. These extensions include functions such as roll up, interpolation and time weighted average, among many others. The ["SQL Reference"](./taos-sql) chapter describes the SQL syntax in detail, and lists the various supported commands and functions.
+TDengine uses ubiquitous SQL as its query language, which greatly reduces learning costs and migration costs. In addition to the standard SQL, TDengine has extensions to better support time series data analysis. These extensions include functions such as roll-up, interpolation, and time-weighted average, among many others. The [SQL Reference](./taos-sql) chapter describes the SQL syntax in detail and lists the various supported commands and functions.
-If you are a system administrator who cares about installation, upgrade, fault tolerance, disaster recovery, data import, data export, system configuration, how to monitor whether TDengine is running healthily, and how to improve system performance, please refer to, and thoroughly read the ["Administration"](./operation) section.
+If you are a system administrator who cares about installation, upgrade, fault tolerance, disaster recovery, data import, data export, system configuration, how to monitor whether TDengine is running healthily, and how to improve system performance, please refer to, and thoroughly read the [Administration](./operation) section.
-If you want to know more about TDengine tools, the REST API, and connectors for various programming languages, please see the ["Reference"](./reference) chapter.
+If you want to know more about TDengine tools, the REST API, and connectors for various programming languages, please see the [Reference](./reference) chapter.
-If you are very interested in the internal design of TDengine, please read the chapter ["Inside TDengine”](./tdinternal), which introduces the cluster design, data partitioning, sharding, writing, and reading processes in detail. If you want to study TDengine code or even contribute code, please read this chapter carefully.
+If you are very interested in the internal design of TDengine, please read the chapter [Inside TDengine](./tdinternal), which introduces the cluster design, data partitioning, sharding, writing, and reading processes in detail. If you want to study TDengine code or even contribute code, please read this chapter carefully.
-TDengine is an open source database, and we would love for you to be a part of TDengine. If you find any errors in the documentation, or see parts where more clarity or elaboration is needed, please click "Edit this page" at the bottom of each page to edit it directly.
+TDengine is an open-source database, and we would love for you to be a part of TDengine. If you find any errors in the documentation or see parts where more clarity or elaboration is needed, please click "Edit this page" at the bottom of each page to edit it directly.
-Together, we make a difference.
+Together, we make a difference!
diff --git a/docs/en/02-intro/index.md b/docs/en/02-intro/index.md
index f6766f910f4d7560b782bf02ffa97922523e6167..d385845d7c57203d6e1cc8ddb8d53307f2655914 100644
--- a/docs/en/02-intro/index.md
+++ b/docs/en/02-intro/index.md
@@ -3,7 +3,7 @@ title: Introduction
toc_max_heading_level: 2
---
-TDengine is a high-performance, scalable time-series database with SQL support. Its code, including its cluster feature is open source under GNU AGPL v3.0. Besides the database engine, it provides [caching](/develop/cache), [stream processing](/develop/continuous-query), [data subscription](/develop/subscribe) and other functionalities to reduce the complexity and cost of development and operation.
+TDengine is an open source, high-performance, cloud native [time-series database](https://tdengine.com/tsdb/) optimized for Internet of Things (IoT), Connected Cars, and Industrial IoT. Its code, including its cluster feature is open source under GNU AGPL v3.0. Besides the database engine, it provides [caching](../develop/cache), [stream processing](../develop/stream), [data subscription](../develop/tmq) and other functionalities to reduce the system complexity and cost of development and operation.
This section introduces the major features, competitive advantages, typical use-cases and benchmarks to help you get a high level overview of TDengine.
@@ -11,52 +11,69 @@ This section introduces the major features, competitive advantages, typical use-
The major features are listed below:
-1. While TDengine supports [using SQL to insert](/develop/insert-data/sql-writing), it also supports [Schemaless writing](/reference/schemaless/) just like NoSQL databases. TDengine also supports standard protocols like [InfluxDB LINE](/develop/insert-data/influxdb-line),[OpenTSDB Telnet](/develop/insert-data/opentsdb-telnet), [OpenTSDB JSON ](/develop/insert-data/opentsdb-json) among others.
-2. TDengine supports seamless integration with third-party data collection agents like [Telegraf](/third-party/telegraf),[Prometheus](/third-party/prometheus),[StatsD](/third-party/statsd),[collectd](/third-party/collectd),[icinga2](/third-party/icinga2), [TCollector](/third-party/tcollector), [EMQX](/third-party/emq-broker), [HiveMQ](/third-party/hive-mq-broker). These agents can write data into TDengine with simple configuration and without a single line of code.
-3. Support for [all kinds of queries](/develop/query-data), including aggregation, nested query, downsampling, interpolation and others.
-4. Support for [user defined functions](/develop/udf).
-5. Support for [caching](/develop/cache). TDengine always saves the last data point in cache, so Redis is not needed in some scenarios.
-6. Support for [continuous query](/develop/continuous-query).
-7. Support for [data subscription](/develop/subscribe) with the capability to specify filter conditions.
-8. Support for [cluster](/cluster/), with the capability of increasing processing power by adding more nodes. High availability is supported by replication.
-9. Provides an interactive [command-line interface](/reference/taos-shell) for management, maintenance and ad-hoc queries.
-10. Provides many ways to [import](/operation/import) and [export](/operation/export) data.
-11. Provides [monitoring](/operation/monitor) on running instances of TDengine.
-12. Provides [connectors](/reference/connector/) for [C/C++](/reference/connector/cpp), [Java](/reference/connector/java), [Python](/reference/connector/python), [Go](/reference/connector/go), [Rust](/reference/connector/rust), [Node.js](/reference/connector/node) and other programming languages.
-13. Provides a [REST API](/reference/rest-api/).
-14. Supports seamless integration with [Grafana](/third-party/grafana) for visualization.
-15. Supports seamless integration with Google Data Studio.
-
-For more details on features, please read through the entire documentation.
+1. Insert data
+ - Supports [using SQL to insert](../develop/insert-data/sql-writing).
+ - Supports [schemaless writing](../reference/schemaless/) just like NoSQL databases. It also supports standard protocols like [InfluxDB Line](../develop/insert-data/influxdb-line), [OpenTSDB Telnet](../develop/insert-data/opentsdb-telnet), [OpenTSDB JSON ](../develop/insert-data/opentsdb-json) among others.
+ - Supports seamless integration with third-party tools like [Telegraf](../third-party/telegraf/), [Prometheus](../third-party/prometheus/), [collectd](../third-party/collectd/), [StatsD](../third-party/statsd/), [TCollector](../third-party/tcollector/), [EMQX](../third-party/emq-broker), [HiveMQ](../third-party/hive-mq-broker), and [Icinga2](../third-party/icinga2/), they can write data into TDengine with simple configuration and without a single line of code.
+2. Query data
+ - Supports standard [SQL](../taos-sql/), including nested query.
+ - Supports [time series specific functions](../taos-sql/function/#time-series-extensions) and [time series specific queries](../taos-sql/distinguished), like downsampling, interpolation, cumulated sum, time weighted average, state window, session window and many others.
+ - Supports [User Defined Functions (UDF)](../taos-sql/udf).
+3. [Caching](../develop/cache/): TDengine always saves the last data point in cache, so Redis is not needed for time-series data processing.
+4. [Stream Processing](../develop/stream/): Not only is the continuous query is supported, but TDengine also supports event driven stream processing, so Flink or Spark is not needed for time-series data processing.
+5. [Data Subscription](../develop/tmq/): Application can subscribe a table or a set of tables. API is the same as Kafka, but you can specify filter conditions.
+6. Visualization
+ - Supports seamless integration with [Grafana](../third-party/grafana/) for visualization.
+ - Supports seamless integration with Google Data Studio.
+7. Cluster
+ - Supports [cluster](../deployment/) with the capability of increasing processing power by adding more nodes.
+ - Supports [deployment on Kubernetes](../deployment/k8s/).
+ - Supports high availability via data replication.
+8. Administration
+ - Provides [monitoring](../operation/monitor) on running instances of TDengine.
+ - Provides many ways to [import](../operation/import) and [export](../operation/export) data.
+9. Tools
+ - Provides an interactive [Command-line Interface (CLI)](../reference/taos-shell) for management, maintenance and ad-hoc queries.
+ - Provides a tool [taosBenchmark](../reference/taosbenchmark/) for testing the performance of TDengine.
+10. Programming
+ - Provides [connectors](../reference/connector/) for [C/C++](../reference/connector/cpp), [Java](../reference/connector/java), [Python](../reference/connector/python), [Go](../reference/connector/go), [Rust](../reference/connector/rust), [Node.js](../reference/connector/node) and other programming languages.
+ - Provides a [REST API](../reference/rest-api/).
+
+For more details on features, please read through the entire documentation.
## Competitive Advantages
-Time-series data is structured, not transactional, and is rarely deleted or updated. TDengine makes full use of [these characteristics of time series data](https://tdengine.com/2019/07/09/86.html) to build its own innovative storage engine and computing engine to differentiate itself from other time series databases, with the following advantages.
+By making full use of [characteristics of time series data](https://tdengine.com/tsdb/characteristics-of-time-series-data/), TDengine differentiates itself from other time series databases, with the following advantages.
-- **[High Performance](https://tdengine.com/fast)**: With an innovatively designed and purpose-built storage engine, TDengine outperforms other time series databases in data ingestion and querying while significantly reducing storage costs and compute costs.
+- **[High-Performance](https://tdengine.com/tdengine/high-performance-time-series-database/)**: TDengine is the only time-series database to solve the high cardinality issue to support billions of data collection points while out performing other time-series databases for data ingestion, querying and data compression.
-- **[Scalable](https://tdengine.com/scalable)**: TDengine provides out-of-box scalability and high-availability through its native distributed design. Nodes can be added through simple configuration to achieve greater data processing power. In addition, this feature is open source.
+- **[Simplified Solution](https://tdengine.com/tdengine/simplified-time-series-data-solution/)**: Through built-in caching, stream processing and data subscription features, TDengine provides a simplified solution for time-series data processing. It reduces system design complexity and operation costs significantly.
-- **[SQL Support](https://tdengine.com/sql-support)**: TDengine uses SQL as the query language, thereby reducing learning and migration costs, while adding SQL extensions to better handle time-series. Keeping NoSQL developers in mind, TDengine also supports convenient and flexible, schemaless data ingestion.
+- **[Cloud Native](https://tdengine.com/tdengine/cloud-native-time-series-database/)**: Through native distributed design, sharding and partitioning, separation of compute and storage, RAFT, support for Kubernetes deployment and full observability, TDengine is a cloud native Time-series Database and can be deployed on public, private or hybrid clouds.
-- **All in One**: TDengine has built-in caching, stream processing and data subscription functions. It is no longer necessary to integrate Kafka/Redis/HBase/Spark or other software in some scenarios. It makes the system architecture much simpler, cost-effective and easier to maintain.
+- **[Ease of Use](https://tdengine.com/tdengine/easy-time-series-data-platform/)**: For administrators, TDengine significantly reduces the effort to[
+ ](https://tdengine.com/tdengine/easy-time-series-data-platform/) deploy and maintain. For developers, it provides a simple interface, simplified solution and seamless integrations for third party tools. For data users, it gives easy data access.
-- **Seamless Integration**: Without a single line of code, TDengine provide seamless, configurable integration with third-party tools such as Telegraf, Grafana, EMQX, Prometheus, StatsD, collectd, etc. More third-party tools are being integrated.
+- **[Easy Data Analytics](https://tdengine.com/tdengine/time-series-data-analytics-made-easy/)**: Through super tables, storage and compute separation, data partitioning by time interval, pre-computation and other means, TDengine makes it easy to explore, format, and get access to data in a highly efficient way.
-- **Zero Management**: Installation and cluster setup can be done in seconds. Data partitioning and sharding are executed automatically. TDengine’s running status can be monitored via Grafana or other DevOps tools.
+- **[Open Source](https://tdengine.com/tdengine/open-source-time-series-database/)**: TDengine’s core modules, including cluster feature, are all available under open source licenses. It has gathered over 19k stars on GitHub. There is an active developer community, and over 140k running instances worldwide.
-- **Zero Learning Costs**: With SQL as the query language and support for ubiquitous tools like Python, Java, C/C++, Go, Rust, and Node.js connectors, and a REST API, there are zero learning costs.
+With TDengine, the total cost of ownership of your time-series data platform can be greatly reduced.
-- **Interactive Console**: TDengine provides convenient console access to the database, through a CLI, to run ad hoc queries, maintain the database, or manage the cluster, without any programming.
-
-With TDengine, the total cost of ownership of your time-series data platform can be greatly reduced. 1: With its superior performance, the computing and storage resources are reduced significantly 2: With SQL support, it can be seamlessly integrated with many third party tools, and learning costs/migration costs are reduced significantly 3: With its simple architecture and zero management, the operation and maintenance costs are reduced.
+1. With its superior performance, the computing and storage resources are reduced significantly.
+2. With SQL support, it can be seamlessly integrated with many third party tools, and learning costs/migration costs are reduced significantly.
+3. With its simplified solution and nearly zero management, the operation and maintenance costs are reduced significantly.
## Technical Ecosystem
+
This is how TDengine would be situated, in a typical time-series data processing platform:
+
+

-
Figure 1. TDengine Technical Ecosystem
+
Figure 1. TDengine Technical Ecosystem
+
On the left-hand side, there are data collection agents like OPC-UA, MQTT, Telegraf and Kafka. On the right-hand side, visualization/BI tools, HMI, Python/R, and IoT Apps can be connected. TDengine itself provides an interactive command-line interface and a web interface for management and maintenance.
@@ -66,48 +83,47 @@ As a high-performance, scalable and SQL supported time-series database, TDengine
### Characteristics and Requirements of Data Sources
-| **Data Source Characteristics and Requirements** | **Not Applicable** | **Might Be Applicable** | **Very Applicable** | **Description** |
-| -------------------------------------------------------- | ------------------ | ----------------------- | ------------------- | :----------------------------------------------------------- |
-| A massive amount of total data | | | √ | TDengine provides excellent scale-out functions in terms of capacity, and has a storage structure with matching high compression ratio to achieve the best storage efficiency in the industry.|
-| Data input velocity is extremely high | | | √ | TDengine's performance is much higher than that of other similar products. It can continuously process larger amounts of input data in the same hardware environment, and provides a performance evaluation tool that can easily run in the user environment. |
-| A huge number of data sources | | | √ | TDengine is optimized specifically for a huge number of data sources. It is especially suitable for efficiently ingesting, writing and querying data from billions of data sources. |
+| **Data Source Characteristics and Requirements** | **Not Applicable** | **Might Be Applicable** | **Very Applicable** | **Description** |
+| ------------------------------------------------ | ------------------ | ----------------------- | ------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
+| A massive amount of total data | | | √ | TDengine provides excellent scale-out functions in terms of capacity, and has a storage structure with matching high compression ratio to achieve the best storage efficiency in the industry. |
+| Data input velocity is extremely high | | | √ | TDengine's performance is much higher than that of other similar products. It can continuously process larger amounts of input data in the same hardware environment, and provides a performance evaluation tool that can easily run in the user environment. |
+| A huge number of data sources | | | √ | TDengine is optimized specifically for a huge number of data sources. It is especially suitable for efficiently ingesting, writing and querying data from billions of data sources. |
### System Architecture Requirements
-| **System Architecture Requirements** | **Not Applicable** | **Might Be Applicable** | **Very Applicable** | **Description** |
-| ------------------------------------------------- | ------------------ | ----------------------- | ------------------- | ------------------------------------------------------------ |
+| **System Architecture Requirements** | **Not Applicable** | **Might Be Applicable** | **Very Applicable** | **Description** |
+| ----------------------------------------- | ------------------ | ----------------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| A simple and reliable system architecture | | | √ | TDengine's system architecture is very simple and reliable, with its own message queue, cache, stream computing, monitoring and other functions. There is no need to integrate any additional third-party products. |
-| Fault-tolerance and high-reliability | | | √ | TDengine has cluster functions to automatically provide high-reliability and high-availability functions such as fault tolerance and disaster recovery. |
-| Standardization support | | | √ | TDengine supports standard SQL and provides SQL extensions for time-series data analysis. |
+| Fault-tolerance and high-reliability | | | √ | TDengine has cluster functions to automatically provide high-reliability and high-availability functions such as fault tolerance and disaster recovery. |
+| Standardization support | | | √ | TDengine supports standard SQL and provides SQL extensions for time-series data analysis. |
### System Function Requirements
-| **System Function Requirements** | **Not Applicable** | **Might Be Applicable** | **Very Applicable** | **Description** |
-| ------------------------------------------------- | ------------------ | ----------------------- | ------------------- | ------------------------------------------------------------ |
-| Complete data processing algorithms built-in | | √ | | While TDengine implements various general data processing algorithms, industry specific algorithms and special types of processing will need to be implemented at the application level.|
-| A large number of crosstab queries | | √ | | This type of processing is better handled by general purpose relational database systems but TDengine can work in concert with relational database systems to provide more complete solutions. |
+| **System Function Requirements** | **Not Applicable** | **Might Be Applicable** | **Very Applicable** | **Description** |
+| -------------------------------------------- | ------------------ | ----------------------- | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| Complete data processing algorithms built-in | | √ | | While TDengine implements various general data processing algorithms, industry specific algorithms and special types of processing will need to be implemented at the application level. |
+| A large number of crosstab queries | | √ | | This type of processing is better handled by general purpose relational database systems but TDengine can work in concert with relational database systems to provide more complete solutions. |
### System Performance Requirements
-| **System Performance Requirements** | **Not Applicable** | **Might Be Applicable** | **Very Applicable** | **Description** |
-| ------------------------------------------------- | ------------------ | ----------------------- | ------------------- | ------------------------------------------------------------ |
-| Very large total processing capacity | | | √ | TDengine’s cluster functions can easily improve processing capacity via multi-server coordination. |
-| Extremely high-speed data processing | | | √ | TDengine’s storage and data processing are optimized for IoT, and can process data many times faster than similar products.|
-| Extremely fast processing of high resolution data | | | √ | TDengine has achieved the same or better performance than other relational and NoSQL data processing systems. |
+| **System Performance Requirements** | **Not Applicable** | **Might Be Applicable** | **Very Applicable** | **Description** |
+| ------------------------------------------------- | ------------------ | ----------------------- | ------------------- | --------------------------------------------------------------------------------------------------------------------------- |
+| Very large total processing capacity | | | √ | TDengine’s cluster functions can easily improve processing capacity via multi-server coordination. |
+| Extremely high-speed data processing | | | √ | TDengine’s storage and data processing are optimized for IoT, and can process data many times faster than similar products. |
+| Extremely fast processing of high resolution data | | | √ | TDengine has achieved the same or better performance than other relational and NoSQL data processing systems. |
### System Maintenance Requirements
-| **System Maintenance Requirements** | **Not Applicable** | **Might Be Applicable** | **Very Applicable** | **Description** |
-| ------------------------------------------------- | ------------------ | ----------------------- | ------------------- | ------------------------------------------------------------ |
-| Native high-reliability | | | √ | TDengine has a very robust, reliable and easily configurable system architecture to simplify routine operation. Human errors and accidents are eliminated to the greatest extent, with a streamlined experience for operators. |
-| Minimize learning and maintenance costs | | | √ | In addition to being easily configurable, standard SQL support and the Taos shell for ad hoc queries makes maintenance simpler, allows reuse and reduces learning costs.|
-| Abundant talent supply | √ | | | Given the above, and given the extensive training and professional services provided by TDengine, it is easy to migrate from existing solutions or create a new and lasting solution based on TDengine.|
+| **System Maintenance Requirements** | **Not Applicable** | **Might Be Applicable** | **Very Applicable** | **Description** |
+| --------------------------------------- | ------------------ | ----------------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
+| Native high-reliability | | | √ | TDengine has a very robust, reliable and easily configurable system architecture to simplify routine operation. Human errors and accidents are eliminated to the greatest extent, with a streamlined experience for operators. |
+| Minimize learning and maintenance costs | | | √ | In addition to being easily configurable, standard SQL support and the TDengine CLI for ad hoc queries makes maintenance simpler, allows reuse and reduces learning costs. |
+| Abundant talent supply | √ | | | Given the above, and given the extensive training and professional services provided by TDengine, it is easy to migrate from existing solutions or create a new and lasting solution based on TDengine. |
## Comparison with other databases
- [Writing Performance Comparison of TDengine and InfluxDB ](https://tdengine.com/2022/02/23/4975.html)
- [Query Performance Comparison of TDengine and InfluxDB](https://tdengine.com/2022/02/24/5120.html)
-- [TDengine vs InfluxDB、OpenTSDB、Cassandra、MySQL、ClickHouse](https://www.tdengine.com/downloads/TDengine_Testing_Report_en.pdf)
- [TDengine vs OpenTSDB](https://tdengine.com/2019/09/12/710.html)
- [TDengine vs Cassandra](https://tdengine.com/2019/09/12/708.html)
- [TDengine vs InfluxDB](https://tdengine.com/2019/09/12/706.html)
diff --git a/docs/en/04-concept/index.md b/docs/en/04-concept/index.md
index 850f705146c4829db579f14be1a686ef9052f678..b0a0c25d85e99244858a461317ff54359d1ceff8 100644
--- a/docs/en/04-concept/index.md
+++ b/docs/en/04-concept/index.md
@@ -2,7 +2,7 @@
title: Concepts
---
-In order to explain the basic concepts and provide some sample code, the TDengine documentation smart meters as a typical time series use case. We assume the following: 1. Each smart meter collects three metrics i.e. current, voltage, and phase 2. There are multiple smart meters, and 3. Each meter has static attributes like location and group ID. Based on this, collected data will look similar to the following table:
+In order to explain the basic concepts and provide some sample code, the TDengine documentation smart meters as a typical time series use case. We assume the following: 1. Each smart meter collects three metrics i.e. current, voltage, and phase; 2. There are multiple smart meters; 3. Each meter has static attributes like location and group ID. Based on this, collected data will look similar to the following table:
@@ -104,19 +104,19 @@ Each row contains the device ID, time stamp, collected metrics (current, voltage
## Metric
-Metric refers to the physical quantity collected by sensors, equipment or other types of data collection devices, such as current, voltage, temperature, pressure, GPS position, etc., which change with time, and the data type can be integer, float, Boolean, or strings. As time goes by, the amount of collected metric data stored increases.
+Metric refers to the physical quantity collected by sensors, equipment or other types of data collection devices, such as current, voltage, temperature, pressure, GPS position, etc., which change with time, and the data type can be integer, float, Boolean, or strings. As time goes by, the amount of collected metric data stored increases. In the smart meters example, current, voltage and phase are the metrics.
## Label/Tag
-Label/Tag refers to the static properties of sensors, equipment or other types of data collection devices, which do not change with time, such as device model, color, fixed location of the device, etc. The data type can be any type. Although static, TDengine allows users to add, delete or update tag values at any time. Unlike the collected metric data, the amount of tag data stored does not change over time.
+Label/Tag refers to the static properties of sensors, equipment or other types of data collection devices, which do not change with time, such as device model, color, fixed location of the device, etc. The data type can be any type. Although static, TDengine allows users to add, delete or update tag values at any time. Unlike the collected metric data, the amount of tag data stored does not change over time. In the meters example, `location` and `groupid` are the tags.
## Data Collection Point
-Data Collection Point (DCP) refers to hardware or software that collects metrics based on preset time periods or triggered by events. A data collection point can collect one or multiple metrics, but these metrics are collected at the same time and have the same time stamp. For some complex equipment, there are often multiple data collection points, and the sampling rate of each collection point may be different, and fully independent. For example, for a car, there could be a data collection point to collect GPS position metrics, a data collection point to collect engine status metrics, and a data collection point to collect the environment metrics inside the car. So in this example the car would have three data collection points.
+Data Collection Point (DCP) refers to hardware or software that collects metrics based on preset time periods or triggered by events. A data collection point can collect one or multiple metrics, but these metrics are collected at the same time and have the same time stamp. For some complex equipment, there are often multiple data collection points, and the sampling rate of each collection point may be different, and fully independent. For example, for a car, there could be a data collection point to collect GPS position metrics, a data collection point to collect engine status metrics, and a data collection point to collect the environment metrics inside the car. So in this example the car would have three data collection points. In the smart meters example, d1001, d1002, d1003, and d1004 are the data collection points.
## Table
-Since time-series data is most likely to be structured data, TDengine adopts the traditional relational database model to process them with a short learning curve. You need to create a database, create tables, then insert data points and execute queries to explore the data.
+Since time-series data is most likely to be structured data, TDengine adopts the traditional relational database model to process them with a short learning curve. You need to create a database, create tables, then insert data points and execute queries to explore the data.
To make full use of time-series data characteristics, TDengine adopts a strategy of "**One Table for One Data Collection Point**". TDengine requires the user to create a table for each data collection point (DCP) to store collected time-series data. For example, if there are over 10 million smart meters, it means 10 million tables should be created. For the table above, 4 tables should be created for devices D1001, D1002, D1003, and D1004 to store the data collected. This design has several benefits:
@@ -125,25 +125,28 @@ To make full use of time-series data characteristics, TDengine adopts a strategy
3. The metric data from a DCP is continuously stored, block by block. If you read data for a period of time, it can greatly reduce random read operations and improve read and query performance by orders of magnitude.
4. Inside a data block for a DCP, columnar storage is used, and different compression algorithms are used for different data types. Metrics generally don't vary as significantly between themselves over a time range as compared to other metrics, which allows for a higher compression rate.
-If the metric data of multiple DCPs are traditionally written into a single table, due to uncontrollable network delays, the timing of the data from different DCPs arriving at the server cannot be guaranteed, write operations must be protected by locks, and metric data from one DCP cannot be guaranteed to be continuously stored together. **One table for one data collection point can ensure the best performance of insert and query of a single data collection point to the greatest possible extent.**
+If the metric data of multiple DCPs are traditionally written into a single table, due to uncontrollable network delays, the timing of the data from different DCPs arriving at the server cannot be guaranteed, write operations must be protected by locks, and metric data from one DCP cannot be guaranteed to be continuously stored together. ** One table for one data collection point can ensure the best performance of insert and query of a single data collection point to the greatest possible extent.**
TDengine suggests using DCP ID as the table name (like D1001 in the above table). Each DCP may collect one or multiple metrics (like the current, voltage, phase as above). Each metric has a corresponding column in the table. The data type for a column can be int, float, string and others. In addition, the first column in the table must be a timestamp. TDengine uses the time stamp as the index, and won’t build the index on any metrics stored. Column wise storage is used.
+Complex devices, such as connected cars, may have multiple DCPs. In this case, multiple tables are created for a single device, one table per DCP.
+
## Super Table (STable)
The design of one table for one data collection point will require a huge number of tables, which is difficult to manage. Furthermore, applications often need to take aggregation operations among DCPs, thus aggregation operations will become complicated. To support aggregation over multiple tables efficiently, the STable(Super Table) concept is introduced by TDengine.
STable is a template for a type of data collection point. A STable contains a set of data collection points (tables) that have the same schema or data structure, but with different static attributes (tags). To describe a STable, in addition to defining the table structure of the metrics, it is also necessary to define the schema of its tags. The data type of tags can be int, float, string, and there can be multiple tags, which can be added, deleted, or modified afterward. If the whole system has N different types of data collection points, N STables need to be established.
-In the design of TDengine, **a table is used to represent a specific data collection point, and STable is used to represent a set of data collection points of the same type**.
+In the design of TDengine, **a table is used to represent a specific data collection point, and STable is used to represent a set of data collection points of the same type**. In the smart meters example, we can create a super table named `meters`.
## Subtable
-When creating a table for a specific data collection point, the user can use a STable as a template and specify the tag values of this specific DCP to create it. **The table created by using a STable as the template is called subtable** in TDengine. The difference between regular table and subtable is:
+When creating a table for a specific data collection point, the user can use a STable as a template and specify the tag values of this specific DCP to create it. ** The table created by using a STable as the template is called subtable** in TDengine. The difference between regular table and subtable is:
+
1. Subtable is a table, all SQL commands applied on a regular table can be applied on subtable.
2. Subtable is a table with extensions, it has static tags (labels), and these tags can be added, deleted, and updated after it is created. But a regular table does not have tags.
3. A subtable belongs to only one STable, but a STable may have many subtables. Regular tables do not belong to a STable.
-4. A regular table can not be converted into a subtable, and vice versa.
+4. A regular table can not be converted into a subtable, and vice versa.
The relationship between a STable and the subtables created based on this STable is as follows:
@@ -151,13 +154,15 @@ The relationship between a STable and the subtables created based on this STable
2. The schema of metrics or labels cannot be adjusted through subtables, and it can only be changed via STable. Changes to the schema of a STable takes effect immediately for all associated subtables.
3. STable defines only one template and does not store any data or label information by itself. Therefore, data cannot be written to a STable, only to subtables.
-Queries can be executed on both a table (subtable) and a STable. For a query on a STable, TDengine will treat the data in all its subtables as a whole data set for processing. TDengine will first find the subtables that meet the tag filter conditions, then scan the time-series data of these subtables to perform aggregation operation, which reduces the number of data sets to be scanned which in turn greatly improves the performance of data aggregation across multiple DCPs.
+Queries can be executed on both a table (subtable) and a STable. For a query on a STable, TDengine will treat the data in all its subtables as a whole data set for processing. TDengine will first find the subtables that meet the tag filter conditions, then scan the time-series data of these subtables to perform aggregation operation, which reduces the number of data sets to be scanned which in turn greatly improves the performance of data aggregation across multiple DCPs. In essence, querying a supertable is a very efficient aggregate query on multiple DCPs of the same type.
+
+In TDengine, it is recommended to use a subtable instead of a regular table for a DCP. In the smart meters example, we can create subtables like d1001, d1002, d1003, and d1004 under super table meters.
-In TDengine, it is recommended to use a subtable instead of a regular table for a DCP.
+To better understand the data model using metri, tags, super table and subtable, please refer to the diagram below which demonstrates the data model of the smart meters example. 
## Database
-A database is a collection of tables. TDengine allows a running instance to have multiple databases, and each database can be configured with different storage policies. Different types of DCPs often have different data characteristics, including the frequency of data collection, data retention time, the number of replications, the size of data blocks, whether data is allowed to be updated, and so on. In order for TDengine to work with maximum efficiency in various scenarios, TDengine recommends that STables with different data characteristics be created in different databases.
+A database is a collection of tables. TDengine allows a running instance to have multiple databases, and each database can be configured with different storage policies. The [characteristics of time-series data](https://tdengine.com/tsdb/characteristics-of-time-series-data/) from different data collection points may be different. Characteristics include collection frequency, retention policy and others which determine how you create and configure the database. For e.g. days to keep, number of replicas, data block size, whether data updates are allowed and other configurable parameters would be determined by the characteristics of your data and your business requirements. In order for TDengine to work with maximum efficiency in various scenarios, TDengine recommends that STables with different data characteristics be created in different databases.
In a database, there can be one or more STables, but a STable belongs to only one database. All tables owned by a STable are stored in only one database.
@@ -167,4 +172,4 @@ FQDN (Fully Qualified Domain Name) is the full domain name of a specific compute
Each node of a TDengine cluster is uniquely identified by an End Point, which consists of an FQDN and a Port, such as h1.tdengine.com:6030. In this way, when the IP changes, we can still use the FQDN to dynamically find the node without changing any configuration of the cluster. In addition, FQDN is used to facilitate unified access to the same cluster from the Intranet and the Internet.
-TDengine does not recommend using an IP address to access the cluster. FQDN is recommended for cluster management.
+TDengine does not recommend using an IP address to access the cluster. FQDN is recommended for cluster management.
diff --git a/docs/en/04-concept/supertable.webp b/docs/en/04-concept/supertable.webp
new file mode 100644
index 0000000000000000000000000000000000000000..764b8f3de7ee92a103b2fcd0e75c03773af5ee37
Binary files /dev/null and b/docs/en/04-concept/supertable.webp differ
diff --git a/docs/en/05-get-started/01-docker.md b/docs/en/05-get-started/01-docker.md
index 14f5a8800072971a2ffa8550c838212d7b6a9907..de5b620a779557a8a3b8422a14caf67b354d1e7a 100644
--- a/docs/en/05-get-started/01-docker.md
+++ b/docs/en/05-get-started/01-docker.md
@@ -1,103 +1,99 @@
---
sidebar_label: Docker
-title: 通过 Docker 快速体验 TDengine
+title: Quick Install on Docker
---
-:::info
-如果您希望对 TDengine 贡献代码或对内部实现感兴趣,请参考我们的 [TDengine GitHub 主页](https://github.com/taosdata/TDengine) 下载源码构建和安装.
-:::
-本节首先介绍如何通过 Docker 快速体验 TDengine,然后介绍如何在 Docker 环境下体验 TDengine 的写入和查询功能。
+This document describes how to install TDengine in a Docker container and perform queries and inserts. To get started with TDengine in a non-containerized environment, see [Quick Install](../../get-started/package). If you want to view the source code, build TDengine yourself, or contribute to the project, see the [TDengine GitHub repository](https://github.com/taosdata/TDengine).
-## 启动 TDengine
+## Run TDengine
-如果已经安装了 docker, 只需执行下面的命令。
+If Docker is already installed on your computer, run the following command:
```shell
-docker run -d -p 6030:6030 -p 6041/6041 -p 6043-6049/6043-6049 -p 6043-6049:6043-6049/udp tdengine/tdengine
+docker run -d -p 6030:6030 -p 6041:6041 -p 6043-6049:6043-6049 -p 6043-6049:6043-6049/udp tdengine/tdengine
```
-注意:TDengine 3.0 服务端仅使用 6030 TCP 端口。6041 为 taosAdapter 所使用提供 REST 服务端口。6043-6049 为 taosAdapter 提供第三方应用接入所使用端口,可根据需要选择是否打开。
+Note that TDengine Server uses TCP port 6030. Port 6041 is used by taosAdapter for the REST API service. Ports 6043 through 6049 are used by taosAdapter for other connectors. You can open these ports as needed.
-确定该容器已经启动并且在正常运行
+Run the following command to ensure that your container is running:
```shell
docker ps
```
-进入该容器并执行 bash
+Enter the container and open the bash shell:
```shell
docker exec -it bash
```
-然后就可以执行相关的 Linux 命令操作和访问 TDengine
+You can now access TDengine or run other Linux commands.
-## 运行 TDengine CLI
+Note: For information about installing docker, see the [official documentation](https://docs.docker.com/get-docker/).
-进入容器,执行 taos
+## Insert Data into TDengine
-```
-$ taos
-Welcome to the TDengine shell from Linux, Client Version:3.0.0.0
-Copyright (c) 2022 by TAOS Data, Inc. All rights reserved.
+You can use the `taosBenchmark` tool included with TDengine to write test data into your deployment.
-Server is Community Edition.
+To do so, run the following command:
-taos>
+ ```bash
+ $ taosBenchmark
+
+ ```
-```
+This command creates the `meters` supertable in the `test` database. In the `meters` supertable, it then creates 10,000 subtables named `d0` to `d9999`. Each table has 10,000 rows and each row has four columns: `ts`, `current`, `voltage`, and `phase`. The timestamps of the data in these columns range from 2017-07-14 10:40:00 000 to 2017-07-14 10:40:09 999. Each table is randomly assigned a `groupId` tag from 1 to 10 and a `location` tag of either `Campbell`, `Cupertino`, `Los Angeles`, `Mountain View`, `Palo Alto`, `San Diego`, `San Francisco`, `San Jose`, `Santa Clara` or `Sunnyvale`.
-## 写入数据
+ The `taosBenchmark` command creates a deployment with 100 million data points that you can use for testing purposes. The time required depends on the hardware specifications of the local system.
-可以使用 TDengine 的自带工具 taosBenchmark 快速体验 TDengine 的写入。
+ You can customize the test deployment that taosBenchmark creates by specifying command-line parameters. For information about command-line parameters, run the `taosBenchmark --help` command. For more information about taosBenchmark, see [taosBenchmark](/reference/taosbenchmark).
-进入容器,启动 taosBenchmark:
+## Open the TDengine CLI
- ```bash
- $ taosBenchmark
-
- ```
+On the container, run the following command to open the TDengine CLI:
- 该命令将在数据库 test 下面自动创建一张超级表 meters,该超级表下有 1 万张表,表名为 "d0" 到 "d9999",每张表有 1 万条记录,每条记录有 (ts, current, voltage, phase) 四个字段,时间戳从 "2017-07-14 10:40:00 000" 到 "2017-07-14 10:40:09 999",每张表带有标签 location 和 groupId,groupId 被设置为 1 到 10, location 被设置为 "San Francisco" 或者 "Los Angeles"等城市名称。
+```
+$ taos
- 这条命令很快完成 1 亿条记录的插入。具体时间取决于硬件性能。
+taos>
- taosBenchmark 命令本身带有很多选项,配置表的数目、记录条数等等,您可以设置不同参数进行体验,请执行 `taosBenchmark --help` 详细列出。taosBenchmark 详细使用方法请参照 [taosBenchmark 参考手册](../../reference/taosbenchmark)。
+```
-## 体验查询
+## Query Data in TDengine
-使用上述 taosBenchmark 插入数据后,可以在 TDengine CLI 输入查询命令,体验查询速度。。
+After using taosBenchmark to create your test deployment, you can run queries in the TDengine CLI to test its performance. For example:
-查询超级表下记录总条数:
+From the TDengine CLI query the number of rows in the `meters` supertable:
```sql
-taos> select count(*) from test.meters;
+select count(*) from test.meters;
```
-查询 1 亿条记录的平均值、最大值、最小值等:
+Query the average, maximum, and minimum values of all 100 million rows of data:
```sql
-taos> select avg(current), max(voltage), min(phase) from test.meters;
+select avg(current), max(voltage), min(phase) from test.meters;
```
-查询 location="San Francisco" 的记录总条数:
+Query the number of rows whose `location` tag is `San Francisco`:
```sql
-taos> select count(*) from test.meters where location="San Francisco";
+select count(*) from test.meters where location="San Francisco";
```
-查询 groupId=10 的所有记录的平均值、最大值、最小值等:
+Query the average, maximum, and minimum values of all rows whose `groupId` tag is `10`:
```sql
-taos> select avg(current), max(voltage), min(phase) from test.meters where groupId=10;
+select avg(current), max(voltage), min(phase) from test.meters where groupId=10;
```
-对表 d10 按 10s 进行平均值、最大值和最小值聚合统计:
+Query the average, maximum, and minimum values for table `d10` in 1 second intervals:
```sql
-taos> select avg(current), max(voltage), min(phase) from test.d10 interval(10s);
+select first(ts), avg(current), max(voltage), min(phase) from test.d10 interval(1s);
```
+In the query above you are selecting the first timestamp (ts) in the interval, another way of selecting this would be _wstart which will give the start of the time window. For more information about windowed queries, see [Time-Series Extensions](../../taos-sql/distinguished/).
-## 其它
+## Additional Information
-更多关于在 Docker 环境下使用 TDengine 的细节,请参考 [在 Docker 下使用 TDengine](../../reference/docker)
+For more information about deploying TDengine in a Docker environment, see [Using TDengine in Docker](../../reference/docker).
diff --git a/docs/en/05-get-started/03-package.md b/docs/en/05-get-started/03-package.md
index 6423cc710523a0be95e95ba9e50556e332659dfd..88096a759c58529d4150c0a750a4354a88da988f 100644
--- a/docs/en/05-get-started/03-package.md
+++ b/docs/en/05-get-started/03-package.md
@@ -1,160 +1,208 @@
---
-sidebar_label: 安装包
-title: 使用安装包立即开始
+sidebar_label: Package
+title: Quick Install from Package
---
import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";
+import PkgListV3 from "/components/PkgListV3";
-:::info
-如果您希望对 TDengine 贡献代码或对内部实现感兴趣,请参考我们的 [TDengine GitHub 主页](https://github.com/taosdata/TDengine) 下载源码构建和安装.
+For information about installing TDengine on Docker, see [Quick Install on Docker](../../get-started/docker). If you want to view the source code, build TDengine yourself, or contribute to the project, see the [TDengine GitHub repository](https://github.com/taosdata/TDengine).
-:::
+The full package of TDengine includes the TDengine Server (`taosd`), TDengine Client (`taosc`), taosAdapter for connecting with third-party systems and providing a RESTful interface, a command-line interface, and some tools. Note that taosAdapter supports Linux only. In addition to connectors for multiple languages, TDengine also provides a [REST API](../../reference/rest-api) through [taosAdapter](../../reference/taosadapter).
+
+The standard server installation package includes `taos`, `taosd`, `taosAdapter`, `taosBenchmark`, and sample code. You can also download a lite package that includes only `taosd` and the C/C++ connector.
-TDengine 开源版本提供 deb 和 rpm 格式安装包,用户可以根据自己的运行环境选择合适的安装包。其中 deb 支持 Debian/Ubuntu 及衍生系统,rpm 支持 CentOS/RHEL/SUSE 及衍生系统。同时我们也为企业用户提供 tar.gz 格式安装包,也支持通过 `apt-get` 工具从线上进行安装。
+The TDengine Community Edition is released as .deb and .rpm packages. The .deb package can be installed on Debian, Ubuntu, and derivative systems. The .rpm package can be installed on CentOS, RHEL, SUSE, and derivative systems. A .tar.gz package is also provided for enterprise customers, and you can install TDengine over `apt-get` as well. The .tar.tz package includes `taosdump` and the TDinsight installation script. If you want to use these utilities with the .deb or .rpm package, download and install taosTools separately. TDengine can also be installed on 64-bit Windows servers.
-## 安装
+## Installation
-
-可以使用 apt-get 工具从官方仓库安装。
+
-**安装包仓库**
+1. Download the .deb installation package.
+
+2. In the directory where the package is located, use `dpkg` to install the package:
```bash
-wget -qO - http://repos.taosdata.com/tdengine.key | sudo apt-key add -
-echo "deb [arch=amd64] http://repos.taosdata.com/tdengine-stable stable main" | sudo tee /etc/apt/sources.list.d/tdengine-stable.list
+# Enter the name of the package that you downloaded.
+sudo dpkg -i TDengine-server--Linux-x64.deb
```
-如果安装 Beta 版需要安装包仓库
+
-```bash
-echo "deb [arch=amd64] http://repos.taosdata.com/tdengine-beta beta main" | sudo tee /etc/apt/sources.list.d/tdengine-beta.list
-```
+
-**使用 apt-get 命令安装**
+1. Download the .rpm installation package.
+
+2. In the directory where the package is located, use rpm to install the package:
```bash
-sudo apt-get update
-apt-cache policy tdengine
-sudo apt-get install tdengine
+# Enter the name of the package that you downloaded.
+sudo rpm -ivh TDengine-server--Linux-x64.rpm
```
-:::tip
-apt-get 方式只适用于 Debian 或 Ubuntu 系统
-::::
-
-1、从官网下载获得 deb 安装包,例如 TDengine-server-3.0.0.0-Linux-x64.deb;
-2、进入到 TDengine-server-3.0.0.0-Linux-x64.deb 安装包所在目录,执行如下的安装命令:
+
+
+1. Download the .tar.gz installation package.
+
+2. In the directory where the package is located, use `tar` to decompress the package:
```bash
-sudo dpkg -i TDengine-server-3.0.0.0-Linux-x64.deb
+# Enter the name of the package that you downloaded.
+tar -zxvf TDengine-server--Linux-x64.tar.gz
```
-
-
-
-
-1、从官网下载获得 rpm 安装包,例如 TDengine-server-3.0.0.0-Linux-x64.rpm;
-2、进入到 TDengine-server-3.0.0.0-Linux-x64.rpm 安装包所在目录,执行如下的安装命令:
+In the directory to which the package was decompressed, run `install.sh`:
```bash
-sudo rpm -ivh TDengine-server-3.0.0.0-Linux-x64.rpm
+sudo ./install.sh
```
+:::info
+Users will be prompted to enter some configuration information when install.sh is executing. The interactive mode can be disabled by executing `./install.sh -e no`. `./install.sh -h` can show all parameters with detailed explanation.
+:::
+
-
+
+You can use `apt-get` to install TDengine from the official package repository.
-1、从官网下载获得 tar.gz 安装包,例如 TDengine-server-3.0.0.0-Linux-x64.tar.gz;
-2、进入到 TDengine-server-3.0.0.0-Linux-x64.tar.gz 安装包所在目录,先解压文件后,进入子目录,执行其中的 install.sh 安装脚本:
+**Configure the package repository**
```bash
-tar -zxvf TDengine-server-3.0.0.0-Linux-x64.tar.gz
+wget -qO - http://repos.taosdata.com/tdengine.key | sudo apt-key add -
+echo "deb [arch=amd64] http://repos.taosdata.com/tdengine-stable stable main" | sudo tee /etc/apt/sources.list.d/tdengine-stable.list
```
-解压后进入相应路径,执行
+You can install beta versions by configuring the following repository:
```bash
-sudo ./install.sh
+wget -qO - http://repos.taosdata.com/tdengine.key | sudo apt-key add -
+echo "deb [arch=amd64] http://repos.taosdata.com/tdengine-beta beta main" | sudo tee /etc/apt/sources.list.d/tdengine-beta.list
```
-:::info
-install.sh 安装脚本在执行过程中,会通过命令行交互界面询问一些配置信息。如果希望采取无交互安装方式,那么可以用 -e no 参数来执行 install.sh 脚本。运行 `./install.sh -h` 指令可以查看所有参数的详细说明信息。
+**Install TDengine with `apt-get`**
-:::
+```bash
+sudo apt-get update
+apt-cache policy tdengine
+sudo apt-get install tdengine
+```
+
+:::tip
+This installation method is supported only for Debian and Ubuntu.
+::::
+
+
+
+Note: TDengine only supports Windows Server 2016/2019 and windows 10/11 system versions on the windows platform.
+
+1. Download the Windows installation package.
+
+2. Run the downloaded package to install TDengine.
+:::info
+For information about TDengine releases, see [Release History](../../releases).
+:::
+
:::note
-当安装第一个节点时,出现 Enter FQDN:提示的时候,不需要输入任何内容。只有当安装第二个或以后更多的节点时,才需要输入已有集群中任何一个可用节点的 FQDN,支持该新节点加入集群。当然也可以不输入,而是在新节点启动前,配置到新节点的配置文件中。
+On the first node in your TDengine cluster, leave the `Enter FQDN:` prompt blank and press **Enter**. On subsequent nodes, you can enter the end point of the first dnode in the cluster. You can also configure this setting after you have finished installing TDengine.
:::
-## 启动
+## Quick Launch
+
+
+
-安装后,请使用 `systemctl` 命令来启动 TDengine 的服务进程。
+After the installation is complete, run the following command to start the TDengine service:
```bash
systemctl start taosd
```
-检查服务是否正常工作:
+Run the following command to confirm that TDengine is running normally:
```bash
systemctl status taosd
```
-如果服务进程处于活动状态,则 status 指令会显示如下的相关信息:
+Output similar to the following indicates that TDengine is running normally:
```
Active: active (running)
```
-如果后台服务进程处于停止状态,则 status 指令会显示如下的相关信息:
+Output similar to the following indicates that TDengine has not started successfully:
```
Active: inactive (dead)
```
-如果 TDengine 服务正常工作,那么您可以通过 TDengine 的命令行程序 `taos` 来访问并体验 TDengine。
+After confirming that TDengine is running, run the `taos` command to access the TDengine CLI.
-systemctl 命令汇总:
+The following `systemctl` commands can help you manage TDengine:
-- 启动服务进程:`systemctl start taosd`
+- Start TDengine Server: `systemctl start taosd`
-- 停止服务进程:`systemctl stop taosd`
+- Stop TDengine Server: `systemctl stop taosd`
-- 重启服务进程:`systemctl restart taosd`
+- Restart TDengine Server: `systemctl restart taosd`
-- 查看服务状态:`systemctl status taosd`
+- Check TDengine Server status: `systemctl status taosd`
:::info
-- systemctl 命令需要 _root_ 权限来运行,如果您非 _root_ 用户,请在命令前添加 sudo 。
-- `systemctl stop taosd` 指令在执行后并不会马上停止 TDengine 服务,而是会等待系统中必要的落盘工作正常完成。在数据量很大的情况下,这可能会消耗较长时间。
-- 如果系统中不支持 `systemd`,也可以用手动运行 `/usr/local/taos/bin/taosd` 方式启动 TDengine 服务。
+- The `systemctl` command requires _root_ privileges. If you are not logged in as the `root` user, use the `sudo` command.
+- The `systemctl stop taosd` command does not instantly stop TDengine Server. The server is stopped only after all data in memory is flushed to disk. The time required depends on the cache size.
+- If your system does not include `systemd`, you can run `/usr/local/taos/bin/taosd` to start TDengine manually.
:::
-## TDengine 命令行 (CLI)
+
+
+
+
+After the installation is complete, run `C:\TDengine\taosd.exe` to start TDengine Server.
+
+
+
+
+## Test data insert performance
+
+After your TDengine Server is running normally, you can run the taosBenchmark utility to test its performance:
-为便于检查 TDengine 的状态,执行数据库 (Database) 的各种即席(Ad Hoc)查询,TDengine 提供一命令行应用程序(以下简称为 TDengine CLI) taos。要进入 TDengine 命令行,您只要在安装有 TDengine 的 Linux 终端执行 `taos` 即可。
+```bash
+taosBenchmark
+```
+
+This command creates the `meters` supertable in the `test` database. In the `meters` supertable, it then creates 10,000 subtables named `d0` to `d9999`. Each table has 10,000 rows and each row has four columns: `ts`, `current`, `voltage`, and `phase`. The timestamps of the data in these columns range from 2017-07-14 10:40:00 000 to 2017-07-14 10:40:09 999. Each table is randomly assigned a `groupId` tag from 1 to 10 and a `location` tag of either `Campbell`, `Cupertino`, `Los Angeles`, `Mountain View`, `Palo Alto`, `San Diego`, `San Francisco`, `San Jose`, `Santa Clara` or `Sunnyvale`.
+
+The `taosBenchmark` command creates a deployment with 100 million data points that you can use for testing purposes. The time required to create the deployment depends on your hardware. On most modern servers, the deployment is created in less than a minute.
+
+You can customize the test deployment that taosBenchmark creates by specifying command-line parameters. For information about command-line parameters, run the `taosBenchmark --help` command. For more information about taosBenchmark, see [taosBenchmark](../../reference/taosbenchmark).
+
+## Command Line Interface
+
+You can use the TDengine CLI to monitor your TDengine deployment and execute ad hoc queries. To open the CLI, run the following command:
```bash
taos
```
-如果连接服务成功,将会打印出欢迎消息和版本信息。如果失败,则会打印错误消息出来(请参考 [FAQ](/train-faq/faq) 来解决终端连接服务端失败的问题)。 TDengine CLI 的提示符号如下:
+The TDengine CLI displays a welcome message and version information to indicate that its connection to the TDengine service was successful. If an error message is displayed, see the [FAQ](/train-faq/faq) for troubleshooting information. At the following prompt, you can execute SQL commands.
```cmd
taos>
```
-在 TDengine CLI 中,用户可以通过 SQL 命令来创建/删除数据库、表等,并进行数据库(database)插入查询操作。在终端中运行的 SQL 语句需要以分号结束来运行。示例:
+For example, you can create and delete databases and tables and run all types of queries. Each SQL command must be end with a semicolon (;). For example:
```sql
create database demo;
@@ -170,52 +218,39 @@ select * from t;
Query OK, 2 row(s) in set (0.003128s)
```
-除执行 SQL 语句外,系统管理员还可以从 TDengine CLI 进行检查系统运行状态、添加删除用户账号等操作。TDengine CLI 连同应用驱动也可以独立安装在 Linux 或 Windows 机器上运行,更多细节请参考 [这里](../../reference/taos-shell/)
-
-## 使用 taosBenchmark 体验写入速度
-
-启动 TDengine 的服务,在 Linux 终端执行 `taosBenchmark` (曾命名为 `taosdemo`):
-
-```bash
-taosBenchmark
-```
-
-该命令将在数据库 test 下面自动创建一张超级表 meters,该超级表下有 1 万张表,表名为 "d0" 到 "d9999",每张表有 1 万条记录,每条记录有 (ts, current, voltage, phase) 四个字段,时间戳从 "2017-07-14 10:40:00 000" 到 "2017-07-14 10:40:09 999",每张表带有标签 location 和 groupId,groupId 被设置为 1 到 10, location 被设置为 "California.SanFrancisco" 或者 "California.LosAngeles"。
-
-这条命令很快完成 1 亿条记录的插入。具体时间取决于硬件性能,即使在一台普通的 PC 服务器往往也仅需十几秒。
-
-taosBenchmark 命令本身带有很多选项,配置表的数目、记录条数等等,您可以设置不同参数进行体验,请执行 `taosBenchmark --help` 详细列出。taosBenchmark 详细使用方法请参照 [如何使用 taosBenchmark 对 TDengine 进行性能测试](https://www.taosdata.com/2021/10/09/3111.html)。
-
-## 使用 TDengine CLI 体验查询速度
+You can also can monitor the deployment status, add and remove user accounts, and manage running instances. You can run the TDengine CLI on either Linux or Windows machines. For more information, see [TDengine CLI](../../reference/taos-shell/).
+
+## Test data query performance
-使用上述 taosBenchmark 插入数据后,可以在 TDengine CLI 输入查询命令,体验查询速度。
+After using taosBenchmark to create your test deployment, you can run queries in the TDengine CLI to test its performance:
-查询超级表下记录总条数:
+From the TDengine CLI query the number of rows in the `meters` supertable:
```sql
-taos> select count(*) from test.meters;
+select count(*) from test.meters;
```
-查询 1 亿条记录的平均值、最大值、最小值等:
+Query the average, maximum, and minimum values of all 100 million rows of data:
```sql
-taos> select avg(current), max(voltage), min(phase) from test.meters;
+select avg(current), max(voltage), min(phase) from test.meters;
```
-查询 location="California.SanFrancisco" 的记录总条数:
+Query the number of rows whose `location` tag is `San Francisco`:
```sql
-taos> select count(*) from test.meters where location="California.SanFrancisco";
+select count(*) from test.meters where location="San Francisco";
```
-查询 groupId=10 的所有记录的平均值、最大值、最小值等:
+Query the average, maximum, and minimum values of all rows whose `groupId` tag is `10`:
```sql
-taos> select avg(current), max(voltage), min(phase) from test.meters where groupId=10;
+select avg(current), max(voltage), min(phase) from test.meters where groupId=10;
```
-对表 d10 按 10s 进行平均值、最大值和最小值聚合统计:
+Query the average, maximum, and minimum values for table `d10` in 1 second intervals:
```sql
-taos> select avg(current), max(voltage), min(phase) from test.d10 interval(10s);
+select first(ts), avg(current), max(voltage), min(phase) from test.d10 interval(1s);
```
+In the query above you are selecting the first timestamp (ts) in the interval, another way of selecting this would be _wstart which will give the start of the time window. For more information about windowed queries, see [Time-Series Extensions](../../taos-sql/distinguished/).
diff --git a/docs/en/05-get-started/_apt_get_install.mdx b/docs/en/05-get-started/_apt_get_install.mdx
index b1bc4a13517bbfdc9eda86a58b89aee8e41fa470..acbcf22122152f970891ca92c20b9b1b7d97fe1a 100644
--- a/docs/en/05-get-started/_apt_get_install.mdx
+++ b/docs/en/05-get-started/_apt_get_install.mdx
@@ -1,19 +1,19 @@
-可以使用 apt-get 工具从官方仓库安装。
+You can use `apt-get` to install TDengine from the official package repository.
-**安装包仓库**
+**Configure the package repository**
```
wget -qO - http://repos.taosdata.com/tdengine.key | sudo apt-key add -
echo "deb [arch=amd64] http://repos.taosdata.com/tdengine-stable stable main" | sudo tee /etc/apt/sources.list.d/tdengine-stable.list
```
-如果安装 Beta 版需要安装包仓库
+You can install beta versions by configuring the following package repository:
```
echo "deb [arch=amd64] http://repos.taosdata.com/tdengine-beta beta main" | sudo tee /etc/apt/sources.list.d/tdengine-beta.list
```
-**使用 apt-get 命令安装**
+**Install TDengine with `apt-get`**
```
sudo apt-get update
@@ -22,5 +22,5 @@ sudo apt-get install tdengine
```
:::tip
-apt-get 方式只适用于 Debian 或 Ubuntu 系统
+This installation method is supported only for Debian and Ubuntu.
::::
diff --git a/docs/en/05-get-started/_category_.yml b/docs/en/05-get-started/_category_.yml
index b2348fade63c7bb717eac3e6e6b8dfda3c73b17a..043ae21554ffd8f274c6afe41c5ae5e7da742b26 100644
--- a/docs/en/05-get-started/_category_.yml
+++ b/docs/en/05-get-started/_category_.yml
@@ -1 +1 @@
-label: 立即开始
+label: Get Started
diff --git a/docs/en/05-get-started/_pkg_install.mdx b/docs/en/05-get-started/_pkg_install.mdx
index 83c987af8bcf24a9593105b680d32a0421344d5f..32d7c1f376bc6404c45db39fbaa24a5012a11f01 100644
--- a/docs/en/05-get-started/_pkg_install.mdx
+++ b/docs/en/05-get-started/_pkg_install.mdx
@@ -1,17 +1,17 @@
import PkgList from "/components/PkgList";
-TDengine 的安装非常简单,从下载到安装成功仅仅只要几秒钟。
+TDengine is easy to download and install.
-为方便使用,从 2.4.0.10 开始,标准的服务端安装包包含了 taos、taosd、taosAdapter、taosdump、taosBenchmark、TDinsight 安装脚本和示例代码;如果您只需要用到服务端程序和客户端连接的 C/C++ 语言支持,也可以仅下载 lite 版本的安装包。
+The standard server installation package includes `taos`, `taosd`, `taosAdapter`, `taosBenchmark`, and sample code. You can also download a lite package that includes only `taosd` and the C/C++ connector.
-在安装包格式上,我们提供 tar.gz, rpm 和 deb 格式,为企业客户提供 tar.gz 格式安装包,以方便在特定操作系统上使用。需要注意的是,rpm 和 deb 包不含 taosdump、taosBenchmark 和 TDinsight 安装脚本,这些工具需要通过安装 taosTool 包获得。
+You can download the TDengine installation package in .rpm, .deb, or .tar.gz format. The .tar.tz package includes `taosdump` and the TDinsight installation script. If you want to use these utilities with the .deb or .rpm package, download and install taosTools separately.
-发布版本包括稳定版和 Beta 版,Beta 版含有更多新功能。正式上线或测试建议安装稳定版。您可以根据需要选择下载:
+Between official releases, beta versions may be released that contain new features. Do not use beta versions for production or testing environments. Select the installation package appropriate for your system.
-具体的安装方法,请参见[安装包的安装和卸载](/operation/pkg-install)。
+For information about installing TDengine, see [Install and Uninstall](/operation/pkg-install).
-下载其他组件、最新 Beta 版及之前版本的安装包,请点击[这里](https://www.taosdata.com/all-downloads)
+For information about TDengine releases, see [All Downloads](https://tdengine.com/all-downloads)
-查看 Release Notes, 请点击[这里](https://github.com/taosdata/TDengine/releases)
+and [Release Notes](https://github.com/taosdata/TDengine/releases).
diff --git a/docs/en/05-get-started/index.md b/docs/en/05-get-started/index.md
index 794081b4e4c438dee2d8cbe125de4094056f190f..cf475a8cd79e15880a4356a89f46c0dd6a8c307d 100644
--- a/docs/en/05-get-started/index.md
+++ b/docs/en/05-get-started/index.md
@@ -1,11 +1,11 @@
---
-title: 立即开始
-description: '快速设置 TDengine 环境并体验其高效写入和查询'
+title: Get Started
+description: This article describes how to install TDengine and test its performance.
---
-TDengine 完整的软件包包括服务端(taosd)、用于与第三方系统对接并提供 RESTful 接口的 taosAdapter、应用驱动(taosc)、命令行程序 (CLI,taos) 和一些工具软件。TDengine 除了提供多种语言的连接器之外,还通过 [taosAdapter](/reference/taosadapter) 提供 [RESTful 接口](/reference/rest-api)。
+The full package of TDengine includes the TDengine Server (`taosd`), TDengine Client (`taosc`), taosAdapter for connecting with third-party systems and providing a RESTful interface, a command-line interface, and some tools. In addition to connectors for multiple languages, TDengine also provides a [RESTful interface](/reference/rest-api) through [taosAdapter](/reference/taosadapter).
-本章主要介绍如何利用 Docker 或者安装包快速设置 TDengine 环境并体验其高效写入和查询。
+You can install and run TDengine on Linux and Windows machines as well as Docker containers.
```mdx-code-block
import DocCardList from '@theme/DocCardList';
diff --git a/docs/en/07-develop/01-connect/_connect_php.mdx b/docs/en/07-develop/01-connect/_connect_php.mdx
new file mode 100644
index 0000000000000000000000000000000000000000..dbad72bc1988bd5336f1da132dd9e6ba9b8020e6
--- /dev/null
+++ b/docs/en/07-develop/01-connect/_connect_php.mdx
@@ -0,0 +1,3 @@
+```php title="原生连接"
+{{#include docs/examples/php/connect.php}}
+```
diff --git a/docs/en/07-develop/01-connect/index.md b/docs/en/07-develop/01-connect/index.md
index 1318f4619ba5ff1da23990f881a15f3726401760..901fe69d24640e1cfab5ed4cbc3875ac240e493b 100644
--- a/docs/en/07-develop/01-connect/index.md
+++ b/docs/en/07-develop/01-connect/index.md
@@ -1,38 +1,39 @@
---
-sidebar_label: Connect
title: Connect
-description: "This document explains how to establish connections to TDengine, and briefly introduces how to install and use TDengine connectors."
+description: "This document explains how to establish connections to TDengine and how to install and use TDengine connectors."
---
import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";
-import ConnJava from "./\_connect_java.mdx";
-import ConnGo from "./\_connect_go.mdx";
-import ConnRust from "./\_connect_rust.mdx";
-import ConnNode from "./\_connect_node.mdx";
-import ConnPythonNative from "./\_connect_python.mdx";
-import ConnCSNative from "./\_connect_cs.mdx";
-import ConnC from "./\_connect_c.mdx";
-import ConnR from "./\_connect_r.mdx";
-import InstallOnWindows from "../../14-reference/03-connector/\_linux_install.mdx";
-import InstallOnLinux from "../../14-reference/03-connector/\_windows_install.mdx";
-import VerifyLinux from "../../14-reference/03-connector/\_verify_linux.mdx";
-import VerifyWindows from "../../14-reference/03-connector/\_verify_windows.mdx";
-
-Any application programs running on any kind of platform can access TDengine through the REST API provided by TDengine. For details, please refer to [REST API](/reference/rest-api/). Additionally, application programs can use the connectors of multiple programming languages including C/C++, Java, Python, Go, Node.js, C#, Rust to access TDengine. This chapter describes how to establish a connection to TDengine and briefly introduces how to install and use connectors. TDengine community also provides connectors in LUA and PHP languages. For details about the connectors, please refer to [Connectors](/reference/connector/).
+import ConnJava from "./_connect_java.mdx";
+import ConnGo from "./_connect_go.mdx";
+import ConnRust from "./_connect_rust.mdx";
+import ConnNode from "./_connect_node.mdx";
+import ConnPythonNative from "./_connect_python.mdx";
+import ConnCSNative from "./_connect_cs.mdx";
+import ConnC from "./_connect_c.mdx";
+import ConnR from "./_connect_r.mdx";
+import ConnPHP from "./_connect_php.mdx";
+import InstallOnWindows from "../../14-reference/03-connector/_linux_install.mdx";
+import InstallOnLinux from "../../14-reference/03-connector/_windows_install.mdx";
+import VerifyLinux from "../../14-reference/03-connector/_verify_linux.mdx";
+import VerifyWindows from "../../14-reference/03-connector/_verify_windows.mdx";
+
+Any application running on any platform can access TDengine through the REST API provided by TDengine. For information, see [REST API](/reference/rest-api/). Applications can also use the connectors for various programming languages, including C/C++, Java, Python, Go, Node.js, C#, and Rust, to access TDengine. These connectors support connecting to TDengine clusters using both native interfaces (taosc). Some connectors also support connecting over a REST interface. Community developers have also contributed several unofficial connectors, such as the ADO.NET connector, the Lua connector, and the PHP connector.
## Establish Connection
There are two ways for a connector to establish connections to TDengine:
-1. Connection through the REST API provided by the taosAdapter component, this way is called "REST connection" hereinafter.
-2. Connection through the TDengine client driver (taosc), this way is called "Native connection" hereinafter.
+1. REST connection through the REST API provided by the taosAdapter component.
+2. Native connection through the TDengine client driver (taosc).
+
+For REST and native connections, connectors provide similar APIs for performing operations and running SQL statements on your databases. The main difference is the method of establishing the connection, which is not visible to users.
Key differences:
-1. The TDengine client driver (taosc) has the highest performance with all the features of TDengine like [Parameter Binding](/reference/connector/cpp#parameter-binding-api), [Subscription](/reference/connector/cpp#subscription-and-consumption-api), etc.
-2. The TDengine client driver (taosc) is not supported across all platforms, and applications built on taosc may need to be modified when updating taosc to newer versions.
3. The REST connection is more accessible with cross-platform support, however it results in a 30% performance downgrade.
+1. The TDengine client driver (taosc) has the highest performance with all the features of TDengine like [Parameter Binding](/reference/connector/cpp#parameter-binding-api), [Subscription](/reference/connector/cpp#subscription-and-consumption-api), etc.
## Install Client Driver taosc
@@ -136,19 +137,19 @@ Node.js connector provides different ways of establishing connections by providi
1. Install Node.js Native Connector
-```
-npm install @tdengine/client
-```
+ ```
+ npm install @tdengine/client
+ ```
:::note
It's recommend to use Node whose version is between `node-v12.8.0` and `node-v13.0.0`.
-:::
-
+:::
+
2. Install Node.js REST Connector
-```
-npm install @tdengine/rest
-```
+ ```
+ npm install @tdengine/rest
+ ```
@@ -222,7 +223,7 @@ phpize && ./configure && make -j && make install
**Specify TDengine Location:**
```shell
-phpize && ./configure --with-tdengine-dir=/usr/local/Cellar/tdengine/2.4.0.0 && make -j && make install
+phpize && ./configure --with-tdengine-dir=/usr/local/Cellar/tdengine/3.0.0.0 && make -j && make install
```
> `--with-tdengine-dir=` is followed by the TDengine installation location.
@@ -236,14 +237,14 @@ phpize && ./configure --enable-swoole && make -j && make install
**Enable The Extension:**
-Option One: Add `extension=tdengine` in `php.ini`
+Option One: Add `extension=tdengine` in `php.ini`
Option Two: Specify the extension on CLI `php -d extension=tdengine test.php`
-## Establish Connection
+## Establish a connection
Prior to establishing connection, please make sure TDengine is already running and accessible. The following sample code assumes TDengine is running on the same host as the client program, with FQDN configured to "localhost" and serverPort configured to "6030".
@@ -272,9 +273,12 @@ Prior to establishing connection, please make sure TDengine is already running a
+
+
+
:::tip
-If the connection fails, in most cases it's caused by improper configuration for FQDN or firewall. Please refer to the section "Unable to establish connection" in [FAQ](https://docs.taosdata.com/train-faq/faq).
+If the connection fails, in most cases it's caused by improper configuration for FQDN or firewall. Please refer to the section "Unable to establish connection" in [FAQ](https://docs.tdengine.com/train-faq/faq).
:::
diff --git a/docs/en/07-develop/02-model/index.mdx b/docs/en/07-develop/02-model/index.mdx
index b647c845d070c26398956f8a9de81864b73120e1..3c16ed2df15940f3f59232a37b6f559010305a96 100644
--- a/docs/en/07-develop/02-model/index.mdx
+++ b/docs/en/07-develop/02-model/index.mdx
@@ -2,31 +2,36 @@
title: Data Model
---
-The data model employed by TDengine is similar to that of a relational database. You have to create databases and tables. You must design the data model based on your own business and application requirements. You should design the STable (an abbreviation for super table) schema to fit your data. This chapter will explain the big picture without getting into syntactical details.
+The data model employed by TDengine is similar to that of a relational database. You have to create databases and tables. You must design the data model based on your own business and application requirements. You should design the [STable](/concept/#super-table-stable) (an abbreviation for super table) schema to fit your data. This chapter will explain the big picture without getting into syntactical details.
+
+Note: before you read this chapter, please make sure you have already read through [Key Concepts](/concept/), since TDengine introduces new concepts like "one table for one [data collection point](/concept/#data-collection-point)" and "[super table](/concept/#super-table-stable)".
+
+
## Create Database
-The [characteristics of time-series data](https://www.taosdata.com/blog/2019/07/09/86.html) from different data collection points may be different. Characteristics include collection frequency, retention policy and others which determine how you create and configure the database. For e.g. days to keep, number of replicas, data block size, whether data updates are allowed and other configurable parameters would be determined by the characteristics of your data and your business requirements. For TDengine to operate with the best performance, we strongly recommend that you create and configure different databases for data with different characteristics. This allows you, for example, to set up different storage and retention policies. When creating a database, there are a lot of parameters that can be configured such as, the days to keep data, the number of replicas, the number of memory blocks, time precision, the minimum and maximum number of rows in each data block, whether compression is enabled, the time range of the data in single data file and so on. Below is an example of the SQL statement to create a database.
+The characteristics of time-series data from different data collection points may be different. Characteristics include collection frequency, retention policy and others which determine how you create and configure the database. For e.g. days to keep, number of replicas, data block size, whether data updates are allowed and other configurable parameters would be determined by the characteristics of your data and your business requirements. For TDengine to operate with the best performance, we strongly recommend that you create and configure different databases for data with different characteristics. This allows you, for example, to set up different storage and retention policies. When creating a database, there are a lot of parameters that can be configured such as, the days to keep data, the number of replicas, the size of the cache, time precision, the minimum and maximum number of rows in each data block, whether compression is enabled, the time range of the data in single data file and so on. An example is shown as follows:
```sql
-CREATE DATABASE power KEEP 365 DURATION 10 BUFFER 16 VGROUPS 100 WAL 1;
+CREATE DATABASE power KEEP 365 DURATION 10 BUFFER 16 WAL_LEVEL 1;
```
In the above SQL statement:
-- a database named "power" will be created
-- the data in it will be kept for 365 days, which means that data older than 365 days will be deleted automatically
+- a database named "power" is created
+- the data in it is retained for 365 days, which means that data older than 365 days will be deleted automatically
- a new data file will be created every 10 days
-- the size of memory cache for writing is 16 MB
-- data will be firstly written to WAL without FSYNC
-
-For more details please refer to [Database](/taos-sql/database).
+- the size of the write cache pool on each vnode is 16 MB
+- the number of vgroups is 100
+- WAL is enabled but fsync is disabled For more details please refer to [Database](/taos-sql/database).
-After creating a database, the current database in use can be switched using SQL command `USE`. For example the SQL statement below switches the current database to `power`. Without the current database specified, table name must be preceded with the corresponding database name.
+After creating a database, the current database in use can be switched using SQL command `USE`. For example the SQL statement below switches the current database to `power`.
```sql
USE power;
```
+Without the current database specified, table name must be preceded with the corresponding database name.
+
:::note
- Any table or STable must belong to a database. To create a table or STable, the database it belongs to must be ready.
@@ -39,14 +44,9 @@ USE power;
In a time-series application, there may be multiple kinds of data collection points. For example, in the electrical power system there are meters, transformers, bus bars, switches, etc. For easy and efficient aggregation of multiple tables, one STable needs to be created for each kind of data collection point. For example, for the meters in [table 1](/concept/#model_table1), the SQL statement below can be used to create the super table.
```sql
-CREATE STable meters (ts timestamp, current float, voltage int, phase float) TAGS (location binary(64), groupId int);
+CREATE STABLE meters (ts timestamp, current float, voltage int, phase float) TAGS (location binary(64), groupId int);
```
-:::note
-If you are using versions prior to 2.0.15, the `STable` keyword needs to be replaced with `TABLE`.
-
-:::
-
Similar to creating a regular table, when creating a STable, the name and schema need to be provided. In the STable schema, the first column must always be a timestamp (like ts in the example), and the other columns (like current, voltage and phase in the example) are the data collected. The remaining columns can [contain data of type](/taos-sql/data-type/) integer, float, double, string etc. In addition, the schema for tags, like location and groupId in the example, must be provided. The tag type can be integer, float, string, etc. Tags are essentially the static properties of a data collection point. For example, properties like the location, device type, device group ID, manager ID are tags. Tags in the schema can be added, removed or updated. Please refer to [STable](/taos-sql/stable) for more details.
For each kind of data collection point, a corresponding STable must be created. There may be many STables in an application. For electrical power system, we need to create a STable respectively for meters, transformers, busbars, switches. There may be multiple kinds of data collection points on a single device, for example there may be one data collection point for electrical data like current and voltage and another data collection point for environmental data like temperature, humidity and wind direction. Multiple STables are required for these kinds of devices.
@@ -63,13 +63,8 @@ CREATE TABLE d1001 USING meters TAGS ("California.SanFrancisco", 2);
In the above SQL statement, "d1001" is the table name, "meters" is the STable name, followed by the value of tag "Location" and the value of tag "groupId", which are "California.SanFrancisco" and "2" respectively in the example. The tag values can be updated after the table is created. Please refer to [Tables](/taos-sql/table) for details.
-In the TDengine system, it's recommended to create a table for a data collection point via STable. A table created via STable is called subtable in some parts of the TDengine documentation. All SQL commands applied on regular tables can be applied on subtables.
-
-:::tip
It's suggested to use the globally unique ID of a data collection point as the table name. For example the device serial number could be used as a unique ID. If a unique ID doesn't exist, multiple IDs that are not globally unique can be combined to form a globally unique ID. It's not recommended to use a globally unique ID as tag value.
-:::
-
## Create Table Automatically
In some circumstances, it's unknown whether the table already exists when inserting rows. The table can be created automatically using the SQL statement below, and nothing will happen if the table already exists.
@@ -84,8 +79,6 @@ For more details please refer to [Create Table Automatically](/taos-sql/insert#a
## Single Column vs Multiple Column
-A multiple columns data model is supported in TDengine. As long as multiple metrics are collected by the same data collection point at the same time, i.e. the timestamps are identical, these metrics can be put in a single STable as columns.
-
-However, there is another kind of design, i.e. single column data model in which a table is created for each metric. This means that a STable is required for each kind of metric. For example in a single column model, 3 STables would be required for current, voltage and phase.
+A multiple columns data model is supported in TDengine. As long as multiple metrics are collected by the same data collection point at the same time, i.e. the timestamps are identical, these metrics can be put in a single STable as columns. However, there is another kind of design, i.e. single column data model in which a table is created for each metric. This means that a STable is required for each kind of metric. For example in a single column model, 3 STables would be required for current, voltage and phase.
It's recommended to use a multiple column data model as much as possible because insert and query performance is higher. In some cases, however, the collected metrics may vary frequently and so the corresponding STable schema needs to be changed frequently too. In such cases, it's more convenient to use single column data model.
diff --git a/docs/en/07-develop/03-insert-data/01-sql-writing.mdx b/docs/en/07-develop/03-insert-data/01-sql-writing.mdx
index da0e87abbc2c83ca940dd596ffbf5746a6b65823..f2168645ff9e59d60e88c85f86e890945b9f336c 100644
--- a/docs/en/07-develop/03-insert-data/01-sql-writing.mdx
+++ b/docs/en/07-develop/03-insert-data/01-sql-writing.mdx
@@ -1,5 +1,4 @@
---
-sidebar_label: Insert Using SQL
title: Insert Using SQL
---
@@ -19,13 +18,14 @@ import CsSQL from "./_cs_sql.mdx";
import CsStmt from "./_cs_stmt.mdx";
import CSQL from "./_c_sql.mdx";
import CStmt from "./_c_stmt.mdx";
+import PhpSQL from "./_php_sql.mdx";
+import PhpStmt from "./_php_stmt.mdx";
## Introduction
Application programs can execute `INSERT` statement through connectors to insert rows. The TDengine CLI can also be used to manually insert data.
### Insert Single Row
-
The below SQL statement is used to insert one row into table "d1001".
```sql
@@ -42,7 +42,7 @@ INSERT INTO d1001 VALUES (1538548684000, 10.2, 220, 0.23) (1538548696650, 10.3,
### Insert into Multiple Tables
-Data can be inserted into multiple tables in single SQL statement. The example below inserts 2 rows into table "d1001" and 1 row into table "d1002".
+Data can be inserted into multiple tables in the same SQL statement. The example below inserts 2 rows into table "d1001" and 1 row into table "d1002".
```sql
INSERT INTO d1001 VALUES (1538548685000, 10.3, 219, 0.31) (1538548695000, 12.6, 218, 0.33) d1002 VALUES (1538548696800, 12.3, 221, 0.31);
@@ -52,19 +52,19 @@ For more details about `INSERT` please refer to [INSERT](/taos-sql/insert).
:::info
-- Inserting in batches can improve performance. Normally, the higher the batch size, the better the performance. Please note that a single row can't exceed 48 KB bytes and each SQL statement can't exceed 1 MB.
-- Inserting with multiple threads can also improve performance. However, depending on the system resources on the application side and the server side, when the number of inserting threads grows beyond a specific point the performance may drop instead of improving. The proper number of threads needs to be tested in a specific environment to find the best number. The proper number of threads may be impacted by the system resources on the server side, the system resources on the client side, the table schemas, etc.
+- Inserting in batches can improve performance. The higher the batch size, the better the performance. Please note that a single row can't exceed 48K bytes and each SQL statement can't exceed 1MB.
+- Inserting with multiple threads can also improve performance. However, at a certain point, increasing the number of threads no longer offers any benefit and can even decrease performance due to the overhead involved in frequent thread switching. The optimal number of threads for a system depends on the processing capabilities and configuration of the server, the configuration of the database, the data schema, and the batch size for writing data. In general, more powerful clients and servers can support higher numbers of concurrently writing threads. Given a sufficiently powerful server, a higher number of vgroups for a database also increases the number of concurrent writes. Finally, a simpler data schema enables more concurrent writes as well.
:::
:::warning
-- If the timestamp for the row to be inserted already exists in the table, the old data will be overritten by the new values for the columns for which new values are provided, columns for which no new values are provided are not impacted.
-- The timestamp to be inserted must be newer than the timestamp of subtracting current time by the parameter `KEEP`. If `KEEP` is set to 3650 days, then the data older than 3650 days ago can't be inserted. The timestamp to be inserted can't be newer than the timestamp of current time plus parameter `DURATION`. If `DAYS` is set to 2, the data newer than 2 days later can't be inserted.
+- If the timestamp of a new record already exists in a table, columns with new data for that timestamp replace old data with new data, while columns without new data are not affected.
+- The timestamp to be inserted must be newer than the timestamp of subtracting current time by the parameter `KEEP`. If `KEEP` is set to 3650 days, then the data older than 3650 days ago can't be inserted. The timestamp to be inserted cannot be newer than the timestamp of current time plus parameter `DURATION`. If `DURATION` is set to 2, the data newer than 2 days later can't be inserted.
:::
-## Examples
+## Sample program
### Insert Using SQL
@@ -90,6 +90,9 @@ For more details about `INSERT` please refer to [INSERT](/taos-sql/insert).
+
+
+
:::note
@@ -101,7 +104,7 @@ For more details about `INSERT` please refer to [INSERT](/taos-sql/insert).
### Insert with Parameter Binding
-TDengine also provides API support for parameter binding. Similar to MySQL, only `?` can be used in these APIs to represent the parameters to bind. Parameter binding support for inserting data has improved significantly to improve the insert performance by avoiding the cost of parsing SQL statements.
+TDengine also provides API support for parameter binding. Similar to MySQL, only `?` can be used in these APIs to represent the parameters to bind. This avoids the resource consumption of SQL syntax parsing when writing data through the parameter binding interface, thus significantly improving write performance in most cases.
Parameter binding is available only with native connection.
@@ -127,4 +130,8 @@ Parameter binding is available only with native connection.
+
+
+
+
diff --git a/docs/en/07-develop/03-insert-data/02-influxdb-line.mdx b/docs/en/07-develop/03-insert-data/02-influxdb-line.mdx
index 41109937053c31f0a141fcc90016397863152e57..11db3daeb054b2cac29c6a0ccde2add27774f3da 100644
--- a/docs/en/07-develop/03-insert-data/02-influxdb-line.mdx
+++ b/docs/en/07-develop/03-insert-data/02-influxdb-line.mdx
@@ -21,15 +21,15 @@ In the InfluxDB Line protocol format, a single line of text is used to represent
measurement,tag_set field_set timestamp
```
-- `measurement` will be used as the name of the STable
-- `tag_set` will be used as tags, with format like `=,=`
-- `field_set`will be used as data columns, with format like `=,=`
+- `measurement` will be used as the name of the STable Enter a comma (,) between `measurement` and `tag_set`.
+- `tag_set` will be used as tags, with format like `=,=` Enter a space between `tag_set` and `field_set`.
+- `field_set`will be used as data columns, with format like `=,=` Enter a space between `field_set` and `timestamp`.
- `timestamp` is the primary key timestamp corresponding to this row of data
For example:
```
-meters,location=California.LoSangeles,groupid=2 current=13.4,voltage=223,phase=0.29 1648432611249500
+meters,location=California.LosAngeles,groupid=2 current=13.4,voltage=223,phase=0.29 1648432611249500
```
:::note
@@ -42,7 +42,6 @@ meters,location=California.LoSangeles,groupid=2 current=13.4,voltage=223,phase=0
For more details please refer to [InfluxDB Line Protocol](https://docs.influxdata.com/influxdb/v2.0/reference/syntax/line-protocol/) and [TDengine Schemaless](/reference/schemaless/#Schemaless-Line-Protocol)
-
## Examples
diff --git a/docs/en/07-develop/03-insert-data/03-opentsdb-telnet.mdx b/docs/en/07-develop/03-insert-data/03-opentsdb-telnet.mdx
index 81e1169489d4188e14f4c5338ca322041bba80fb..db9bfd73649709cf806ae6499513191db8321107 100644
--- a/docs/en/07-develop/03-insert-data/03-opentsdb-telnet.mdx
+++ b/docs/en/07-develop/03-insert-data/03-opentsdb-telnet.mdx
@@ -17,19 +17,19 @@ import CTelnet from "./_c_opts_telnet.mdx";
A single line of text is used in OpenTSDB line protocol to represent one row of data. OpenTSDB employs a single column data model, so each line can only contain a single data column. There can be multiple tags. Each line contains 4 parts as below:
-```
+```txt
=[ =]
```
- `metric` will be used as the STable name.
- `timestamp` is the timestamp of current row of data. The time precision will be determined automatically based on the length of the timestamp. Second and millisecond time precision are supported.
-- `value` is a metric which must be a numeric value, the corresponding column name is "_value".
+- `value` is a metric which must be a numeric value, The corresponding column name is "value".
- The last part is the tag set separated by spaces, all tags will be converted to nchar type automatically.
For example:
```txt
-meters.current 1648432611250 11.3 location=California.LoSangeles groupid=3
+meters.current 1648432611250 11.3 location=California.LosAngeles groupid=3
```
Please refer to [OpenTSDB Telnet API](http://opentsdb.net/docs/build/html/api_telnet/put.html) for more details.
@@ -63,7 +63,7 @@ Please refer to [OpenTSDB Telnet API](http://opentsdb.net/docs/build/html/api_te
taos> use test;
Database changed.
-taos> show STables;
+taos> show stables;
name | created_time | columns | tags | tables |
============================================================================================
meters.current | 2022-03-30 17:04:10.877 | 2 | 2 | 2 |
@@ -73,8 +73,8 @@ Query OK, 2 row(s) in set (0.002544s)
taos> select tbname, * from `meters.current`;
tbname | _ts | _value | groupid | location |
==================================================================================================================================
- t_0e7bcfa21a02331c06764f275... | 2022-03-28 09:56:51.249 | 10.800000000 | 3 | California.LoSangeles |
- t_0e7bcfa21a02331c06764f275... | 2022-03-28 09:56:51.250 | 11.300000000 | 3 | California.LoSangeles |
+ t_0e7bcfa21a02331c06764f275... | 2022-03-28 09:56:51.249 | 10.800000000 | 3 | California.LosAngeles |
+ t_0e7bcfa21a02331c06764f275... | 2022-03-28 09:56:51.250 | 11.300000000 | 3 | California.LosAngeles |
t_7e7b26dd860280242c6492a16... | 2022-03-28 09:56:51.249 | 10.300000000 | 2 | California.SanFrancisco |
t_7e7b26dd860280242c6492a16... | 2022-03-28 09:56:51.250 | 12.600000000 | 2 | California.SanFrancisco |
Query OK, 4 row(s) in set (0.005399s)
diff --git a/docs/en/07-develop/03-insert-data/04-opentsdb-json.mdx b/docs/en/07-develop/03-insert-data/04-opentsdb-json.mdx
index aad94c3d913a128b344757162c231affc6a64651..23703f4087483373a15e9cf7604bb67ca62888f5 100644
--- a/docs/en/07-develop/03-insert-data/04-opentsdb-json.mdx
+++ b/docs/en/07-develop/03-insert-data/04-opentsdb-json.mdx
@@ -15,37 +15,37 @@ import CJson from "./_c_opts_json.mdx";
## Introduction
-A JSON string is used in OpenTSDB JSON to represent one or more rows of data, for example:
+A JSON string is used in OpenTSDB JSON to represent one or more rows of data, for example: For example:
```json
[
- {
- "metric": "sys.cpu.nice",
- "timestamp": 1346846400,
- "value": 18,
- "tags": {
- "host": "web01",
- "dc": "lga"
- }
- },
- {
- "metric": "sys.cpu.nice",
- "timestamp": 1346846400,
- "value": 9,
- "tags": {
- "host": "web02",
- "dc": "lga"
- }
+ {
+ "metric": "sys.cpu.nice",
+ "timestamp": 1346846400,
+ "value": 18,
+ "tags": {
+ "host": "web01",
+ "dc": "lga"
}
+ },
+ {
+ "metric": "sys.cpu.nice",
+ "timestamp": 1346846400,
+ "value": 9,
+ "tags": {
+ "host": "web02",
+ "dc": "lga"
+ }
+ }
]
```
Similar to OpenTSDB line protocol, `metric` will be used as the STable name, `timestamp` is the timestamp to be used, `value` represents the metric collected, `tags` are the tag sets.
-
Please refer to [OpenTSDB HTTP API](http://opentsdb.net/docs/build/html/api_http/put.html) for more details.
:::note
+
- In JSON protocol, strings will be converted to nchar type and numeric values will be converted to double type.
- Only data in array format is accepted and so an array must be used even if there is only one row.
@@ -74,13 +74,13 @@ Please refer to [OpenTSDB HTTP API](http://opentsdb.net/docs/build/html/api_http
-The above sample code will created 2 STables automatically while each STable has 2 rows of data.
+2 STables will be created automatically and each STable has 2 rows of data in the above sample code.
```cmd
taos> use test;
Database changed.
-taos> show STables;
+taos> show stables;
name | created_time | columns | tags | tables |
============================================================================================
meters.current | 2022-03-29 16:05:25.193 | 2 | 2 | 1 |
diff --git a/docs/en/07-develop/03-insert-data/05-high-volume.md b/docs/en/07-develop/03-insert-data/05-high-volume.md
new file mode 100644
index 0000000000000000000000000000000000000000..9ea0c884473e670d0624cb3be737830f46bedc38
--- /dev/null
+++ b/docs/en/07-develop/03-insert-data/05-high-volume.md
@@ -0,0 +1,441 @@
+---
+sidebar_label: High Performance Writing
+title: High Performance Writing
+---
+
+import Tabs from "@theme/Tabs";
+import TabItem from "@theme/TabItem";
+
+This chapter introduces how to write data into TDengine with high throughput.
+
+## How to achieve high performance data writing
+
+To achieve high performance writing, there are a few aspects to consider. In the following sections we will describe these important factors in achieving high performance writing.
+
+### Application Program
+
+From the perspective of application program, you need to consider:
+
+1. The data size of each single write, also known as batch size. Generally speaking, higher batch size generates better writing performance. However, once the batch size is over a specific value, you will not get any additional benefit anymore. When using SQL to write into TDengine, it's better to put as much as possible data in single SQL. The maximum SQL length supported by TDengine is 1,048,576 bytes, i.e. 1 MB.
+
+2. The number of concurrent connections. Normally more connections can get better result. However, once the number of connections exceeds the processing ability of the server side, the performance may downgrade.
+
+3. The distribution of data to be written across tables or sub-tables. Writing to single table in one batch is more efficient than writing to multiple tables in one batch.
+
+4. Data Writing Protocol.
+ - Prameter binding mode is more efficient than SQL because it doesn't have the cost of parsing SQL.
+ - Writing to known existing tables is more efficient than wirting to uncertain tables in automatic creating mode because the later needs to check whether the table exists or not before actually writing data into it
+ - Writing in SQL is more efficient than writing in schemaless mode because schemaless writing creats table automatically and may alter table schema
+
+Application programs need to take care of the above factors and try to take advantage of them. The application progam should write to single table in each write batch. The batch size needs to be tuned to a proper value on a specific system. The number of concurrent connections needs to be tuned to a proper value too to achieve the best writing throughput.
+
+### Data Source
+
+Application programs need to read data from data source then write into TDengine. If you meet one or more of below situations, you need to setup message queues between the threads for reading from data source and the threads for writing into TDengine.
+
+1. There are multiple data sources, the data generation speed of each data source is much slower than the speed of single writing thread. In this case, the purpose of message queues is to consolidate the data from multiple data sources together to increase the batch size of single write.
+2. The speed of data generation from single data source is much higher than the speed of single writing thread. The purpose of message queue in this case is to provide buffer so that data is not lost and multiple writing threads can get data from the buffer.
+3. The data for single table are from multiple data source. In this case the purpose of message queues is to combine the data for single table together to improve the write efficiency.
+
+If the data source is Kafka, then the appication program is a consumer of Kafka, you can benefit from some kafka features to achieve high performance writing:
+
+1. Put the data for a table in single partition of single topic so that it's easier to put the data for each table together and write in batch
+2. Subscribe multiple topics to accumulate data together.
+3. Add more consumers to gain more concurrency and throughput.
+4. Incrase the size of single fetch to increase the size of write batch.
+
+### Tune TDengine
+
+On the server side, database configuration parameter `vgroups` needs to be set carefully to maximize the system performance. If it's set too low, the system capability can't be utilized fully; if it's set too big, unnecessary resource competition may be produced. A normal recommendation for `vgroups` parameter is 2 times of the number of CPU cores. However, depending on the actual system resources, it may still need to tuned.
+
+For more configuration parameters, please refer to [Database Configuration](../../../taos-sql/database) and [Server Configuration](../../../reference/config)。
+
+## Sample Programs
+
+This section will introduce the sample programs to demonstrate how to write into TDengine with high performance.
+
+### Scenario
+
+Below are the scenario for the sample programs of high performance wrting.
+
+- Application program reads data from data source, the sample program simulates a data source by generating data
+- The speed of single writing thread is much slower than the speed of generating data, so the program starts multiple writing threads while each thread establish a connection to TDengine and each thread has a message queue of fixed size.
+- Application program maps the received data to different writing threads based on table name to make sure all the data for each table is always processed by a specific writing thread.
+- Each writing thread writes the received data into TDengine once the message queue becomes empty or the read data meets a threshold.
+
+
+
+### Sample Programs
+
+The sample programs listed in this section are based on the scenario described previously. If your scenarios is different, please try to adjust the code based on the principles described in this chapter.
+
+The sample programs assume the source data is for all the different sub tables in same super table (meters). The super table has been created before the sample program starts to writing data. Sub tables are created automatically according to received data. If there are multiple super tables in your case, please try to adjust the part of creating table automatically.
+
+
+
+
+**Program Inventory**
+
+| Class | Description |
+| ---------------- | ----------------------------------------------------------------------------------------------------- |
+| FastWriteExample | Main Program |
+| ReadTask | Read data from simulated data source and put into a queue according to the hash value of table name |
+| WriteTask | Read data from Queue, compose a wirte batch and write into TDengine |
+| MockDataSource | Generate data for some sub tables of super table meters |
+| SQLWriter | WriteTask uses this class to compose SQL, create table automatically, check SQL length and write data |
+| StmtWriter | Write in Parameter binding mode (Not finished yet) |
+| DataBaseMonitor | Calculate the writing speed and output on console every 10 seconds |
+
+Below is the list of complete code of the classes in above table and more detailed description.
+
+
+FastWriteExample
+The main Program is responsible for:
+
+1. Create message queues
+2. Start writing threads
+3. Start reading threads
+4. Otuput writing speed every 10 seconds
+
+The main program provides 4 parameters for tuning:
+
+1. The number of reading threads, default value is 1
+2. The number of writing threads, default alue is 2
+3. The total number of tables in the generated data, default value is 1000. These tables are distributed evenly across all writing threads. If the number of tables is very big, it will cost much time to firstly create these tables.
+4. The batch size of single write, default value is 3,000
+
+The capacity of message queue also impacts performance and can be tuned by modifying program. Normally it's always better to have a larger message queue. A larger message queue means lower possibility of being blocked when enqueueing and higher throughput. But a larger message queue consumes more memory space. The default value used in the sample programs is already big enoug.
+
+```java
+{{#include docs/examples/java/src/main/java/com/taos/example/highvolume/FastWriteExample.java}}
+```
+
+
+
+
+ReadTask
+
+ReadTask reads data from data source. Each ReadTask is associated with a simulated data source, each data source generates data for a group of specific tables, and the data of any table is only generated from a single specific data source.
+
+ReadTask puts data in message queue in blocking mode. That means, the putting operation is blocked if the message queue is full.
+
+```java
+{{#include docs/examples/java/src/main/java/com/taos/example/highvolume/ReadTask.java}}
+```
+
+
+
+
+WriteTask
+
+```java
+{{#include docs/examples/java/src/main/java/com/taos/example/highvolume/WriteTask.java}}
+```
+
+
+
+
+
+MockDataSource
+
+```java
+{{#include docs/examples/java/src/main/java/com/taos/example/highvolume/MockDataSource.java}}
+```
+
+
+
+
+
+SQLWriter
+
+SQLWriter class encapsulates the logic of composing SQL and writing data. Please be noted that the tables have not been created before writing, but are created automatically when catching the exception of table doesn't exist. For other exceptions caught, the SQL which caused the exception are logged for you to debug.
+
+```java
+{{#include docs/examples/java/src/main/java/com/taos/example/highvolume/SQLWriter.java}}
+```
+
+
+
+
+
+DataBaseMonitor
+
+```java
+{{#include docs/examples/java/src/main/java/com/taos/example/highvolume/DataBaseMonitor.java}}
+```
+
+
+
+**Steps to Launch**
+
+
+Launch Java Sample Program
+
+You need to set environment variable `TDENGINE_JDBC_URL` before launching the program. If TDengine Server is setup on localhost, then the default value for user name, password and port can be used, like below:
+
+```
+TDENGINE_JDBC_URL="jdbc:TAOS://localhost:6030?user=root&password=taosdata"
+```
+
+**Launch in IDE**
+
+1. Clone TDengine repolitory
+ ```
+ git clone git@github.com:taosdata/TDengine.git --depth 1
+ ```
+2. Use IDE to open `docs/examples/java` directory
+3. Configure environment variable `TDENGINE_JDBC_URL`, you can also configure it before launching the IDE, if so you can skip this step.
+4. Run class `com.taos.example.highvolume.FastWriteExample`
+
+**Launch on server**
+
+If you want to launch the sample program on a remote server, please follow below steps:
+
+1. Package the sample programs. Execute below command under directory `TDengine/docs/examples/java` :
+ ```
+ mvn package
+ ```
+2. Create `examples/java` directory on the server
+ ```
+ mkdir -p examples/java
+ ```
+3. Copy dependencies (below commands assume you are working on a local Windows host and try to launch on a remote Linux host)
+ - Copy dependent packages
+ ```
+ scp -r .\target\lib @:~/examples/java
+ ```
+ - Copy the jar of sample programs
+ ```
+ scp -r .\target\javaexample-1.0.jar @:~/examples/java
+ ```
+4. Configure environment variable
+ Edit `~/.bash_profile` or `~/.bashrc` and add below:
+
+ ```
+ export TDENGINE_JDBC_URL="jdbc:TAOS://localhost:6030?user=root&password=taosdata"
+ ```
+
+ If your TDengine server is not deployed on localhost or doesn't use default port, you need to change the above URL to correct value in your environment.
+
+5. Launch the sample program
+
+ ```
+ java -classpath lib/*:javaexample-1.0.jar com.taos.example.highvolume.FastWriteExample
+ ```
+
+6. The sample program doesn't exit unless you press CTRL + C to terminate it.
+ Below is the output of running on a server of 16 cores, 64GB memory and SSD hard disk.
+
+ ```
+ root@vm85$ java -classpath lib/*:javaexample-1.0.jar com.taos.example.highvolume.FastWriteExample 2 12
+ 18:56:35.896 [main] INFO c.t.e.highvolume.FastWriteExample - readTaskCount=2, writeTaskCount=12 tableCount=1000 maxBatchSize=3000
+ 18:56:36.011 [WriteThread-0] INFO c.taos.example.highvolume.WriteTask - started
+ 18:56:36.015 [WriteThread-0] INFO c.taos.example.highvolume.SQLWriter - maxSQLLength=1048576
+ 18:56:36.021 [WriteThread-1] INFO c.taos.example.highvolume.WriteTask - started
+ 18:56:36.022 [WriteThread-1] INFO c.taos.example.highvolume.SQLWriter - maxSQLLength=1048576
+ 18:56:36.031 [WriteThread-2] INFO c.taos.example.highvolume.WriteTask - started
+ 18:56:36.032 [WriteThread-2] INFO c.taos.example.highvolume.SQLWriter - maxSQLLength=1048576
+ 18:56:36.041 [WriteThread-3] INFO c.taos.example.highvolume.WriteTask - started
+ 18:56:36.042 [WriteThread-3] INFO c.taos.example.highvolume.SQLWriter - maxSQLLength=1048576
+ 18:56:36.093 [WriteThread-4] INFO c.taos.example.highvolume.WriteTask - started
+ 18:56:36.094 [WriteThread-4] INFO c.taos.example.highvolume.SQLWriter - maxSQLLength=1048576
+ 18:56:36.099 [WriteThread-5] INFO c.taos.example.highvolume.WriteTask - started
+ 18:56:36.100 [WriteThread-5] INFO c.taos.example.highvolume.SQLWriter - maxSQLLength=1048576
+ 18:56:36.100 [WriteThread-6] INFO c.taos.example.highvolume.WriteTask - started
+ 18:56:36.101 [WriteThread-6] INFO c.taos.example.highvolume.SQLWriter - maxSQLLength=1048576
+ 18:56:36.103 [WriteThread-7] INFO c.taos.example.highvolume.WriteTask - started
+ 18:56:36.104 [WriteThread-7] INFO c.taos.example.highvolume.SQLWriter - maxSQLLength=1048576
+ 18:56:36.105 [WriteThread-8] INFO c.taos.example.highvolume.WriteTask - started
+ 18:56:36.107 [WriteThread-8] INFO c.taos.example.highvolume.SQLWriter - maxSQLLength=1048576
+ 18:56:36.108 [WriteThread-9] INFO c.taos.example.highvolume.WriteTask - started
+ 18:56:36.109 [WriteThread-9] INFO c.taos.example.highvolume.SQLWriter - maxSQLLength=1048576
+ 18:56:36.156 [WriteThread-10] INFO c.taos.example.highvolume.WriteTask - started
+ 18:56:36.157 [WriteThread-11] INFO c.taos.example.highvolume.WriteTask - started
+ 18:56:36.158 [WriteThread-10] INFO c.taos.example.highvolume.SQLWriter - maxSQLLength=1048576
+ 18:56:36.158 [ReadThread-0] INFO com.taos.example.highvolume.ReadTask - started
+ 18:56:36.158 [ReadThread-1] INFO com.taos.example.highvolume.ReadTask - started
+ 18:56:36.158 [WriteThread-11] INFO c.taos.example.highvolume.SQLWriter - maxSQLLength=1048576
+ 18:56:46.369 [main] INFO c.t.e.highvolume.FastWriteExample - count=18554448 speed=1855444
+ 18:56:56.946 [main] INFO c.t.e.highvolume.FastWriteExample - count=39059660 speed=2050521
+ 18:57:07.322 [main] INFO c.t.e.highvolume.FastWriteExample - count=59403604 speed=2034394
+ 18:57:18.032 [main] INFO c.t.e.highvolume.FastWriteExample - count=80262938 speed=2085933
+ 18:57:28.432 [main] INFO c.t.e.highvolume.FastWriteExample - count=101139906 speed=2087696
+ 18:57:38.921 [main] INFO c.t.e.highvolume.FastWriteExample - count=121807202 speed=2066729
+ 18:57:49.375 [main] INFO c.t.e.highvolume.FastWriteExample - count=142952417 speed=2114521
+ 18:58:00.689 [main] INFO c.t.e.highvolume.FastWriteExample - count=163650306 speed=2069788
+ 18:58:11.646 [main] INFO c.t.e.highvolume.FastWriteExample - count=185019808 speed=2136950
+ ```
+
+
+
+
+
+
+**Program Inventory**
+
+Sample programs in Python uses multi-process and cross-process message queues.
+
+| Function/CLass | Description |
+| ---------------------------- | --------------------------------------------------------------------------- |
+| main Function | Program entry point, create child processes and message queues |
+| run_monitor_process Function | Create database, super table, calculate writing speed and output to console |
+| run_read_task Function | Read data and distribute to message queues |
+| MockDataSource Class | Simulate data source, return next 1,000 rows of each table |
+| run_write_task Function | Read as much as possible data from message queue and write in batch |
+| SQLWriter Class | Write in SQL and create table utomatically |
+| StmtWriter Class | Write in parameter binding mode (not finished yet) |
+
+
+main function
+
+`main` function is responsible for creating message queues and fork child processes, there are 3 kinds of child processes:
+
+1. Monitoring process, initializes database and calculating writing speed
+2. Reading process (n), reads data from data source
+3. Writing process (m), wirtes data into TDengine
+
+`main` function provides 5 parameters:
+
+1. The number of reading tasks, default value is 1
+2. The number of writing tasks, default value is 1
+3. The number of tables, default value is 1,000
+4. The capacity of message queue, default value is 1,000,000 bytes
+5. The batch size in single write, default value is 3000
+
+```python
+{{#include docs/examples/python/fast_write_example.py:main}}
+```
+
+
+
+
+run_monitor_process
+
+Monitoring process initilizes database and monitoring writing speed.
+
+```python
+{{#include docs/examples/python/fast_write_example.py:monitor}}
+```
+
+
+
+
+
+run_read_task function
+
+Reading process reads data from other data system and distributes to the message queue allocated for it.
+
+```python
+{{#include docs/examples/python/fast_write_example.py:read}}
+```
+
+
+
+
+
+MockDataSource
+
+Below is the simulated data source, we assume table name exists in each generated data.
+
+```python
+{{#include docs/examples/python/mockdatasource.py}}
+```
+
+
+
+
+run_write_task function
+
+Writing process tries to read as much as possible data from message queue and writes in batch.
+
+```python
+{{#include docs/examples/python/fast_write_example.py:write}}
+```
+
+
+
+
+
+SQLWriter class encapsulates the logic of composing SQL and writing data. Please be noted that the tables have not been created before writing, but are created automatically when catching the exception of table doesn't exist. For other exceptions caught, the SQL which caused the exception are logged for you to debug. This class also checks the SQL length, and passes the maximum SQL length by parameter maxSQLLength according to actual TDengine limit.
+
+SQLWriter
+
+```python
+{{#include docs/examples/python/sql_writer.py}}
+```
+
+
+
+**Steps to Launch**
+
+
+
+Launch Sample Program in Python
+
+1. Prerequisities
+
+ - TDengine client driver has been installed
+ - Python3 has been installed, the the version >= 3.8
+ - TDengine Python connector `taospy` has been installed
+
+2. Install faster-fifo to replace python builtin multiprocessing.Queue
+
+ ```
+ pip3 install faster-fifo
+ ```
+
+3. Click the "Copy" in the above sample programs to copy `fast_write_example.py` 、 `sql_writer.py` and `mockdatasource.py`.
+
+4. Execute the program
+
+ ```
+ python3 fast_write_example.py
+ ```
+
+ Below is the output of running on a server of 16 cores, 64GB memory and SSD hard disk.
+
+ ```
+ root@vm85$ python3 fast_write_example.py 8 8
+ 2022-07-14 19:13:45,869 [root] - READ_TASK_COUNT=8, WRITE_TASK_COUNT=8, TABLE_COUNT=1000, QUEUE_SIZE=1000000, MAX_BATCH_SIZE=3000
+ 2022-07-14 19:13:48,882 [root] - WriteTask-0 started with pid 718347
+ 2022-07-14 19:13:48,883 [root] - WriteTask-1 started with pid 718348
+ 2022-07-14 19:13:48,884 [root] - WriteTask-2 started with pid 718349
+ 2022-07-14 19:13:48,884 [root] - WriteTask-3 started with pid 718350
+ 2022-07-14 19:13:48,885 [root] - WriteTask-4 started with pid 718351
+ 2022-07-14 19:13:48,885 [root] - WriteTask-5 started with pid 718352
+ 2022-07-14 19:13:48,886 [root] - WriteTask-6 started with pid 718353
+ 2022-07-14 19:13:48,886 [root] - WriteTask-7 started with pid 718354
+ 2022-07-14 19:13:48,887 [root] - ReadTask-0 started with pid 718355
+ 2022-07-14 19:13:48,888 [root] - ReadTask-1 started with pid 718356
+ 2022-07-14 19:13:48,889 [root] - ReadTask-2 started with pid 718357
+ 2022-07-14 19:13:48,889 [root] - ReadTask-3 started with pid 718358
+ 2022-07-14 19:13:48,890 [root] - ReadTask-4 started with pid 718359
+ 2022-07-14 19:13:48,891 [root] - ReadTask-5 started with pid 718361
+ 2022-07-14 19:13:48,892 [root] - ReadTask-6 started with pid 718364
+ 2022-07-14 19:13:48,893 [root] - ReadTask-7 started with pid 718365
+ 2022-07-14 19:13:56,042 [DataBaseMonitor] - count=6676310 speed=667631.0
+ 2022-07-14 19:14:06,196 [DataBaseMonitor] - count=20004310 speed=1332800.0
+ 2022-07-14 19:14:16,366 [DataBaseMonitor] - count=32290310 speed=1228600.0
+ 2022-07-14 19:14:26,527 [DataBaseMonitor] - count=44438310 speed=1214800.0
+ 2022-07-14 19:14:36,673 [DataBaseMonitor] - count=56608310 speed=1217000.0
+ 2022-07-14 19:14:46,834 [DataBaseMonitor] - count=68757310 speed=1214900.0
+ 2022-07-14 19:14:57,280 [DataBaseMonitor] - count=80992310 speed=1223500.0
+ 2022-07-14 19:15:07,689 [DataBaseMonitor] - count=93805310 speed=1281300.0
+ 2022-07-14 19:15:18,020 [DataBaseMonitor] - count=106111310 speed=1230600.0
+ 2022-07-14 19:15:28,356 [DataBaseMonitor] - count=118394310 speed=1228300.0
+ 2022-07-14 19:15:38,690 [DataBaseMonitor] - count=130742310 speed=1234800.0
+ 2022-07-14 19:15:49,000 [DataBaseMonitor] - count=143051310 speed=1230900.0
+ 2022-07-14 19:15:59,323 [DataBaseMonitor] - count=155276310 speed=1222500.0
+ 2022-07-14 19:16:09,649 [DataBaseMonitor] - count=167603310 speed=1232700.0
+ 2022-07-14 19:16:19,995 [DataBaseMonitor] - count=179976310 speed=1237300.0
+ ```
+
+
+
+:::note
+Don't establish connection to TDengine in the parent process if using Python connector in multi-process way, otherwise all the connections in child processes are blocked always. This is a known issue.
+
+:::
+
+
+
diff --git a/docs/en/07-develop/03-insert-data/_go_stmt.mdx b/docs/en/07-develop/03-insert-data/_go_stmt.mdx
index ab519c9a806345c2f14337f62c74728da955d2e0..0bdcffc16fa18a1d0afcd50548ed6076f6154838 100644
--- a/docs/en/07-develop/03-insert-data/_go_stmt.mdx
+++ b/docs/en/07-develop/03-insert-data/_go_stmt.mdx
@@ -3,6 +3,6 @@
```
:::tip
-`github.com/taosdata/driver-go/v2/wrapper` module in driver-go is the wrapper for C API, it can be used to insert data with parameter binding.
+`github.com/taosdata/driver-go/v3/wrapper` module in driver-go is the wrapper for C API, it can be used to insert data with parameter binding.
:::
diff --git a/docs/en/07-develop/03-insert-data/_php_sql.mdx b/docs/en/07-develop/03-insert-data/_php_sql.mdx
new file mode 100644
index 0000000000000000000000000000000000000000..78cd663ec219dabc2eeb81c7e67426eda41d7762
--- /dev/null
+++ b/docs/en/07-develop/03-insert-data/_php_sql.mdx
@@ -0,0 +1,3 @@
+```php
+{{#include docs/examples/php/insert.php}}
+```
diff --git a/docs/en/07-develop/03-insert-data/_php_stmt.mdx b/docs/en/07-develop/03-insert-data/_php_stmt.mdx
new file mode 100644
index 0000000000000000000000000000000000000000..3bb7b2f8da9887c1063822e69bfdff599aa50b7b
--- /dev/null
+++ b/docs/en/07-develop/03-insert-data/_php_stmt.mdx
@@ -0,0 +1,3 @@
+```php
+{{#include docs/examples/php/insert_stmt.php}}
+```
diff --git a/docs/en/07-develop/03-insert-data/highvolume.webp b/docs/en/07-develop/03-insert-data/highvolume.webp
new file mode 100644
index 0000000000000000000000000000000000000000..46dfc74ae3b0043c591ff930c62251da49cae7ad
Binary files /dev/null and b/docs/en/07-develop/03-insert-data/highvolume.webp differ
diff --git a/docs/en/07-develop/04-query-data/_php.mdx b/docs/en/07-develop/04-query-data/_php.mdx
new file mode 100644
index 0000000000000000000000000000000000000000..bcafd1cfbcb1bbb55b03f6fe198e6fa1b5251b19
--- /dev/null
+++ b/docs/en/07-develop/04-query-data/_php.mdx
@@ -0,0 +1,3 @@
+```go
+{{#include docs/examples/php/query.php}}
+```
diff --git a/docs/en/07-develop/04-query-data/index.mdx b/docs/en/07-develop/04-query-data/index.mdx
index a212fa9529215fc24c55c95a166cfc1a407359b2..38dc98d1ff262c7f8ec4951297e6f42e436682c8 100644
--- a/docs/en/07-develop/04-query-data/index.mdx
+++ b/docs/en/07-develop/04-query-data/index.mdx
@@ -1,6 +1,5 @@
---
-Sidebar_label: Query data
-title: Query data
+title: Query Data
description: "This chapter introduces major query functionalities and how to perform sync and async query using connectors."
---
@@ -13,6 +12,7 @@ import RustQuery from "./_rust.mdx";
import NodeQuery from "./_js.mdx";
import CsQuery from "./_cs.mdx";
import CQuery from "./_c.mdx";
+import PhpQuery from "./_php.mdx";
import PyAsync from "./_py_async.mdx";
import NodeAsync from "./_js_async.mdx";
import CsAsync from "./_cs_async.mdx";
@@ -24,9 +24,8 @@ SQL is used by TDengine as its query language. Application programs can send SQL
- Query on single column or multiple columns
- Filter on tags or data columns:>, <, =, <\>, like
-- Grouping of results: `Group By`
-- Sorting of results: `Order By`
-- Limit the number of results: `Limit/Offset`
+- Grouping of results: `Group By` - Sorting of results: `Order By` - Limit the number of results: `Limit/Offset`
+- Windowed aggregate queries for time windows (interval), session windows (session), and state windows (state_window)
- Arithmetic on columns of numeric types or aggregate results
- Join query with timestamp alignment
- Aggregate functions: count, max, min, avg, sum, twa, stddev, leastsquares, top, bottom, first, last, percentile, apercentile, last_row, spread, diff
@@ -34,10 +33,6 @@ SQL is used by TDengine as its query language. Application programs can send SQL
For example, the SQL statement below can be executed in TDengine CLI `taos` to select records with voltage greater than 215 and limit the output to only 2 rows.
```sql
-select * from d1001 where voltage > 215 order by ts desc limit 2;
-```
-
-```title=Output
taos> select * from d1001 where voltage > 215 order by ts desc limit 2;
ts | current | voltage | phase |
======================================================================================
@@ -46,89 +41,88 @@ taos> select * from d1001 where voltage > 215 order by ts desc limit 2;
Query OK, 2 row(s) in set (0.001100s)
```
-To meet the requirements of varied use cases, some special functions have been added in TDengine. Some examples are `twa` (Time Weighted Average), `spread` (The difference between the maximum and the minimum), and `last_row` (the last row). Furthermore, continuous query is also supported in TDengine.
+To meet the requirements of varied use cases, some special functions have been added in TDengine. Some examples are `twa` (Time Weighted Average), `spread` (The difference between the maximum and the minimum), and `last_row` (the last row).
-For detailed query syntax please refer to [Select](/taos-sql/select).
+For detailed query syntax, see [Select](../../taos-sql/select).
## Aggregation among Tables
In most use cases, there are always multiple kinds of data collection points. A new concept, called STable (abbreviation for super table), is used in TDengine to represent one type of data collection point, and a subtable is used to represent a specific data collection point of that type. Tags are used by TDengine to represent the static properties of data collection points. A specific data collection point has its own values for static properties. By specifying filter conditions on tags, aggregation can be performed efficiently among all the subtables created via the same STable, i.e. same type of data collection points. Aggregate functions applicable for tables can be used directly on STables; the syntax is exactly the same.
-In summary, records across subtables can be aggregated by a simple query on their STable. It is like a join operation. However, tables belonging to different STables can not be aggregated.
-
### Example 1
In TDengine CLI `taos`, use the SQL below to get the average voltage of all the meters in California grouped by location.
```
-taos> SELECT AVG(voltage) FROM meters GROUP BY location;
- avg(voltage) | location |
-=============================================================
- 222.000000000 | California.LosAngeles |
- 219.200000000 | California.SanFrancisco |
-Query OK, 2 row(s) in set (0.002136s)
+taos> SELECT AVG(voltage), location FROM meters GROUP BY location;
+ avg(voltage) | location |
+===============================================================================================
+ 219.200000000 | California.SanFrancisco |
+ 221.666666667 | California.LosAngeles |
+Query OK, 2 rows in database (0.005995s)
```
### Example 2
-In TDengine CLI `taos`, use the SQL below to get the number of rows and the maximum current in the past 24 hours from meters whose groupId is 2.
+In TDengine CLI `taos`, use the SQL below to get the number of rows and the maximum current from meters whose groupId is 2.
```
-taos> SELECT count(*), max(current) FROM meters where groupId = 2 and ts > now - 24h;
+taos> SELECT count(*), max(current) FROM meters where groupId = 2;
count(*) | max(current) |
==================================
5 | 13.4 |
Query OK, 1 row(s) in set (0.002136s)
```
-Join queries are only allowed between subtables of the same STable. In [Select](/taos-sql/select), all query operations are marked as to whether they support STables or not.
+In [Select](../../taos-sql/select), all query operations are marked as to whether they support STables or not.
## Down Sampling and Interpolation
In IoT use cases, down sampling is widely used to aggregate data by time range. The `INTERVAL` keyword in TDengine can be used to simplify the query by time window. For example, the SQL statement below can be used to get the sum of current every 10 seconds from meters table d1001.
```
-taos> SELECT sum(current) FROM d1001 INTERVAL(10s);
- ts | sum(current) |
+taos> SELECT _wstart, sum(current) FROM d1001 INTERVAL(10s);
+ _wstart | sum(current) |
======================================================
2018-10-03 14:38:00.000 | 10.300000191 |
2018-10-03 14:38:10.000 | 24.900000572 |
-Query OK, 2 row(s) in set (0.000883s)
+Query OK, 2 rows in database (0.003139s)
```
Down sampling can also be used for STable. For example, the below SQL statement can be used to get the sum of current from all meters in California.
```
-taos> SELECT SUM(current) FROM meters where location like "California%" INTERVAL(1s);
- ts | sum(current) |
+taos> SELECT _wstart, SUM(current) FROM meters where location like "California%" INTERVAL(1s);
+ _wstart | sum(current) |
======================================================
2018-10-03 14:38:04.000 | 10.199999809 |
- 2018-10-03 14:38:05.000 | 32.900000572 |
+ 2018-10-03 14:38:05.000 | 23.699999809 |
2018-10-03 14:38:06.000 | 11.500000000 |
2018-10-03 14:38:15.000 | 12.600000381 |
- 2018-10-03 14:38:16.000 | 36.000000000 |
-Query OK, 5 row(s) in set (0.001538s)
+ 2018-10-03 14:38:16.000 | 34.400000572 |
+Query OK, 5 rows in database (0.007413s)
```
Down sampling also supports time offset. For example, the below SQL statement can be used to get the sum of current from all meters but each time window must start at the boundary of 500 milliseconds.
```
-taos> SELECT SUM(current) FROM meters INTERVAL(1s, 500a);
- ts | sum(current) |
+taos> SELECT _wstart, SUM(current) FROM meters INTERVAL(1s, 500a);
+ _wstart | sum(current) |
======================================================
- 2018-10-03 14:38:04.500 | 11.189999809 |
- 2018-10-03 14:38:05.500 | 31.900000572 |
- 2018-10-03 14:38:06.500 | 11.600000000 |
- 2018-10-03 14:38:15.500 | 12.300000381 |
- 2018-10-03 14:38:16.500 | 35.000000000 |
-Query OK, 5 row(s) in set (0.001521s)
+ 2018-10-03 14:38:03.500 | 10.199999809 |
+ 2018-10-03 14:38:04.500 | 10.300000191 |
+ 2018-10-03 14:38:05.500 | 13.399999619 |
+ 2018-10-03 14:38:06.500 | 11.500000000 |
+ 2018-10-03 14:38:14.500 | 12.600000381 |
+ 2018-10-03 14:38:16.500 | 34.400000572 |
+Query OK, 6 rows in database (0.005515s)
```
In many use cases, it's hard to align the timestamp of the data collected by each collection point. However, a lot of algorithms like FFT require the data to be aligned with same time interval and application programs have to handle this by themselves. In TDengine, it's easy to achieve the alignment using down sampling.
Interpolation can be performed in TDengine if there is no data in a time range.
-For more details please refer to [Aggregate by Window](/taos-sql/interval).
+For more information, see [Aggregate by Window](../../taos-sql/distinguished).
## Examples
@@ -158,6 +152,9 @@ In the section describing [Insert](/develop/insert-data/sql-writing), a database
+
+
+
:::note
diff --git a/docs/en/07-develop/06-continuous-query.mdx b/docs/en/07-develop/06-continuous-query.mdx
deleted file mode 100644
index 1aea5783fc8116a4e02a4b5345d341707cd399ea..0000000000000000000000000000000000000000
--- a/docs/en/07-develop/06-continuous-query.mdx
+++ /dev/null
@@ -1,83 +0,0 @@
----
-sidebar_label: Continuous Query
-description: "Continuous query is a query that's executed automatically at a predefined frequency to provide aggregate query capability by time window. It is essentially simplified, time driven, stream computing."
-title: "Continuous Query"
----
-
-A continuous query is a query that's executed automatically at a predefined frequency to provide aggregate query capability by time window. It is essentially simplified, time driven, stream computing. A continuous query can be performed on a table or STable in TDengine. The results of a continuous query can be pushed to clients or written back to TDengine. Each query is executed on a time window, which moves forward with time. The size of time window and the forward sliding time need to be specified with parameter `INTERVAL` and `SLIDING` respectively.
-
-A continuous query in TDengine is time driven, and can be defined using TAOS SQL directly without any extra operations. With a continuous query, the result can be generated based on a time window to achieve down sampling of the original data. Once a continuous query is defined using TAOS SQL, the query is automatically executed at the end of each time window and the result is pushed back to clients or written to TDengine.
-
-There are some differences between continuous query in TDengine and time window computation in stream computing:
-
-- The computation is performed and the result is returned in real time in stream computing, but the computation in continuous query is only started when a time window closes. For example, if the time window is 1 day, then the result will only be generated at 23:59:59.
-- If a historical data row is written in to a time window for which the computation has already finished, the computation will not be performed again and the result will not be pushed to client applications again. If the results have already been written into TDengine, they will not be updated.
-- In continuous query, if the result is pushed to a client, the client status is not cached on the server side and Exactly-once is not guaranteed by the server. If the client program crashes, a new time window will be generated from the time where the continuous query is restarted. If the result is written into TDengine, the data written into TDengine can be guaranteed as valid and continuous.
-
-## Syntax
-
-```sql
-[CREATE TABLE AS] SELECT select_expr [, select_expr ...]
- FROM {tb_name_list}
- [WHERE where_condition]
- [INTERVAL(interval_val [, interval_offset]) [SLIDING sliding_val]]
-
-```
-
-INTERVAL: The time window for which continuous query is performed
-
-SLIDING: The time step for which the time window moves forward each time
-
-## How to Use
-
-In this section the use case of meters will be used to introduce how to use continuous query. Assume the STable and subtables have been created using the SQL statements below.
-
-```sql
-create table meters (ts timestamp, current float, voltage int, phase float) tags (location binary(64), groupId int);
-create table D1001 using meters tags ("California.SanFrancisco", 2);
-create table D1002 using meters tags ("California.LosAngeles", 2);
-```
-
-The SQL statement below retrieves the average voltage for a one minute time window, with each time window moving forward by 30 seconds.
-
-```sql
-select avg(voltage) from meters interval(1m) sliding(30s);
-```
-
-Whenever the above SQL statement is executed, all the existing data will be computed again. If the computation needs to be performed every 30 seconds automatically to compute on the data in the past one minute, the above SQL statement needs to be revised as below, in which `{startTime}` stands for the beginning timestamp in the latest time window.
-
-```sql
-select avg(voltage) from meters where ts > {startTime} interval(1m) sliding(30s);
-```
-
-An easier way to achieve this is to prepend `create table {tableName} as` before the `select`.
-
-```sql
-create table avg_vol as select avg(voltage) from meters interval(1m) sliding(30s);
-```
-
-A table named as `avg_vol` will be created automatically, then every 30 seconds the `select` statement will be executed automatically on the data in the past 1 minute, i.e. the latest time window, and the result is written into table `avg_vol`. The client program just needs to query from table `avg_vol`. For example:
-
-```sql
-taos> select * from avg_vol;
- ts | avg_voltage_ |
-===================================================
- 2020-07-29 13:37:30.000 | 222.0000000 |
- 2020-07-29 13:38:00.000 | 221.3500000 |
- 2020-07-29 13:38:30.000 | 220.1700000 |
- 2020-07-29 13:39:00.000 | 223.0800000 |
-```
-
-Please note that the minimum allowed time window is 10 milliseconds, and there is no upper limit.
-
-It's possible to specify the start and end time of a continuous query. If the start time is not specified, the timestamp of the first row will be considered as the start time; if the end time is not specified, the continuous query will be performed indefinitely, otherwise it will be terminated once the end time is reached. For example, the continuous query in the SQL statement below will be started from now and terminated one hour later.
-
-```sql
-create table avg_vol as select avg(voltage) from meters where ts > now and ts <= now + 1h interval(1m) sliding(30s);
-```
-
-`now` in the above SQL statement stands for the time when the continuous query is created, not the time when the computation is actually performed. To avoid the trouble caused by a delay in receiving data as much as possible, the actual computation in a continuous query is started after a little delay. That means, once a time window closes, the computation is not started immediately. Normally, the result are available after a little time, normally within one minute, after the time window closes.
-
-## How to Manage
-
-`show streams` command can be used in the TDengine CLI `taos` to show all the continuous queries in the system, and `kill stream` can be used to terminate a continuous query.
diff --git a/docs/en/07-develop/06-stream.md b/docs/en/07-develop/06-stream.md
new file mode 100644
index 0000000000000000000000000000000000000000..36f903ee9a4f2d210e63d0b79e702bc199f790ed
--- /dev/null
+++ b/docs/en/07-develop/06-stream.md
@@ -0,0 +1,113 @@
+---
+sidebar_label: Stream Processing
+description: "The TDengine stream processing engine combines data inserts, preprocessing, analytics, real-time computation, and alerting into a single component."
+title: Stream Processing
+---
+
+Raw time-series data is often cleaned and preprocessed before being permanently stored in a database. In a traditional time-series solution, this generally requires the deployment of stream processing systems such as Kafka or Flink. However, the complexity of such systems increases the cost of development and maintenance.
+
+With the stream processing engine built into TDengine, you can process incoming data streams in real time and define stream transformations in SQL. Incoming data is automatically processed, and the results are pushed to specified tables based on triggering rules that you define. This is a lightweight alternative to complex processing engines that returns computation results in milliseconds even in high throughput scenarios.
+
+The stream processing engine includes data filtering, scalar function computation (including user-defined functions), and window aggregation, with support for sliding windows, session windows, and event windows. Stream processing can write data to supertables from other supertables, standard tables, or subtables. When you create a stream, the target supertable is automatically created. New data is then processed and written to that supertable according to the rules defined for the stream. You can use PARTITION BY statements to partition the data by table name or tag. Separate partitions are then written to different subtables within the target supertable.
+
+TDengine stream processing supports the aggregation of supertables that are deployed across multiple vnodes. It can also handle out-of-order writes and includes a watermark mechanism that determines the extent to which out-of-order data is accepted by the system. You can configure whether to drop or reprocess out-of-order data through the **ignore expired** parameter.
+
+For more information, see [Stream Processing](../../taos-sql/stream).
+
+
+## Create a Stream
+
+```sql
+CREATE STREAM [IF NOT EXISTS] stream_name [stream_options] INTO stb_name AS subquery
+stream_options: {
+ TRIGGER [AT_ONCE | WINDOW_CLOSE | MAX_DELAY time]
+ WATERMARK time
+ IGNORE EXPIRED [0 | 1]
+}
+```
+
+For more information, see [Stream Processing](../../taos-sql/stream).
+
+## Usage Scenario 1
+
+It is common that smart electrical meter systems for businesses generate millions of data points that are widely dispersed and not ordered. The time required to clean and convert this data makes efficient, real-time processing impossible for traditional solutions. This scenario shows how you can configure TDengine stream processing to drop data points over 220 V, find the maximum voltage for 5 second windows, and output this data to a table.
+
+### Create a Database for Raw Data
+
+A database including one supertable and four subtables is created as follows:
+
+```sql
+DROP DATABASE IF EXISTS power;
+CREATE DATABASE power;
+USE power;
+
+CREATE STABLE meters (ts timestamp, current float, voltage int, phase float) TAGS (location binary(64), groupId int);
+
+CREATE TABLE d1001 USING meters TAGS ("California.SanFrancisco", 2);
+CREATE TABLE d1002 USING meters TAGS ("California.SanFrancisco", 3);
+CREATE TABLE d1003 USING meters TAGS ("California.LosAngeles", 2);
+CREATE TABLE d1004 USING meters TAGS ("California.LosAngeles", 3);
+```
+
+### Create a Stream
+
+```sql
+create stream current_stream into current_stream_output_stb as select _wstart as start, _wend as end, max(current) as max_current from meters where voltage <= 220 interval (5s);
+```
+
+### Write Data
+```sql
+insert into d1001 values("2018-10-03 14:38:05.000", 10.30000, 219, 0.31000);
+insert into d1001 values("2018-10-03 14:38:15.000", 12.60000, 218, 0.33000);
+insert into d1001 values("2018-10-03 14:38:16.800", 12.30000, 221, 0.31000);
+insert into d1002 values("2018-10-03 14:38:16.650", 10.30000, 218, 0.25000);
+insert into d1003 values("2018-10-03 14:38:05.500", 11.80000, 221, 0.28000);
+insert into d1003 values("2018-10-03 14:38:16.600", 13.40000, 223, 0.29000);
+insert into d1004 values("2018-10-03 14:38:05.000", 10.80000, 223, 0.29000);
+insert into d1004 values("2018-10-03 14:38:06.500", 11.50000, 221, 0.35000);
+```
+
+### Query the Results
+
+```sql
+taos> select start, end, max_current from current_stream_output_stb;
+ start | end | max_current |
+===========================================================================
+ 2018-10-03 14:38:05.000 | 2018-10-03 14:38:10.000 | 10.30000 |
+ 2018-10-03 14:38:15.000 | 2018-10-03 14:38:20.000 | 12.60000 |
+Query OK, 2 rows in database (0.018762s)
+```
+
+## Usage Scenario 2
+
+In this scenario, the active power and reactive power are determined from the data gathered in the previous scenario. The location and name of each meter are concatenated with a period (.) between them, and the data set is partitioned by meter name and written to a new database.
+
+### Create a Database for Raw Data
+
+The procedure from the previous scenario is used to create the database.
+
+### Create a Stream
+
+```sql
+create stream power_stream into power_stream_output_stb as select ts, concat_ws(".", location, tbname) as meter_location, current*voltage*cos(phase) as active_power, current*voltage*sin(phase) as reactive_power from meters partition by tbname;
+```
+
+### Write data
+
+The procedure from the previous scenario is used to write the data.
+
+### Query the Results
+```sql
+taos> select ts, meter_location, active_power, reactive_power from power_stream_output_stb;
+ ts | meter_location | active_power | reactive_power |
+===================================================================================================================
+ 2018-10-03 14:38:05.000 | California.LosAngeles.d1004 | 2307.834596289 | 688.687331847 |
+ 2018-10-03 14:38:06.500 | California.LosAngeles.d1004 | 2387.415754896 | 871.474763418 |
+ 2018-10-03 14:38:05.500 | California.LosAngeles.d1003 | 2506.240411679 | 720.680274962 |
+ 2018-10-03 14:38:16.600 | California.LosAngeles.d1003 | 2863.424274422 | 854.482390839 |
+ 2018-10-03 14:38:05.000 | California.SanFrancisco.d1001 | 2148.178871730 | 688.120784090 |
+ 2018-10-03 14:38:15.000 | California.SanFrancisco.d1001 | 2598.589176205 | 890.081451418 |
+ 2018-10-03 14:38:16.800 | California.SanFrancisco.d1001 | 2588.728381186 | 829.240910475 |
+ 2018-10-03 14:38:16.650 | California.SanFrancisco.d1002 | 2175.595991997 | 555.520860397 |
+Query OK, 8 rows in database (0.014753s)
+```
diff --git a/docs/en/07-develop/07-subscribe.mdx b/docs/en/07-develop/07-subscribe.mdx
deleted file mode 100644
index 782fcdbaf221419dd231bd10958e26b8f4f856e5..0000000000000000000000000000000000000000
--- a/docs/en/07-develop/07-subscribe.mdx
+++ /dev/null
@@ -1,259 +0,0 @@
----
-sidebar_label: Data Subscription
-description: "Lightweight service for data subscription and publishing. Time series data inserted into TDengine continuously can be pushed automatically to subscribing clients."
-title: Data Subscription
----
-
-import Tabs from "@theme/Tabs";
-import TabItem from "@theme/TabItem";
-import Java from "./_sub_java.mdx";
-import Python from "./_sub_python.mdx";
-import Go from "./_sub_go.mdx";
-import Rust from "./_sub_rust.mdx";
-import Node from "./_sub_node.mdx";
-import CSharp from "./_sub_cs.mdx";
-import CDemo from "./_sub_c.mdx";
-
-## Introduction
-
-Due to the nature of time series data, data insertion into TDengine is similar to data publishing in message queues. Data is stored in ascending order of timestamp inside TDengine, and so each table in TDengine can essentially be considered as a message queue.
-
-A lightweight service for data subscription and publishing is built into TDengine. With the API provided by TDengine, client programs can use `select` statements to subscribe to data from one or more tables. The subscription and state maintenance is performed on the client side. The client programs poll the server to check whether there is new data, and if so the new data will be pushed back to the client side. If the client program is restarted, where to start retrieving new data is up to the client side.
-
-There are 3 major APIs related to subscription provided in the TDengine client driver.
-
-```c
-taos_subscribe
-taos_consume
-taos_unsubscribe
-```
-
-For more details about these APIs please refer to [C/C++ Connector](/reference/connector/cpp). Their usage will be introduced below using the use case of meters, in which the schema of STable and subtables from the previous section [Continuous Query](/develop/continuous-query) are used. Full sample code can be found [here](https://github.com/taosdata/TDengine/blob/master/examples/c/subscribe.c).
-
-If we want to get a notification and take some actions if the current exceeds a threshold, like 10A, from some meters, there are two ways:
-
-The first way is to query each sub table and record the last timestamp matching the criteria. Then after some time, query the data later than the recorded timestamp, and repeat this process. The SQL statements for this way are as below.
-
-```sql
-select * from D1001 where ts > {last_timestamp1} and current > 10;
-select * from D1002 where ts > {last_timestamp2} and current > 10;
-...
-```
-
-The above way works, but the problem is that the number of `select` statements increases with the number of meters. Additionally, the performance of both client side and server side will be unacceptable once the number of meters grows to a big enough number.
-
-A better way is to query on the STable, only one `select` is enough regardless of the number of meters, like below:
-
-```sql
-select * from meters where ts > {last_timestamp} and current > 10;
-```
-
-However, this presents a new problem in how to choose `last_timestamp`. First, the timestamp when the data is generated is different from the timestamp when the data is inserted into the database, sometimes the difference between them may be very big. Second, the time when the data from different meters arrives at the database may be different too. If the timestamp of the "slowest" meter is used as `last_timestamp` in the query, the data from other meters may be selected repeatedly; but if the timestamp of the "fastest" meter is used as `last_timestamp`, some data from other meters may be missed.
-
-All the problems mentioned above can be resolved easily using the subscription functionality provided by TDengine.
-
-The first step is to create subscription using `taos_subscribe`.
-
-```c
-TAOS_SUB* tsub = NULL;
-if (async) {
- // create an asynchronous subscription, the callback function will be called every 1s
- tsub = taos_subscribe(taos, restart, topic, sql, subscribe_callback, &blockFetch, 1000);
-} else {
- // create an synchronous subscription, need to call 'taos_consume' manually
- tsub = taos_subscribe(taos, restart, topic, sql, NULL, NULL, 0);
-}
-```
-
-The subscription in TDengine can be either synchronous or asynchronous. In the above sample code, the value of variable `async` is determined from the CLI input, then it's used to create either an async or sync subscription. Sync subscription means the client program needs to invoke `taos_consume` to retrieve data, and async subscription means another thread created by `taos_subscribe` internally invokes `taos_consume` to retrieve data and pass the data to `subscribe_callback` for processing. `subscribe_callback` is a callback function provided by the client program. You should not perform time consuming operations in the callback function.
-
-The parameter `taos` is an established connection. Nothing special needs to be done for thread safety for synchronous subscription. For asynchronous subscription, the taos_subscribe function should be called exclusively by the current thread, to avoid unpredictable errors.
-
-The parameter `sql` is a `select` statement in which the `where` clause can be used to specify filter conditions. In our example, we can subscribe to the records in which the current exceeds 10A, with the following SQL statement:
-
-```sql
-select * from meters where current > 10;
-```
-
-Please note that, all the data will be processed because no start time is specified. If we only want to process data for the past day, a time related condition can be added:
-
-```sql
-select * from meters where ts > now - 1d and current > 10;
-```
-
-The parameter `topic` is the name of the subscription. The client application must guarantee that the name is unique. However, it doesn't have to be globally unique because subscription is implemented in the APIs on the client side.
-
-If the subscription named as `topic` doesn't exist, the parameter `restart` will be ignored. If the subscription named as `topic` has been created before by the client program, when the client program is restarted with the subscription named `topic`, parameter `restart` is used to determine whether to retrieve data from the beginning or from the last point where the subscription was broken.
-
-If the value of `restart` is **true** (i.e. a non-zero value), data will be retrieved from the beginning. If it is **false** (i.e. zero), the data already consumed before will not be processed again.
-
-The last parameter of `taos_subscribe` is the polling interval in units of millisecond. In sync mode, if the time difference between two continuous invocations to `taos_consume` is smaller than the interval specified by `taos_subscribe`, `taos_consume` will be blocked until the interval is reached. In async mode, this interval is the minimum interval between two invocations to the call back function.
-
-The second to last parameter of `taos_subscribe` is used to pass arguments to the call back function. `taos_subscribe` doesn't process this parameter and simply passes it to the call back function. This parameter is simply ignored in sync mode.
-
-After a subscription is created, its data can be consumed and processed. Shown below is the sample code to consume data in sync mode, in the else condition of `if (async)`.
-
-```c
-if (async) {
- getchar();
-} else while(1) {
- TAOS_RES* res = taos_consume(tsub);
- if (res == NULL) {
- printf("failed to consume data.");
- break;
- } else {
- print_result(res, blockFetch);
- getchar();
- }
-}
-```
-
-In the above sample code in the else condition, there is an infinite loop. Each time carriage return is entered `taos_consume` is invoked. The return value of `taos_consume` is the selected result set. In the above sample, `print_result` is used to simplify the printing of the result set. It is similar to `taos_use_result`. Below is the implementation of `print_result`.
-
-```c
-void print_result(TAOS_RES* res, int blockFetch) {
- TAOS_ROW row = NULL;
- int num_fields = taos_num_fields(res);
- TAOS_FIELD* fields = taos_fetch_fields(res);
- int nRows = 0;
- if (blockFetch) {
- nRows = taos_fetch_block(res, &row);
- for (int i = 0; i < nRows; i++) {
- char temp[256];
- taos_print_row(temp, row + i, fields, num_fields);
- puts(temp);
- }
- } else {
- while ((row = taos_fetch_row(res))) {
- char temp[256];
- taos_print_row(temp, row, fields, num_fields);
- puts(temp);
- nRows++;
- }
- }
- printf("%d rows consumed.\n", nRows);
-}
-```
-
-In the above code `taos_print_row` is used to process the data consumed. All matching rows are printed.
-
-In async mode, consuming data is simpler as shown below.
-
-```c
-void subscribe_callback(TAOS_SUB* tsub, TAOS_RES *res, void* param, int code) {
- print_result(res, *(int*)param);
-}
-```
-
-`taos_unsubscribe` can be invoked to terminate a subscription.
-
-```c
-taos_unsubscribe(tsub, keep);
-```
-
-The second parameter `keep` is used to specify whether to keep the subscription progress on the client sde. If it is **false**, i.e. **0**, then subscription will be restarted from beginning regardless of the `restart` parameter's value when `taos_subscribe` is invoked again. The subscription progress information is stored in _{DataDir}/subscribe/_ , under which there is a file with the same name as `topic` for each subscription(Note: The default value of `DataDir` in the `taos.cfg` file is **/var/lib/taos/**. However, **/var/lib/taos/** does not exist on the Windows server. So you need to change the `DataDir` value to the corresponding existing directory."), the subscription will be restarted from the beginning if the corresponding progress file is removed.
-
-Now let's see the effect of the above sample code, assuming below prerequisites have been done.
-
-- The sample code has been downloaded to local system
-- TDengine has been installed and launched properly on same system
-- The database, STable, and subtables required in the sample code are ready
-
-Launch the command below in the directory where the sample code resides to compile and start the program.
-
-```bash
-make
-./subscribe -sql='select * from meters where current > 10;'
-```
-
-After the program is started, open another terminal and launch TDengine CLI `taos`, then use the below SQL commands to insert a row whose current is 12A into table **D1001**.
-
-```sql
-use test;
-insert into D1001 values(now, 12, 220, 1);
-```
-
-Then, this row of data will be shown by the example program on the first terminal because its current exceeds 10A. More data can be inserted for you to observe the output of the example program.
-
-## Examples
-
-The example program below demonstrates how to subscribe, using connectors, to data rows in which current exceeds 10A.
-
-### Prepare Data
-
-```bash
-# create database "power"
-taos> create database power;
-# use "power" as the database in following operations
-taos> use power;
-# create super table "meters"
-taos> create table meters(ts timestamp, current float, voltage int, phase int) tags(location binary(64), groupId int);
-# create tabes using the schema defined by super table "meters"
-taos> create table d1001 using meters tags ("California.SanFrancisco", 2);
-taos> create table d1002 using meters tags ("California.LoSangeles", 2);
-# insert some rows
-taos> insert into d1001 values("2020-08-15 12:00:00.000", 12, 220, 1),("2020-08-15 12:10:00.000", 12.3, 220, 2),("2020-08-15 12:20:00.000", 12.2, 220, 1);
-taos> insert into d1002 values("2020-08-15 12:00:00.000", 9.9, 220, 1),("2020-08-15 12:10:00.000", 10.3, 220, 1),("2020-08-15 12:20:00.000", 11.2, 220, 1);
-# filter out the rows in which current is bigger than 10A
-taos> select * from meters where current > 10;
- ts | current | voltage | phase | location | groupid |
-===========================================================================================================
- 2020-08-15 12:10:00.000 | 10.30000 | 220 | 1 | California.LoSangeles | 2 |
- 2020-08-15 12:20:00.000 | 11.20000 | 220 | 1 | California.LoSangeles | 2 |
- 2020-08-15 12:00:00.000 | 12.00000 | 220 | 1 | California.SanFrancisco | 2 |
- 2020-08-15 12:10:00.000 | 12.30000 | 220 | 2 | California.SanFrancisco | 2 |
- 2020-08-15 12:20:00.000 | 12.20000 | 220 | 1 | California.SanFrancisco | 2 |
-Query OK, 5 row(s) in set (0.004896s)
-```
-
-### Example Programs
-
-
-
-
-
-
-
-
- {/*
-
- */}
-
-
-
- {/*
-
-
-
-
- */}
-
-
-
-
-
-### Run the Examples
-
-The example programs first consume all historical data matching the criteria.
-
-```bash
-ts: 1597464000000 current: 12.0 voltage: 220 phase: 1 location: California.SanFrancisco groupid : 2
-ts: 1597464600000 current: 12.3 voltage: 220 phase: 2 location: California.SanFrancisco groupid : 2
-ts: 1597465200000 current: 12.2 voltage: 220 phase: 1 location: California.SanFrancisco groupid : 2
-ts: 1597464600000 current: 10.3 voltage: 220 phase: 1 location: California.LoSangeles groupid : 2
-ts: 1597465200000 current: 11.2 voltage: 220 phase: 1 location: California.LoSangeles groupid : 2
-```
-
-Next, use TDengine CLI to insert a new row.
-
-```
-# taos
-taos> use power;
-taos> insert into d1001 values(now, 12.4, 220, 1);
-```
-
-Because the current in the inserted row exceeds 10A, it will be consumed by the example program.
-
-```
-ts: 1651146662805 current: 12.4 voltage: 220 phase: 1 location: California.SanFrancisco groupid: 2
-```
diff --git a/docs/en/07-develop/07-tmq.mdx b/docs/en/07-develop/07-tmq.mdx
new file mode 100644
index 0000000000000000000000000000000000000000..17b3f5caa062eaacb4216b7153e899040e702cc1
--- /dev/null
+++ b/docs/en/07-develop/07-tmq.mdx
@@ -0,0 +1,841 @@
+---
+sidebar_label: Data Subscription
+description: "The TDengine data subscription service automatically pushes data written in TDengine to subscribing clients."
+title: Data Subscription
+---
+
+import Tabs from "@theme/Tabs";
+import TabItem from "@theme/TabItem";
+import Java from "./_sub_java.mdx";
+import Python from "./_sub_python.mdx";
+import Go from "./_sub_go.mdx";
+import Rust from "./_sub_rust.mdx";
+import Node from "./_sub_node.mdx";
+import CSharp from "./_sub_cs.mdx";
+import CDemo from "./_sub_c.mdx";
+
+TDengine provides data subscription and consumption interfaces similar to message queue products. These interfaces make it easier for applications to obtain data written to TDengine either in real time and to process data in the order that events occurred. This simplifies your time-series data processing systems and reduces your costs because it is no longer necessary to deploy a message queue product such as Kafka.
+
+To use TDengine data subscription, you define topics like in Kafka. However, a topic in TDengine is based on query conditions for an existing supertable, table, or subtable - in other words, a SELECT statement. You can use SQL to filter data by tag, table name, column, or expression and then perform a scalar function or user-defined function on the data. Aggregate functions are not supported. This gives TDengine data subscription more flexibility than similar products. The granularity of data can be controlled on demand by applications, while filtering and preprocessing are handled by TDengine instead of the application layer. This implementation reduces the amount of data transmitted and the complexity of applications.
+
+By subscribing to a topic, a consumer can obtain the latest data in that topic in real time. Multiple consumers can be formed into a consumer group that consumes messages together. Consumer groups enable faster speed through multi-threaded, distributed data consumption. Note that consumers in different groups that are subscribed to the same topic do not consume messages together. A single consumer can subscribe to multiple topics. If the data in a supertable is sharded across multiple vnodes, consumer groups can consume it much more efficiently than single consumers. TDengine also includes an acknowledgement mechanism that ensures at-least-once delivery in complicated environments where machines may crash or restart.
+
+To implement these features, TDengine indexes its write-ahead log (WAL) file for fast random access and provides configurable methods for replacing and retaining this file. You can define a retention period and size for this file. For information, see the CREATE DATABASE statement. In this way, the WAL file is transformed into a persistent storage engine that remembers the order in which events occur. However, note that configuring an overly long retention period for your WAL files makes database compression inefficient. TDengine then uses the WAL file instead of the time-series database as its storage engine for queries in the form of topics. TDengine reads the data from the WAL file; uses a unified query engine instance to perform filtering, transformations, and other operations; and finally pushes the data to consumers.
+
+
+
+## Data Schema and API
+
+The related schemas and APIs in various languages are described as follows:
+
+
+
+
+```c
+typedef struct tmq_t tmq_t;
+typedef struct tmq_conf_t tmq_conf_t;
+typedef struct tmq_list_t tmq_list_t;
+
+typedef void(tmq_commit_cb(tmq_t *, int32_t code, void *param));
+
+DLL_EXPORT tmq_list_t *tmq_list_new();
+DLL_EXPORT int32_t tmq_list_append(tmq_list_t *, const char *);
+DLL_EXPORT void tmq_list_destroy(tmq_list_t *);
+DLL_EXPORT tmq_t *tmq_consumer_new(tmq_conf_t *conf, char *errstr, int32_t errstrLen);
+DLL_EXPORT const char *tmq_err2str(int32_t code);
+
+DLL_EXPORT int32_t tmq_subscribe(tmq_t *tmq, const tmq_list_t *topic_list);
+DLL_EXPORT int32_t tmq_unsubscribe(tmq_t *tmq);
+DLL_EXPORT TAOS_RES *tmq_consumer_poll(tmq_t *tmq, int64_t timeout);
+DLL_EXPORT int32_t tmq_consumer_close(tmq_t *tmq);
+DLL_EXPORT int32_t tmq_commit_sync(tmq_t *tmq, const TAOS_RES *msg);
+DLL_EXPORT void tmq_commit_async(tmq_t *tmq, const TAOS_RES *msg, tmq_commit_cb *cb, void *param);
+
+enum tmq_conf_res_t {
+ TMQ_CONF_UNKNOWN = -2,
+ TMQ_CONF_INVALID = -1,
+ TMQ_CONF_OK = 0,
+};
+typedef enum tmq_conf_res_t tmq_conf_res_t;
+
+DLL_EXPORT tmq_conf_t *tmq_conf_new();
+DLL_EXPORT tmq_conf_res_t tmq_conf_set(tmq_conf_t *conf, const char *key, const char *value);
+DLL_EXPORT void tmq_conf_destroy(tmq_conf_t *conf);
+DLL_EXPORT void tmq_conf_set_auto_commit_cb(tmq_conf_t *conf, tmq_commit_cb *cb, void *param);
+```
+
+For more information, see [C/C++ Connector](/reference/connector/cpp).
+
+The following example is based on the smart meter table described in Data Models. For complete sample code, see the C language section below.
+
+
+
+
+```java
+void subscribe(Collection topics) throws SQLException;
+
+void unsubscribe() throws SQLException;
+
+Set subscription() throws SQLException;
+
+ConsumerRecords poll(Duration timeout) throws SQLException;
+
+void commitAsync();
+
+void commitAsync(OffsetCommitCallback callback);
+
+void commitSync() throws SQLException;
+
+void close() throws SQLException;
+```
+
+
+
+
+
+```python
+class TaosConsumer():
+ def __init__(self, *topics, **configs)
+
+ def __iter__(self)
+
+ def __next__(self)
+
+ def sync_next(self)
+
+ def subscription(self)
+
+ def unsubscribe(self)
+
+ def close(self)
+
+ def __del__(self)
+```
+
+
+
+
+
+```go
+func NewConsumer(conf *Config) (*Consumer, error)
+
+func (c *Consumer) Close() error
+
+func (c *Consumer) Commit(ctx context.Context, message unsafe.Pointer) error
+
+func (c *Consumer) FreeMessage(message unsafe.Pointer)
+
+func (c *Consumer) Poll(timeout time.Duration) (*Result, error)
+
+func (c *Consumer) Subscribe(topics []string) error
+
+func (c *Consumer) Unsubscribe() error
+```
+
+
+
+
+
+```rust
+impl TBuilder for TmqBuilder
+ fn from_dsn(dsn: D) -> Result
+ fn build(&self) -> Result
+
+impl AsAsyncConsumer for Consumer
+ async fn subscribe, I: IntoIterator + Send>(
+ &mut self,
+ topics: I,
+ ) -> Result<(), Self::Error>;
+ fn stream(
+ &self,
+ ) -> Pin<
+ Box<
+ dyn '_
+ + Send
+ + futures::Stream<
+ Item = Result<(Self::Offset, MessageSet), Self::Error>,
+ >,
+ >,
+ >;
+ async fn commit(&self, offset: Self::Offset) -> Result<(), Self::Error>;
+
+ async fn unsubscribe(self);
+```
+
+For more information, see [Crate taos](https://docs.rs/taos).
+
+
+
+
+
+```js
+function TMQConsumer(config)
+
+function subscribe(topic)
+
+function consume(timeout)
+
+function subscription()
+
+function unsubscribe()
+
+function commit(msg)
+
+function close()
+```
+
+
+
+
+
+```csharp
+ConsumerBuilder(IEnumerable> config)
+
+virtual IConsumer Build()
+
+Consumer(ConsumerBuilder builder)
+
+void Subscribe(IEnumerable topics)
+
+void Subscribe(string topic)
+
+ConsumeResult Consume(int millisecondsTimeout)
+
+List Subscription()
+
+void Unsubscribe()
+
+void Commit(ConsumeResult consumerResult)
+
+void Close()
+```
+
+
+
+
+## Insert Data into TDengine
+
+A database including one supertable and two subtables is created as follows:
+
+```sql
+DROP DATABASE IF EXISTS tmqdb;
+CREATE DATABASE tmqdb;
+CREATE TABLE tmqdb.stb (ts TIMESTAMP, c1 INT, c2 FLOAT, c3 VARCHAR(16) TAGS(t1 INT, t3 VARCHAR(16));
+CREATE TABLE tmqdb.ctb0 USING tmqdb.stb TAGS(0, "subtable0");
+CREATE TABLE tmqdb.ctb1 USING tmqdb.stb TAGS(1, "subtable1");
+INSERT INTO tmqdb.ctb0 VALUES(now, 0, 0, 'a0')(now+1s, 0, 0, 'a00');
+INSERT INTO tmqdb.ctb1 VALUES(now, 1, 1, 'a1')(now+1s, 11, 11, 'a11');
+```
+
+## Create a Topic
+
+The following SQL statement creates a topic in TDengine:
+
+```sql
+CREATE TOPIC topic_name AS SELECT ts, c1, c2, c3 FROM tmqdb.stb WHERE c1 > 1;
+```
+
+Multiple subscription types are supported.
+
+#### Subscribe to a Column
+
+Syntax:
+
+```sql
+CREATE TOPIC topic_name as subquery
+```
+
+You can subscribe to a topic through a SELECT statement. Statements that specify columns, such as `SELECT *` and `SELECT ts, cl` are supported, as are filtering conditions and scalar functions. Aggregate functions and time window aggregation are not supported. Note:
+
+- The schema of topics created in this manner is determined by the subscribed data.
+- You cannot modify (`ALTER
MODIFY`) or delete (`ALTER
DROP`) columns or tags that are used in a subscription or calculation.
+- Columns added to a table after the subscription is created are not displayed in the results. Deleting columns will cause an error.
+
+### Subscribe to a Supertable
+
+Syntax:
+
+```sql
+CREATE TOPIC topic_name AS STABLE stb_name
+```
+
+Creating a topic in this manner differs from a `SELECT * from stbName` statement as follows:
+
+- The table schema can be modified.
+- Unstructured data is returned. The format of the data returned changes based on the supertable schema.
+- A different table schema may exist for every data block to be processed.
+- The data returned does not include tags.
+
+### Subscribe to a Database
+
+Syntax:
+
+```sql
+CREATE TOPIC topic_name [WITH META] AS DATABASE db_name;
+```
+
+This SQL statement creates a subscription to all tables in the database. You can add the `WITH META` parameter to include schema changes in the subscription, including creating and deleting supertables; adding, deleting, and modifying columns; and creating, deleting, and modifying the tags of subtables. Consumers can determine the message type from the API. Note that this differs from Kafka.
+
+## Create a Consumer
+
+You configure the following parameters when creating a consumer:
+
+| Parameter | Type | Description | Remarks |
+| :----------------------------: | :-----: | -------------------------------------------------------- | ------------------------------------------- |
+| `td.connect.ip` | string | Used in establishing a connection; same as `taos_connect` | |
+| `td.connect.user` | string | Used in establishing a connection; same as `taos_connect` | |
+| `td.connect.pass` | string | Used in establishing a connection; same as `taos_connect` | |
+| `td.connect.port` | string | Used in establishing a connection; same as `taos_connect` | |
+| `group.id` | string | Consumer group ID; consumers with the same ID are in the same group | **Required**. Maximum length: 192. |
+| `client.id` | string | Client ID | Maximum length: 192. |
+| `auto.offset.reset` | enum | Initial offset for the consumer group | Specify `earliest`, `latest`, or `none`(default) |
+| `enable.auto.commit` | boolean | Commit automatically | Specify `true` or `false`. |
+| `auto.commit.interval.ms` | integer | Interval for automatic commits, in milliseconds |
+| `enable.heartbeat.background` | boolean | Backend heartbeat; if enabled, the consumer does not go offline even if it has not polled for a long time | |
+| `experimental.snapshot.enable` | boolean | Specify whether to consume messages from the WAL or from TSBS | |
+| `msg.with.table.name` | boolean | Specify whether to deserialize table names from messages |
+
+The method of specifying these parameters depends on the language used:
+
+
+
+
+```c
+/* Create consumer groups on demand (group.id) and enable automatic commits (enable.auto.commit),
+ an automatic commit interval (auto.commit.interval.ms), and a username (td.connect.user) and password (td.connect.pass) */
+tmq_conf_t* conf = tmq_conf_new();
+tmq_conf_set(conf, "enable.auto.commit", "true");
+tmq_conf_set(conf, "auto.commit.interval.ms", "1000");
+tmq_conf_set(conf, "group.id", "cgrpName");
+tmq_conf_set(conf, "td.connect.user", "root");
+tmq_conf_set(conf, "td.connect.pass", "taosdata");
+tmq_conf_set(conf, "auto.offset.reset", "earliest");
+tmq_conf_set(conf, "experimental.snapshot.enable", "true");
+tmq_conf_set(conf, "msg.with.table.name", "true");
+tmq_conf_set_auto_commit_cb(conf, tmq_commit_cb_print, NULL);
+
+tmq_t* tmq = tmq_consumer_new(conf, NULL, 0);
+tmq_conf_destroy(conf);
+```
+
+
+
+
+Java programs use the following parameters:
+
+| Parameter | Type | Description | Remarks |
+| ----------------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------- |
+| `bootstrap.servers` | string |Connection address, such as `localhost:6030` |
+| `value.deserializer` | string | Value deserializer; to use this method, implement the `com.taosdata.jdbc.tmq.Deserializer` interface or inherit the `com.taosdata.jdbc.tmq.ReferenceDeserializer` type |
+| `value.deserializer.encoding` | string | Specify the encoding for string deserialization | |
+
+Note: The `bootstrap.servers` parameter is used instead of `td.connect.ip` and `td.connect.port` to provide an interface that is consistent with Kafka.
+
+```java
+Properties properties = new Properties();
+properties.setProperty("enable.auto.commit", "true");
+properties.setProperty("auto.commit.interval.ms", "1000");
+properties.setProperty("group.id", "cgrpName");
+properties.setProperty("bootstrap.servers", "127.0.0.1:6030");
+properties.setProperty("td.connect.user", "root");
+properties.setProperty("td.connect.pass", "taosdata");
+properties.setProperty("auto.offset.reset", "earliest");
+properties.setProperty("msg.with.table.name", "true");
+properties.setProperty("value.deserializer", "com.taos.example.MetersDeserializer");
+
+TaosConsumer consumer = new TaosConsumer<>(properties);
+
+/* value deserializer definition. */
+import com.taosdata.jdbc.tmq.ReferenceDeserializer;
+
+public class MetersDeserializer extends ReferenceDeserializer {
+}
+```
+
+
+
+
+
+```go
+config := tmq.NewConfig()
+defer config.Destroy()
+err = config.SetGroupID("test")
+if err != nil {
+ panic(err)
+}
+err = config.SetAutoOffsetReset("earliest")
+if err != nil {
+ panic(err)
+}
+err = config.SetConnectIP("127.0.0.1")
+if err != nil {
+ panic(err)
+}
+err = config.SetConnectUser("root")
+if err != nil {
+ panic(err)
+}
+err = config.SetConnectPass("taosdata")
+if err != nil {
+ panic(err)
+}
+err = config.SetConnectPort("6030")
+if err != nil {
+ panic(err)
+}
+err = config.SetMsgWithTableName(true)
+if err != nil {
+ panic(err)
+}
+err = config.EnableHeartBeat()
+if err != nil {
+ panic(err)
+}
+err = config.EnableAutoCommit(func(result *wrapper.TMQCommitCallbackResult) {
+ if result.ErrCode != 0 {
+ errStr := wrapper.TMQErr2Str(result.ErrCode)
+ err := errors.NewError(int(result.ErrCode), errStr)
+ panic(err)
+ }
+})
+if err != nil {
+ panic(err)
+}
+```
+
+
+
+
+
+```rust
+let mut dsn: Dsn = "taos://".parse()?;
+dsn.set("group.id", "group1");
+dsn.set("client.id", "test");
+dsn.set("auto.offset.reset", "earliest");
+
+let tmq = TmqBuilder::from_dsn(dsn)?;
+
+let mut consumer = tmq.build()?;
+```
+
+
+
+
+
+Python programs use the following parameters:
+
+| Parameter | Type | Description | Remarks |
+| :----------------------------: | :----: | -------------------------------------------------------- | ------------------------------------------- |
+| `td_connect_ip` | string | Used in establishing a connection; same as `taos_connect` | |
+| `td_connect_user` | string | Used in establishing a connection; same as `taos_connect` | |
+| `td_connect_pass` | string | Used in establishing a connection; same as `taos_connect` | |
+| `td_connect_port` | string | Used in establishing a connection; same as `taos_connect` | |
+| `group_id` | string | Consumer group ID; consumers with the same ID are in the same group | **Required**. Maximum length: 192. |
+| `client_id` | string | Client ID | Maximum length: 192. |
+| `auto_offset_reset` | string | Initial offset for the consumer group | Specify `earliest`, `latest`, or `none`(default) |
+| `enable_auto_commit` | string | Commit automatically | Specify `true` or `false`. |
+| `auto_commit_interval_ms` | string | Interval for automatic commits, in milliseconds |
+| `enable_heartbeat_background` | string | Backend heartbeat; if enabled, the consumer does not go offline even if it has not polled for a long time | Specify `true` or `false`. |
+| `experimental_snapshot_enable` | string | Specify whether to consume messages from the WAL or from TSBS | Specify `true` or `false`. |
+| `msg_with_table_name` | string | Specify whether to deserialize table names from messages | Specify `true` or `false`.
+| `timeout` | int | Consumer pull timeout | |
+
+
+
+
+
+```js
+// Create consumer groups on demand (group.id) and enable automatic commits (enable.auto.commit),
+// an automatic commit interval (auto.commit.interval.ms), and a username (td.connect.user) and password (td.connect.pass)
+
+let consumer = taos.consumer({
+ 'enable.auto.commit': 'true',
+ 'auto.commit.interval.ms','1000',
+ 'group.id': 'tg2',
+ 'td.connect.user': 'root',
+ 'td.connect.pass': 'taosdata',
+ 'auto.offset.reset','earliest',
+ 'msg.with.table.name': 'true',
+ 'td.connect.ip','127.0.0.1',
+ 'td.connect.port','6030'
+ });
+```
+
+
+
+
+
+```csharp
+using TDengineTMQ;
+
+// Create consumer groups on demand (GourpID) and enable automatic commits (EnableAutoCommit),
+// an automatic commit interval (AutoCommitIntervalMs), and a username (TDConnectUser) and password (TDConnectPasswd)
+var cfg = new ConsumerConfig
+ {
+ EnableAutoCommit = "true"
+ AutoCommitIntervalMs = "1000"
+ GourpId = "TDengine-TMQ-C#",
+ TDConnectUser = "root",
+ TDConnectPasswd = "taosdata",
+ AutoOffsetReset = "earliest"
+ MsgWithTableName = "true",
+ TDConnectIp = "127.0.0.1",
+ TDConnectPort = "6030"
+ };
+
+var consumer = new ConsumerBuilder(cfg).Build();
+
+```
+
+
+
+
+
+A consumer group is automatically created when multiple consumers are configured with the same consumer group ID.
+
+## Subscribe to a Topic
+
+A single consumer can subscribe to multiple topics.
+
+
+
+
+```c
+// Create a list of subscribed topics
+tmq_list_t* topicList = tmq_list_new();
+tmq_list_append(topicList, "topicName");
+// Enable subscription
+tmq_subscribe(tmq, topicList);
+tmq_list_destroy(topicList);
+
+```
+
+
+
+
+```java
+List topics = new ArrayList<>();
+topics.add("tmq_topic");
+consumer.subscribe(topics);
+```
+
+
+
+
+```go
+consumer, err := tmq.NewConsumer(config)
+if err != nil {
+ panic(err)
+}
+err = consumer.Subscribe([]string{"example_tmq_topic"})
+if err != nil {
+ panic(err)
+}
+```
+
+
+
+
+```rust
+consumer.subscribe(["tmq_meters"]).await?;
+```
+
+
+
+
+
+```python
+consumer = TaosConsumer('topic_ctb_column', group_id='vg2')
+```
+
+
+
+
+
+```js
+// Create a list of subscribed topics
+let topics = ['topic_test']
+
+// Enable subscription
+consumer.subscribe(topics);
+```
+
+
+
+
+
+```csharp
+// Create a list of subscribed topics
+List topics = new List();
+topics.add("tmq_topic");
+// Enable subscription
+consumer.Subscribe(topics);
+```
+
+
+
+
+
+## Consume messages
+
+The following code demonstrates how to consume the messages in a queue.
+
+
+
+
+```c
+## Consume data
+while (running) {
+ TAOS_RES* msg = tmq_consumer_poll(tmq, timeOut);
+ msg_process(msg);
+}
+```
+
+The `while` loop obtains a message each time it calls `tmq_consumer_poll()`. This message is exactly the same as the result returned by a query, and the same deserialization API can be used on it.
+
+
+
+
+```java
+while(running){
+ ConsumerRecords meters = consumer.poll(Duration.ofMillis(100));
+ for (Meters meter : meters) {
+ processMsg(meter);
+ }
+}
+```
+
+
+
+
+
+```go
+for {
+ result, err := consumer.Poll(time.Second)
+ if err != nil {
+ panic(err)
+ }
+ fmt.Println(result)
+ consumer.Commit(context.Background(), result.Message)
+ consumer.FreeMessage(result.Message)
+}
+```
+
+
+
+
+
+```rust
+{
+ let mut stream = consumer.stream();
+
+ while let Some((offset, message)) = stream.try_next().await? {
+ // get information from offset
+
+ // the topic
+ let topic = offset.topic();
+ // the vgroup id, like partition id in kafka.
+ let vgroup_id = offset.vgroup_id();
+ println!("* in vgroup id {vgroup_id} of topic {topic}\n");
+
+ if let Some(data) = message.into_data() {
+ while let Some(block) = data.fetch_raw_block().await? {
+ // one block for one table, get table name if needed
+ let name = block.table_name();
+ let records: Vec = block.deserialize().try_collect()?;
+ println!(
+ "** table: {}, got {} records: {:#?}\n",
+ name.unwrap(),
+ records.len(),
+ records
+ );
+ }
+ }
+ consumer.commit(offset).await?;
+ }
+}
+```
+
+
+
+
+```python
+for msg in consumer:
+ for row in msg:
+ print(row)
+```
+
+
+
+
+
+```js
+while(true){
+ msg = consumer.consume(200);
+ // process message(consumeResult)
+ console.log(msg.topicPartition);
+ console.log(msg.block);
+ console.log(msg.fields)
+}
+```
+
+
+
+
+
+```csharp
+## Consume data
+while (true)
+{
+ var consumerRes = consumer.Consume(100);
+ // process ConsumeResult
+ ProcessMsg(consumerRes);
+ consumer.Commit(consumerRes);
+}
+```
+
+
+
+
+
+## Close the consumer
+
+After message consumption is finished, the consumer is unsubscribed.
+
+
+
+
+```c
+/* Unsubscribe */
+tmq_unsubscribe(tmq);
+
+/* Close consumer object */
+tmq_consumer_close(tmq);
+```
+
+
+
+
+```java
+/* Unsubscribe */
+consumer.unsubscribe();
+
+/* Close consumer */
+consumer.close();
+```
+
+
+
+
+
+```go
+consumer.Close()
+```
+
+
+
+
+
+```rust
+consumer.unsubscribe().await;
+```
+
+
+
+
+
+```py
+# Unsubscribe
+consumer.unsubscribe()
+# Close consumer
+consumer.close()
+```
+
+
+
+
+```js
+consumer.unsubscribe();
+consumer.close();
+```
+
+
+
+
+
+```csharp
+// Unsubscribe
+consumer.Unsubscribe();
+
+// Close consumer
+consumer.Close();
+```
+
+
+
+
+
+## Delete a Topic
+
+You can delete topics that are no longer useful. Note that you must unsubscribe all consumers from a topic before deleting it.
+
+```sql
+/* Delete topic/
+DROP TOPIC topic_name;
+```
+
+## Check Status
+
+1. Query all existing topics.
+
+```sql
+SHOW TOPICS;
+```
+
+2. Query the status and subscribed topics of all consumers.
+
+```sql
+SHOW CONSUMERS;
+```
+
+3. Query the relationships between consumers and vgroups.
+
+```sql
+SHOW SUBSCRIPTIONS;
+```
+
+## Examples
+
+The following section shows sample code in various languages.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/en/07-develop/08-cache.md b/docs/en/07-develop/08-cache.md
index 8e86eff7414a02ad36a965eb092b8b9b65343301..82a4787016f608f8e32e89b1747443b7cd164551 100644
--- a/docs/en/07-develop/08-cache.md
+++ b/docs/en/07-develop/08-cache.md
@@ -1,52 +1,49 @@
---
-sidebar_label: Cache
-title: Cache
-description: "Caching System inside TDengine"
+sidebar_label: Caching
+title: Caching
+description: "This document describes the caching component of TDengine."
---
-To achieve the purpose of high performance data writing and querying, TDengine employs a lot of caching technologies in both server side and client side.
+TDengine uses various kinds of caching techniques to efficiently write and query data. This document describes the caching component of TDengine.
## Write Cache
-The cache management policy in TDengine is First-In-First-Out (FIFO). FIFO is also known as insert driven cache management policy and it is different from read driven cache management, which is more commonly known as Least-Recently-Used (LRU). FIFO simply stores the latest data in cache and flushes the oldest data in cache to disk, when the cache usage reaches a threshold. In IoT use cases, it is the current state i.e. the latest or most recent data that is important. The cache policy in TDengine, like much of the design and architecture of TDengine, is based on the nature of IoT data.
+TDengine uses an insert-driven cache management policy, known as first in, first out (FIFO). This policy differs from read-driven "least recently used (LRU)" cache management. A FIFO policy stores the latest data in cache and flushes the oldest data from cache to disk when the cache usage reaches a threshold. In IoT use cases, the most recent data or the current state is most important. The cache policy in TDengine, like much of the design and architecture of TDengine, is based on the nature of IoT data.
-The memory space used by each vnode as write cache is determined when creating a database. Parameter `vgroups` and `buffer` can be used to specify the number of vnode and the size of write cache for each vnode when creating the database. Then, the total size of write cache for this database is `vgroups * buffer`.
+When you create a database, you can configure the size of the write cache on each vnode. The **vgroups** parameter determines the number of vgroups that process data in the database, and the **buffer** parameter determines the size of the write cache for each vnode.
```sql
create database db0 vgroups 100 buffer 16MB
```
-The above statement creates a database of 100 vnodes while each vnode has a write cache of 16MB.
-
-Even though in theory it's always better to have a larger cache, the extra effect would be very minor once the size of cache grows beyond a threshold. So normally it's enough to use the default value of `buffer` parameter.
+In theory, larger cache sizes are always better. However, at a certain point, it becomes impossible to improve performance by increasing cache size. In most scenarios, you can retain the default cache settings.
## Read Cache
-When creating a database, it's also possible to specify whether to cache the latest data of each sub table, using parameter `cachelast`. There are 3 cases:
-- 0: No cache for latest data
-- 1: The last row of each table is cached, `last_row` function can benefit significantly from it
-- 2: The latest non-NULL value of each column for each table is cached, `last` function can benefit very much when there is no `where`, `group by`, `order by` or `interval` clause
-- 3: Bot hthe last row and the latest non-NULL value of each column for each table are cached, identical to the behavior of both 1 and 2 are set together
-
+When you create a database, you can configure whether the latest data from every subtable is cached. To do so, set the *cachemodel* parameter as follows:
+- none: Caching is disabled.
+- last_row: The latest row of data in each subtable is cached. This option significantly improves the performance of the `LAST_ROW` function
+- last_value: The latest non-null value in each column of each subtable is cached. This option significantly improves the performance of the `LAST` function in normal situations, such as WHERE, ORDER BY, GROUP BY, and INTERVAL statements.
+- both: Rows and columns are both cached. This option is equivalent to simultaneously enabling option last_row and last_value.
-## Meta Cache
+## Metadata Cache
-To process data writing and querying efficiently, each vnode caches the metadata that's already retrieved. Parameters `pages` and `pagesize` are used to specify the size of metadata cache for each vnode.
+To improve query and write performance, each vnode caches the metadata that it receives. When you create a database, you can configure the size of the metadata cache through the *pages* and *pagesize* parameters.
```sql
create database db0 pages 128 pagesize 16kb
```
-The above statement will create a database db0 each of whose vnode is allocated a meta cache of `128 * 16 KB = 2 MB` .
+The preceding SQL statement creates 128 pages on each vnode in the `db0` database. Each page has a 16 KB metadata cache.
## File System Cache
-TDengine utilizes WAL to provide basic reliability. The essential of WAL is to append data in a disk file, so the file system cache also plays an important role in the writing performance. Parameter `wal` can be used to specify the policy of writing WAL, there are 2 cases:
-- 1: Write data to WAL without calling fsync, the data is actually written to the file system cache without flushing immediately, in this way you can get better write performance
-- 2: Write data to WAL and invoke fsync, the data is immediately flushed to disk, in this way you can get higher reliability
+TDengine implements data reliability by means of a write-ahead log (WAL). Writing data to the WAL is essentially writing data to the disk in an ordered, append-only manner. For this reason, the file system cache plays an important role in write performance. When you create a database, you can use the *wal* parameter to choose higher performance or higher reliability.
+- 1: This option writes to the WAL but does not enable fsync. New data written to the WAL is stored in the file system cache but not written to disk. This provides better performance.
+- 2: This option writes to the WAL and enables fsync. New data written to the WAL is immediately written to disk. This provides better data reliability.
## Client Cache
-To improve the overall efficiency of processing data, besides the above caches, the core library `libtaos.so` (also referred to as `taosc`) which all client programs depend on also has its own cache. `taosc` caches the metadata of the databases, super tables, tables that the invoking client has accessed, plus other critical metadata such as the cluster topology.
+In addition to the server-side caching discussed previously, the core client library `libtaos.so` also makes use of caching. TDengine Client caches the metadata of all databases, supertables, and subtables that it has accessed, as well as the cluster topology.
-When multiple client programs are accessing a TDengine cluster, if one of the clients modifies some metadata, the cache may become invalid in other clients. If this case happens, the client programs need to "reset query cache" to invalidate the whole cache so that `taosc` is enforced to repull the metadata it needs to rebuild the cache.
+If a client modifies certain metadata while multiple clients are simultaneously accessing a TDengine cluster, the metadata caches on each client may fail or become out of sync. If this occurs, run the `reset query cache` command on the affected clientsto force them to obtain fresh metadata and reset their caches.
diff --git a/docs/en/07-develop/09-udf.md b/docs/en/07-develop/09-udf.md
index 49bc95bd91a4c31d42d2b21ef05d69225f1bd963..deb9c4cdb5b50edf7b48537f607ac47edc1246fd 100644
--- a/docs/en/07-develop/09-udf.md
+++ b/docs/en/07-develop/09-udf.md
@@ -1,240 +1,245 @@
---
sidebar_label: UDF
-title: User Defined Functions(UDF)
-description: "Scalar functions and aggregate functions developed by users can be utilized by the query framework to expand query capability"
+title: User-Defined Functions (UDF)
+description: "You can define your own scalar and aggregate functions to expand the query capabilities of TDengine."
---
-In some use cases, built-in functions are not adequate for the query capability required by application programs. With UDF, the functions developed by users can be utilized by the query framework to meet business and application requirements. UDF normally takes one column of data as input, but can also support the result of a sub-query as input.
+The built-in functions of TDengine may not be sufficient for the use cases of every application. In this case, you can define custom functions for use in TDengine queries. These are known as user-defined functions (UDF). A user-defined function takes one column of data or the result of a subquery as its input.
-From version 2.2.0.0, UDF written in C/C++ are supported by TDengine.
+TDengine supports user-defined functions written in C or C++. This document describes the usage of user-defined functions.
+User-defined functions can be scalar functions or aggregate functions. Scalar functions, such as `abs`, `sin`, and `concat`, output a value for every row of data. Aggregate functions, such as `avg` and `max` output one value for multiple rows of data.
-## Types of UDF
+When you create a user-defined function, you must implement standard interface functions:
+- For scalar functions, implement the `scalarfn` interface function.
+- For aggregate functions, implement the `aggfn_start`, `aggfn`, and `aggfn_finish` interface functions.
+- To initialize your function, implement the `udf_init` function. To terminate your function, implement the `udf_destroy` function.
-Two kinds of functions can be implemented by UDF: scalar functions and aggregate functions.
+There are strict naming conventions for these interface functions. The names of the start, finish, init, and destroy interfaces must be _start, _finish, _init, and _destroy, respectively. Replace `scalarfn`, `aggfn`, and `udf` with the name of your user-defined function.
-Scalar functions return multiple rows and aggregate functions return either 0 or 1 row.
-
-In the case of a scalar function you only have to implement the "normal" function template.
-
-In the case of an aggregate function, in addition to the "normal" function, you also need to implement the "merge" and "finalize" function templates even if the implementation is empty. This will become clear in the sections below.
-
-### Scalar Function
-
-As mentioned earlier, a scalar UDF only has to implement the "normal" function template. The function template below can be used to define your own scalar function.
-
-`void udfNormalFunc(char* data, short itype, short ibytes, int numOfRows, long long* ts, char* dataOutput, char* interBuf, char* tsOutput, int* numOfOutput, short otype, short obytes, SUdfInit* buf)`
-
-`udfNormalFunc` is the place holder for a function name. A function implemented based on the above template can be used to perform scalar computation on data rows. The parameters are fixed to control the data exchange between UDF and TDengine.
-
-- Definitions of the parameters:
-
- - data:input data
- - itype:the type of input data, for details please refer to [type definition in column_meta](/reference/rest-api/), for example 4 represents INT
- - iBytes:the number of bytes consumed by each value in the input data
- - oType:the type of output data, similar to iType
- - oBytes:the number of bytes consumed by each value in the output data
- - numOfRows:the number of rows in the input data
- - ts: the column of timestamp corresponding to the input data
- - dataOutput:the buffer for output data, total size is `oBytes * numberOfRows`
- - interBuf:the buffer for an intermediate result. Its size is specified by the `BUFSIZE` parameter when creating a UDF. It's normally used when the intermediate result is not same as the final result. This buffer is allocated and freed by TDengine.
- - tsOutput:the column of timestamps corresponding to the output data; it can be used to output timestamp together with the output data if it's not NULL
- - numOfOutput:the number of rows in output data
- - buf:for the state exchange between UDF and TDengine
+## Implementing a Scalar Function
+The implementation of a scalar function is described as follows:
+```c
+#include "taos.h"
+#include "taoserror.h"
+#include "taosudf.h"
+
+// initialization function. if no initialization, we can skip definition of it. The initialization function shall be concatenation of the udf name and _init suffix
+// @return error number defined in taoserror.h
+int32_t scalarfn_init() {
+ // initialization.
+ return TSDB_CODE_SUCCESS;
+}
+
+// scalar function main computation function
+// @param inputDataBlock, input data block composed of multiple columns with each column defined by SUdfColumn
+// @param resultColumn, output column
+// @return error number defined in taoserror.h
+int32_t scalarfn(SUdfDataBlock* inputDataBlock, SUdfColumn* resultColumn) {
+ // read data from inputDataBlock and process, then output to resultColumn.
+ return TSDB_CODE_SUCCESS;
+}
+
+// cleanup function. if no cleanup related processing, we can skip definition of it. The destroy function shall be concatenation of the udf name and _destroy suffix.
+// @return error number defined in taoserror.h
+int32_t scalarfn_destroy() {
+ // clean up
+ return TSDB_CODE_SUCCESS;
+}
+```
+Replace `scalarfn` with the name of your function.
- [add_one.c](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/add_one.c) is one example of a very simple UDF implementation, i.e. one instance of the above `udfNormalFunc` template. It adds one to each value of a passed in column, which can be filtered using the `where` clause, and outputs the result.
+## Implementing an Aggregate Function
-### Aggregate Function
+The implementation of an aggregate function is described as follows:
+```c
+#include "taos.h"
+#include "taoserror.h"
+#include "taosudf.h"
+
+// Initialization function. if no initialization, we can skip definition of it. The initialization function shall be concatenation of the udf name and _init suffix
+// @return error number defined in taoserror.h
+int32_t aggfn_init() {
+ // initialization.
+ return TSDB_CODE_SUCCESS;
+}
+
+// aggregate start function. The intermediate value or the state(@interBuf) is initialized in this function. The function name shall be concatenation of udf name and _start suffix
+// @param interbuf intermediate value to intialize
+// @return error number defined in taoserror.h
+int32_t aggfn_start(SUdfInterBuf* interBuf) {
+ // initialize intermediate value in interBuf
+ return TSDB_CODE_SUCESS;
+}
+
+// aggregate reduce function. This function aggregate old state(@interbuf) and one data bock(inputBlock) and output a new state(@newInterBuf).
+// @param inputBlock input data block
+// @param interBuf old state
+// @param newInterBuf new state
+// @return error number defined in taoserror.h
+int32_t aggfn(SUdfDataBlock* inputBlock, SUdfInterBuf *interBuf, SUdfInterBuf *newInterBuf) {
+ // read from inputBlock and interBuf and output to newInterBuf
+ return TSDB_CODE_SUCCESS;
+}
+
+// aggregate function finish function. This function transforms the intermediate value(@interBuf) into the final output(@result). The function name must be concatenation of aggfn and _finish suffix.
+// @interBuf : intermediate value
+// @result: final result
+// @return error number defined in taoserror.h
+int32_t int32_t aggfn_finish(SUdfInterBuf* interBuf, SUdfInterBuf *result) {
+ // read data from inputDataBlock and process, then output to result
+ return TSDB_CODE_SUCCESS;
+}
+
+// cleanup function. if no cleanup related processing, we can skip definition of it. The destroy function shall be concatenation of the udf name and _destroy suffix.
+// @return error number defined in taoserror.h
+int32_t aggfn_destroy() {
+ // clean up
+ return TSDB_CODE_SUCCESS;
+}
+```
+Replace `aggfn` with the name of your function.
-For aggregate UDF, as mentioned earlier you must implement a "normal" function template (described above) and also implement the "merge" and "finalize" templates.
+## Interface Functions
-#### Merge Function Template
+There are strict naming conventions for interface functions. The names of the start, finish, init, and destroy interfaces must be _start, _finish, _init, and _destroy, respectively. Replace `scalarfn`, `aggfn`, and `udf` with the name of your user-defined function.
-The function template below can be used to define your own merge function for an aggregate UDF.
+Interface functions return a value that indicates whether the operation was successful. If an operation fails, the interface function returns an error code. Otherwise, it returns TSDB_CODE_SUCCESS. The error codes are defined in `taoserror.h` and in the common API error codes in `taos.h`. For example, TSDB_CODE_UDF_INVALID_INPUT indicates invalid input. TSDB_CODE_OUT_OF_MEMORY indicates insufficient memory.
-`void udfMergeFunc(char* data, int32_t numOfRows, char* dataOutput, int32_t* numOfOutput, SUdfInit* buf)`
+For information about the parameters for interface functions, see Data Model
-`udfMergeFunc` is the place holder for a function name. The function implemented with the above template is used to aggregate intermediate results and can only be used in the aggregate query for STable.
+### Interfaces for Scalar Functions
-Definitions of the parameters:
+ `int32_t scalarfn(SUdfDataBlock* inputDataBlock, SUdfColumn *resultColumn)`
+
+ Replace `scalarfn` with the name of your function. This function performs scalar calculations on data blocks. You can configure a value through the parameters in the `resultColumn` structure.
-- data:array of output data, if interBuf is used it's an array of interBuf
-- numOfRows:number of rows in `data`
-- dataOutput:the buffer for output data, the size is same as that of the final result; If the result is not final, it can be put in the interBuf, i.e. `data`.
-- numOfOutput:number of rows in the output data
-- buf:for the state exchange between UDF and TDengine
+The parameters in the function are defined as follows:
+ - inputDataBlock: The data block to input.
+ - resultColumn: The column to output. The column to output.
-#### Finalize Function Template
+### Interfaces for Aggregate Functions
-The function template below can be used to finalize the result of your own UDF, normally used when interBuf is used.
+`int32_t aggfn_start(SUdfInterBuf *interBuf)`
-`void udfFinalizeFunc(char* dataOutput, char* interBuf, int* numOfOutput, SUdfInit* buf)`
+`int32_t aggfn(SUdfDataBlock* inputBlock, SUdfInterBuf *interBuf, SUdfInterBuf *newInterBuf)`
-`udfFinalizeFunc` is the place holder of function name, definitions of the parameter are as below:
+`int32_t aggfn_finish(SUdfInterBuf* interBuf, SUdfInterBuf *result)`
-- dataOutput:buffer for output data
-- interBuf:buffer for intermediate result, can be used as input for next processing step
-- numOfOutput:number of output data, can only be 0 or 1 for aggregate function
-- buf:for state exchange between UDF and TDengine
+Replace `aggfn` with the name of your function. In the function, aggfn_start is called to generate a result buffer. Data is then divided between multiple blocks, and aggfn is called on each block to update the result. Finally, aggfn_finish is called to generate final results from the intermediate results. The final result contains only one or zero data points.
-### Example abs_max.c
+The parameters in the function are defined as follows:
+ - interBuf: The intermediate result buffer.
+ - inputBlock: The data block to input.
+ - newInterBuf: The new intermediate result buffer.
+ - result: The final result.
-[abs_max.c](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/abs_max.c) is an example of a user defined aggregate function to get the maximum from the absolute values of a column.
-The internal processing happens as follows. The results of the select statement are divided into multiple row blocks and `udfNormalFunc`, i.e. `abs_max` in this case, is performed on each row block to generate the intermediate results for each sub table. Then `udfMergeFunc`, i.e. `abs_max_merge` in this case, is performed on the intermediate result of sub tables to aggregate and generate the final or intermediate result of STable. The intermediate result of STable is finally processed by `udfFinalizeFunc`, i.e. `abs_max_finalize` in this example, to generate the final result, which contains either 0 or 1 row.
+### Initializing and Terminating User-Defined Functions
+`int32_t udf_init()`
-Other typical aggregation functions such as covariance, can also be implemented using aggregate UDF.
+`int32_t udf_destroy()`
-## UDF Naming Conventions
+Replace `udf`with the name of your function. udf_init initializes the function. udf_destroy terminates the function. If it is not necessary to initialize your function, udf_init is not required. If it is not necessary to terminate your function, udf_destroy is not required.
-The naming convention for the 3 kinds of function templates required by UDF is as follows:
- - udfNormalFunc, udfMergeFunc, and udfFinalizeFunc are required to have same prefix, i.e. the actual name of udfNormalFunc. The udfNormalFunc doesn't need a suffix following the function name.
- - udfMergeFunc should be udfNormalFunc followed by `_merge`
- - udfFinalizeFunc should be udfNormalFunc followed by `_finalize`.
-
-The naming convention is part of TDengine's UDF framework. TDengine follows this convention to invoke the corresponding actual functions.
-Depending on whether you are creating a scalar UDF or aggregate UDF, the functions that you need to implement are different.
+## Data Structure of User-Defined Functions
+```c
+typedef struct SUdfColumnMeta {
+ int16_t type;
+ int32_t bytes;
+ uint8_t precision;
+ uint8_t scale;
+} SUdfColumnMeta;
+
+typedef struct SUdfColumnData {
+ int32_t numOfRows;
+ int32_t rowsAlloc;
+ union {
+ struct {
+ int32_t nullBitmapLen;
+ char *nullBitmap;
+ int32_t dataLen;
+ char *data;
+ } fixLenCol;
+
+ struct {
+ int32_t varOffsetsLen;
+ int32_t *varOffsets;
+ int32_t payloadLen;
+ char *payload;
+ int32_t payloadAllocLen;
+ } varLenCol;
+ };
+} SUdfColumnData;
+
+typedef struct SUdfColumn {
+ SUdfColumnMeta colMeta;
+ bool hasNull;
+ SUdfColumnData colData;
+} SUdfColumn;
+
+typedef struct SUdfDataBlock {
+ int32_t numOfRows;
+ int32_t numOfCols;
+ SUdfColumn **udfCols;
+} SUdfDataBlock;
+
+typedef struct SUdfInterBuf {
+ int32_t bufLen;
+ char* buf;
+ int8_t numOfResult; //zero or one
+} SUdfInterBuf;
+```
+The data structure is described as follows:
-- Scalar function:udfNormalFunc is required.
-- Aggregate function:udfNormalFunc, udfMergeFunc (if query on STable) and udfFinalizeFunc are required.
+- The SUdfDataBlock block includes the number of rows (numOfRows) and number of columns (numCols). udfCols[i] (0 <= i <= numCols-1) indicates that each column is of type SUdfColumn.
+- SUdfColumn includes the definition of the data type of the column (colMeta) and the data in the column (colData).
+- The member definitions of SUdfColumnMeta are the same as the data type definitions in `taos.h`.
+- The data in SUdfColumnData can become longer. varLenCol indicates variable-length data, and fixLenCol indicates fixed-length data.
+- SUdfInterBuf defines the intermediate structure `buffer` and the number of results in the buffer `numOfResult`.
-For clarity, assuming we want to implement a UDF named "foo":
-- If the function is a scalar function, we only need to implement the "normal" function template and it should be named simply `foo`.
-- If the function is an aggregate function, we need to implement `foo`, `foo_merge`, and `foo_finalize`. Note that for aggregate UDF, even though one of the three functions is not necessary, there must be an empty implementation.
+Additional functions are defined in `taosudf.h` to make it easier to work with these structures.
## Compile UDF
-The source code of UDF in C can't be utilized by TDengine directly. UDF can only be loaded into TDengine after compiling to dynamically linked library (DLL).
+To use your user-defined function in TDengine, first compile it to a dynamically linked library (DLL).
-For example, the example UDF `add_one.c` mentioned earlier, can be compiled into DLL using the command below, in a Linux Shell.
+For example, the sample UDF `add_one.c` can be compiled into a DLL as follows:
```bash
gcc -g -O0 -fPIC -shared add_one.c -o add_one.so
```
-The generated DLL file `add_one.so` can be used later when creating a UDF. It's recommended to use GCC not older than 7.5.
-
-## Create and Use UDF
-
-When a UDF is created in a TDengine instance, it is available across the databases in that instance.
-
-### Create UDF
-
-SQL command can be executed on the host where the generated UDF DLL resides to load the UDF DLL into TDengine. This operation cannot be done through REST interface or web console. Once created, any client of the current TDengine can use these UDF functions in their SQL commands. UDF are stored in the management node of TDengine. The UDFs loaded in TDengine would be still available after TDengine is restarted.
-
-When creating UDF, the type of UDF, i.e. a scalar function or aggregate function must be specified. If the specified type is wrong, the SQL statements using the function would fail with errors. The input type and output type don't need to be the same in UDF, but the input data type and output data type must be consistent with the UDF definition.
-
-- Create Scalar Function
-
-```sql
-CREATE FUNCTION userDefinedFunctionName AS "/absolute/path/to/userDefinedFunctionName.so" OUTPUTTYPE [BUFSIZE B];
-```
-
-- userDefinedFunctionName:The function name to be used in SQL statement which must be consistent with the function name defined by `udfNormalFunc` and is also the name of the compiled DLL (.so file).
-- path:The absolute path of the DLL file including the name of the shared object file (.so). The path must be quoted with single or double quotes.
-- outputtype:The output data type, the value is the literal string of the supported TDengine data type.
-- B:the size of intermediate buffer, in bytes; it is an optional parameter and the range is [0,512].
-
-For example, below SQL statement can be used to create a UDF from `add_one.so`.
-
-```sql
-CREATE FUNCTION add_one AS "/home/taos/udf_example/add_one.so" OUTPUTTYPE INT;
-```
-
-- Create Aggregate Function
-
-```sql
-CREATE AGGREGATE FUNCTION userDefinedFunctionName AS "/absolute/path/to/userDefinedFunctionName.so" OUTPUTTYPE [ BUFSIZE B ];
-```
-
-- userDefinedFunctionName:the function name to be used in SQL statement which must be consistent with the function name defined by `udfNormalFunc` and is also the name of the compiled DLL (.so file).
-- path:the absolute path of the DLL file including the name of the shared object file (.so). The path needs to be quoted by single or double quotes.
-- OUTPUTTYPE:the output data type, the value is the literal string of the type
-- B:the size of intermediate buffer, in bytes; it's an optional parameter and the range is [0,512]
-
-For details about how to use intermediate result, please refer to example program [demo.c](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/demo.c).
-
-For example, below SQL statement can be used to create a UDF from `demo.so`.
-
-```sql
-CREATE AGGREGATE FUNCTION demo AS "/home/taos/udf_example/demo.so" OUTPUTTYPE DOUBLE bufsize 14;
-```
-
-### Manage UDF
-
-- Delete UDF
-
-```
-DROP FUNCTION ids(X);
-```
-
-- ids(X):same as that in `CREATE FUNCTION` statement
-
-```sql
-DROP FUNCTION add_one;
-```
-
-- Show Available UDF
+The generated DLL file `add_one.so` can now be used to implement your function. Note: GCC 7.5 or later is required.
-```sql
-SHOW FUNCTIONS;
-```
-
-### Use UDF
-
-The function name specified when creating UDF can be used directly in SQL statements, just like builtin functions.
-
-```sql
-SELECT X(c) FROM table/STable;
-```
-
-The above SQL statement invokes function X for column c.
-
-## Restrictions for UDF
-
-In current version there are some restrictions for UDF
+## Manage and Use User-Defined Functions
+After compiling your function into a DLL, you add it to TDengine. For more information, see [User-Defined Functions](../12-taos-sql/26-udf.md).
-1. Only Linux is supported when creating and invoking UDF for both client side and server side
-2. UDF can't be mixed with builtin functions
-3. Only one UDF can be used in a SQL statement
-4. Only a single column is supported as input for UDF
-5. Once created successfully, UDF is persisted in MNode of TDengineUDF
-6. UDF can't be created through REST interface
-7. The function name used when creating UDF in SQL must be consistent with the function name defined in the DLL, i.e. the name defined by `udfNormalFunc`
-8. The name of a UDF should not conflict with any of TDengine's built-in functions
+## Sample Code
-## Examples
+### Sample scalar function: [bit_and](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/bit_and.c)
-### Scalar function example [add_one](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/add_one.c)
+The bit_add function implements bitwise addition for multiple columns. If there is only one column, the column is returned. The bit_add function ignores null values.
-add_one.c
+bit_and.c
```c
-{{#include tests/script/sh/add_one.c}}
+{{#include tests/script/sh/bit_and.c}}
```
-### Aggregate function example [abs_max](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/abs_max.c)
-
-
-abs_max.c
-
-```c
-{{#include tests/script/sh/abs_max.c}}
-```
-
-
+### Sample aggregate function: [l2norm](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/l2norm.c)
-### Example for using intermediate result [demo](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/demo.c)
+The l2norm function finds the second-order norm for all data in the input column. This squares the values, takes a cumulative sum, and finds the square root.
-demo.c
+l2norm.c
```c
-{{#include tests/script/sh/demo.c}}
+{{#include tests/script/sh/l2norm.c}}
```
diff --git a/docs/en/07-develop/_sub_c.mdx b/docs/en/07-develop/_sub_c.mdx
index da492a0269f064d8cdf9dfb80969894131d94015..b0667268e9978533e84e68ea3fe5f285538df762 100644
--- a/docs/en/07-develop/_sub_c.mdx
+++ b/docs/en/07-develop/_sub_c.mdx
@@ -1,3 +1,3 @@
```c
-{{#include docs/examples/c/subscribe_demo.c}}
-```
\ No newline at end of file
+{{#include docs/examples/c/tmq_example.c}}
+```
diff --git a/docs/en/07-develop/_sub_java.mdx b/docs/en/07-develop/_sub_java.mdx
index ab77f61348c115d3fe3336df47d467c5525f41b8..d14b5fd6095dd90f89dd2c2e828858585cfddff9 100644
--- a/docs/en/07-develop/_sub_java.mdx
+++ b/docs/en/07-develop/_sub_java.mdx
@@ -1,7 +1,11 @@
```java
{{#include docs/examples/java/src/main/java/com/taos/example/SubscribeDemo.java}}
+{{#include docs/examples/java/src/main/java/com/taos/example/MetersDeserializer.java}}
+{{#include docs/examples/java/src/main/java/com/taos/example/Meters.java}}
```
-:::note
-For now Java connector doesn't provide asynchronous subscription, but `TimerTask` can be used to achieve similar purpose.
-
-:::
\ No newline at end of file
+```java
+{{#include docs/examples/java/src/main/java/com/taos/example/MetersDeserializer.java}}
+```
+```java
+{{#include docs/examples/java/src/main/java/com/taos/example/Meters.java}}
+```
\ No newline at end of file
diff --git a/docs/en/07-develop/_sub_python.mdx b/docs/en/07-develop/_sub_python.mdx
index 490b76fca6deb61e61dc59c2096b30742a7d25f7..1309da5b416799492a6b85aae4b775e227c0ad6e 100644
--- a/docs/en/07-develop/_sub_python.mdx
+++ b/docs/en/07-develop/_sub_python.mdx
@@ -1,3 +1,3 @@
```py
-{{#include docs/examples/python/subscribe_demo.py}}
-```
\ No newline at end of file
+{{#include docs/examples/python/tmq_example.py}}
+```
diff --git a/docs/en/07-develop/_sub_rust.mdx b/docs/en/07-develop/_sub_rust.mdx
index afb8d79daa3bbd72d72795cb4425f12277d710fc..0021666a7024a9b63d6b9c38bf8a57b6eded6d66 100644
--- a/docs/en/07-develop/_sub_rust.mdx
+++ b/docs/en/07-develop/_sub_rust.mdx
@@ -1,3 +1,3 @@
-```rs
+```rust
{{#include docs/examples/rust/nativeexample/examples/subscribe_demo.rs}}
-```
\ No newline at end of file
+```
diff --git a/docs/en/07-develop/index.md b/docs/en/07-develop/index.md
index e3f55f290753f79ac1708337082ce90bb050b21f..1ef5e23f72f707f7a9decce6ea0bfed8fd642c0c 100644
--- a/docs/en/07-develop/index.md
+++ b/docs/en/07-develop/index.md
@@ -2,13 +2,12 @@
title: Developer Guide
---
-To develop an application to process time-series data using TDengine, we recommend taking the following steps:
-
-1. Choose the method to connect to TDengine. No matter what programming language you use, you can always use the REST interface to access TDengine, but you can also use connectors unique to each programming language.
-2. Design the data model based on your own use cases. Learn the [concepts](/concept/) of TDengine including "one table for one data collection point" and the "super table" (STable) concept; learn about static labels, collected metrics, and subtables. Depending on the characteristics of your data and your requirements, you may decide to create one or more databases, and you should design the STable schema to fit your data.
+Before creating an application to process time-series data with TDengine, consider the following:
+1. Choose the method to connect to TDengine. TDengine offers a REST API that can be used with any programming language. It also has connectors for a variety of languages.
+2. Design the data model based on your own use cases. Consider the main [concepts](/concept/) of TDengine, including "one table per data collection point" and the supertable. Learn about static labels, collected metrics, and subtables. Depending on the characteristics of your data and your requirements, you decide to create one or more databases and design a supertable schema that fit your data.
3. Decide how you will insert data. TDengine supports writing using standard SQL, but also supports schemaless writing, so that data can be written directly without creating tables manually.
4. Based on business requirements, find out what SQL query statements need to be written. You may be able to repurpose any existing SQL.
-5. If you want to run real-time analysis based on time series data, including various dashboards, it is recommended that you use the TDengine continuous query feature instead of deploying complex streaming processing systems such as Spark or Flink.
+5. If you want to run real-time analysis based on time series data, including various dashboards, use the TDengine stream processing component instead of deploying complex systems such as Spark or Flink.
6. If your application has modules that need to consume inserted data, and they need to be notified when new data is inserted, it is recommended that you use the data subscription function provided by TDengine without the need to deploy Kafka.
7. In many use cases (such as fleet management), the application needs to obtain the latest status of each data collection point. It is recommended that you use the cache function of TDengine instead of deploying Redis separately.
8. If you find that the SQL functions of TDengine cannot meet your requirements, then you can use user-defined functions to solve the problem.
diff --git a/docs/en/10-cluster/01-deploy.md b/docs/en/10-cluster/01-deploy.md
deleted file mode 100644
index d998fd6ad0061ae2585e2155703bf5895ab6787d..0000000000000000000000000000000000000000
--- a/docs/en/10-cluster/01-deploy.md
+++ /dev/null
@@ -1,126 +0,0 @@
----
-title: Deployment
----
-
-## Prerequisites
-
-### Step 1
-
-The FQDN of all hosts must be setup properly. All FQDNs need to be configured in the /etc/hosts file on each host. You must confirm that each FQDN can be accessed from any other host, you can do this by using the `ping` command.
-
-The command `hostname -f` can be executed to get the hostname on any host. `ping ` command can be executed on each host to check whether any other host is accessible from it. If any host is not accessible, the network configuration, like /etc/hosts or DNS configuration, needs to be checked and revised, to make any two hosts accessible to each other.
-
-:::note
-
-- The host where the client program runs also needs to be configured properly for FQDN, to make sure all hosts for client or server can be accessed from any other. In other words, the hosts where the client is running are also considered as a part of the cluster.
-
-- Please ensure that your firewall rules do not block TCP/UDP on ports 6030-6042 on all hosts in the cluster.
-
-:::
-
-### Step 2
-
-If any previous version of TDengine has been installed and configured on any host, the installation needs to be removed and the data needs to be cleaned up. For details about uninstalling please refer to [Install and Uninstall](/operation/pkg-install). To clean up the data, please use `rm -rf /var/lib/taos/\*` assuming the `dataDir` is configured as `/var/lib/taos`.
-
-:::note
-
-As a best practice, before cleaning up any data files or directories, please ensure that your data has been backed up correctly, if required by your data integrity, backup, security, or other standard operating protocols (SOP).
-
-:::
-
-### Step 3
-
-Now it's time to install TDengine on all hosts but without starting `taosd`. Note that the versions on all hosts should be same. If you are prompted to input the existing TDengine cluster, simply press carriage return to ignore the prompt. `install.sh -e no` can also be used to disable this prompt. For details please refer to [Install and Uninstall](/operation/pkg-install).
-
-### Step 4
-
-Now each physical node (referred to, hereinafter, as `dnode` which is an abbreviation for "data node") of TDengine needs to be configured properly. Please note that one dnode doesn't stand for one host. Multiple TDengine dnodes can be started on a single host as long as they are configured properly without conflicting. More specifically each instance of the configuration file `taos.cfg` stands for a dnode. Assuming the first dnode of TDengine cluster is "h1.taosdata.com:6030", its `taos.cfg` is configured as following.
-
-```c
-// firstEp is the end point to connect to when any dnode starts
-firstEp h1.taosdata.com:6030
-
-// must be configured to the FQDN of the host where the dnode is launched
-fqdn h1.taosdata.com
-
-// the port used by the dnode, default is 6030
-serverPort 6030
-
-// only necessary when replica is configured to an even number
-#arbitrator ha.taosdata.com:6042
-```
-
-`firstEp` and `fqdn` must be configured properly. In `taos.cfg` of all dnodes in TDengine cluster, `firstEp` must be configured to point to same address, i.e. the first dnode of the cluster. `fqdn` and `serverPort` compose the address of each node itself. If you want to start multiple TDengine dnodes on a single host, please make sure all other configurations like `dataDir`, `logDir`, and other resources related parameters are not conflicting.
-
-For all the dnodes in a TDengine cluster, the below parameters must be configured exactly the same, any node whose configuration is different from dnodes already in the cluster can't join the cluster.
-
-| **#** | **Parameter** | **Definition** |
-| ----- | -------------- | ------------------------------------------------------------- |
-| 1 | statusInterval | The time interval for which dnode reports its status to mnode |
-| 2 | timezone | Time Zone where the server is located |
-| 3 | locale | Location code of the system |
-| 4 | charset | Character set of the system |
-
-## Start Cluster
-
-In the following example we assume that first dnode has FQDN h1.taosdata.com and the second dnode has FQDN h2.taosdata.com.
-
-### Start The First DNODE
-
-Start the first dnode following the instructions in [Get Started](/get-started/). Then launch TDengine CLI `taos` and execute command `show dnodes`, the output is as following for example:
-
-```
-Welcome to the TDengine shell from Linux, Client Version:3.0.0.0
-Copyright (c) 2022 by TAOS Data, Inc. All rights reserved.
-
-Server is Enterprise trial Edition, ver:3.0.0.0 and will never expire.
-
-taos> show dnodes;
- id | endpoint | vnodes | support_vnodes | status | create_time | note |
-============================================================================================================================================
- 1 | h1.taosdata.com:6030 | 0 | 1024 | ready | 2022-07-16 10:50:42.673 | |
-Query OK, 1 rows affected (0.007984s)
-
-taos>
-```
-
-From the above output, it is shown that the end point of the started dnode is "h1.taosdata.com:6030", which is the `firstEp` of the cluster.
-
-### Start Other DNODEs
-
-There are a few steps necessary to add other dnodes in the cluster.
-
-Let's assume we are starting the second dnode with FQDN, h2.taosdata.com. Firstly we make sure the configuration is correct.
-
-```c
-// firstEp is the end point to connect to when any dnode starts
-firstEp h1.taosdata.com:6030
-
-// must be configured to the FQDN of the host where the dnode is launched
-fqdn h2.taosdata.com
-
-// the port used by the dnode, default is 6030
-serverPort 6030
-
-```
-
-Secondly, we can start `taosd` as instructed in [Get Started](/get-started/).
-
-Then, on the first dnode i.e. h1.taosdata.com in our example, use TDengine CLI `taos` to execute the following command to add the end point of the dnode in the cluster. In the command "fqdn:port" should be quoted using double quotes.
-
-```sql
-CREATE DNODE "h2.taos.com:6030";
-```
-
-Then on the first dnode h1.taosdata.com, execute `show dnodes` in `taos` to show whether the second dnode has been added in the cluster successfully or not.
-
-```sql
-SHOW DNODES;
-```
-
-If the status of the newly added dnode is offline, please check:
-
-- Whether the `taosd` process is running properly or not
-- In the log file `taosdlog.0` to see whether the fqdn and port are correct
-
-The above process can be repeated to add more dnodes in the cluster.
diff --git a/docs/en/10-cluster/02-cluster-mgmt.md b/docs/en/10-cluster/02-cluster-mgmt.md
deleted file mode 100644
index 19ee034127364469931391257073ecbd6bc5507b..0000000000000000000000000000000000000000
--- a/docs/en/10-cluster/02-cluster-mgmt.md
+++ /dev/null
@@ -1,138 +0,0 @@
----
-sidebar_label: Operation
-title: Manage DNODEs
----
-
-The previous section, [Deployment],(/cluster/deploy) showed you how to deploy and start a cluster from scratch. Once a cluster is ready, the status of dnode(s) in the cluster can be shown at any time. Dnodes can be managed from the TDengine CLI. New dnode(s) can be added to scale out the cluster, an existing dnode can be removed and you can even perform load balancing manually, if necessary.
-
-:::note
-All the commands introduced in this chapter must be run in the TDengine CLI - `taos`. Note that sometimes it is necessary to use root privilege.
-
-:::
-
-## Show DNODEs
-
-The below command can be executed in TDengine CLI `taos` to list all dnodes in the cluster, including ID, end point (fqdn:port), status (ready, offline), number of vnodes, number of free vnodes and so on. We recommend executing this command after adding or removing a dnode.
-
-```sql
-SHOW DNODES;
-```
-
-Below is the example output of this command.
-
-```
-taos> show dnodes;
- id | end_point | vnodes | cores | status | role | create_time | offline reason |
-======================================================================================================================================
- 1 | localhost:6030 | 9 | 8 | ready | any | 2022-04-15 08:27:09.359 | |
-Query OK, 1 row(s) in set (0.008298s)
-```
-
-## Show VGROUPs
-
-To utilize system resources efficiently and provide scalability, data sharding is required. The data of each database is divided into multiple shards and stored in multiple vnodes. These vnodes may be located on different dnodes. One way of scaling out is to add more vnodes on dnodes. Each vnode can only be used for a single DB, but one DB can have multiple vnodes. The allocation of vnode is scheduled automatically by mnode based on system resources of the dnodes.
-
-Launch TDengine CLI `taos` and execute below command:
-
-```sql
-USE SOME_DATABASE;
-SHOW VGROUPS;
-```
-
-The output is like below:
-
-taos> use db;
-Database changed.
-
-taos> show vgroups;
-vgId | tables | status | onlines | v1_dnode | v1_status | compacting |
-==========================================================================================
-14 | 38000 | ready | 1 | 1 | leader | 0 |
-15 | 38000 | ready | 1 | 1 | leader | 0 |
-16 | 38000 | ready | 1 | 1 | leader | 0 |
-17 | 38000 | ready | 1 | 1 | leader | 0 |
-18 | 37001 | ready | 1 | 1 | leader | 0 |
-19 | 37000 | ready | 1 | 1 | leader | 0 |
-20 | 37000 | ready | 1 | 1 | leader | 0 |
-21 | 37000 | ready | 1 | 1 | leader | 0 |
-Query OK, 8 row(s) in set (0.001154s)
-
-````
-
-## Add DNODE
-
-Launch TDengine CLI `taos` and execute the command below to add the end point of a new dnode into the EPI (end point) list of the cluster. "fqdn:port" must be quoted using double quotes.
-
-```sql
-CREATE DNODE "fqdn:port";
-````
-
-The example output is as below:
-
-```
-taos> create dnode "localhost:7030";
-Query OK, 0 of 0 row(s) in database (0.008203s)
-
-taos> show dnodes;
- id | end_point | vnodes | cores | status | role | create_time | offline reason |
-======================================================================================================================================
- 1 | localhost:6030 | 9 | 8 | ready | any | 2022-04-15 08:27:09.359 | |
- 2 | localhost:7030 | 0 | 0 | offline | any | 2022-04-19 08:11:42.158 | status not received |
-Query OK, 2 row(s) in set (0.001017s)
-```
-
-It can be seen that the status of the new dnode is "offline". Once the dnode is started and connects to the firstEp of the cluster, you can execute the command again and get the example output below. As can be seen, both dnodes are in "ready" status.
-
-```
-taos> show dnodes;
- id | end_point | vnodes | cores | status | role | create_time | offline reason |
-======================================================================================================================================
- 1 | localhost:6030 | 3 | 8 | ready | any | 2022-04-15 08:27:09.359 | |
- 2 | localhost:7030 | 6 | 8 | ready | any | 2022-04-19 08:14:59.165 | |
-Query OK, 2 row(s) in set (0.001316s)
-```
-
-## Drop DNODE
-
-Launch TDengine CLI `taos` and execute the command below to drop or remove a dnode from the cluster. In the command, you can get `dnodeId` from `show dnodes`.
-
-```sql
-DROP DNODE "fqdn:port";
-```
-
-or
-
-```sql
-DROP DNODE dnodeId;
-```
-
-The example output is below:
-
-```
-taos> show dnodes;
- id | end_point | vnodes | cores | status | role | create_time | offline reason |
-======================================================================================================================================
- 1 | localhost:6030 | 9 | 8 | ready | any | 2022-04-15 08:27:09.359 | |
- 2 | localhost:7030 | 0 | 0 | offline | any | 2022-04-19 08:11:42.158 | status not received |
-Query OK, 2 row(s) in set (0.001017s)
-
-taos> drop dnode 2;
-Query OK, 0 of 0 row(s) in database (0.000518s)
-
-taos> show dnodes;
- id | end_point | vnodes | cores | status | role | create_time | offline reason |
-======================================================================================================================================
- 1 | localhost:6030 | 9 | 8 | ready | any | 2022-04-15 08:27:09.359 | |
-Query OK, 1 row(s) in set (0.001137s)
-```
-
-In the above example, when `show dnodes` is executed the first time, two dnodes are shown. After `drop dnode 2` is executed, you can execute `show dnodes` again and it can be seen that only the dnode with ID 1 is still in the cluster.
-
-:::note
-
-- Once a dnode is dropped, it can't rejoin the cluster. To rejoin, the dnode needs to deployed again after cleaning up the data directory. Before dropping a dnode, the data belonging to the dnode MUST be migrated/backed up according to your data retention, data security or other SOPs.
-- Please note that `drop dnode` is different from stopping `taosd` process. `drop dnode` just removes the dnode out of TDengine cluster. Only after a dnode is dropped, can the corresponding `taosd` process be stopped.
-- Once a dnode is dropped, other dnodes in the cluster will be notified of the drop and will not accept the request from the dropped dnode.
-- dnodeID is allocated automatically and can't be manually modified. dnodeID is generated in ascending order without duplication.
-
-:::
diff --git a/docs/en/10-cluster/_category_.yml b/docs/en/10-cluster/_category_.yml
deleted file mode 100644
index 141fd7832631d69efed214293c69cee336bc854d..0000000000000000000000000000000000000000
--- a/docs/en/10-cluster/_category_.yml
+++ /dev/null
@@ -1 +0,0 @@
-label: Cluster
diff --git a/docs/en/10-deployment/01-deploy.md b/docs/en/10-deployment/01-deploy.md
new file mode 100644
index 0000000000000000000000000000000000000000..5dfcd3108d8b10cf24cdd5c852c4225ced0f16b2
--- /dev/null
+++ b/docs/en/10-deployment/01-deploy.md
@@ -0,0 +1,193 @@
+---
+sidebar_label: Manual Deployment
+title: Manual Deployment and Management
+---
+
+## Prerequisites
+
+### Step 0
+
+The FQDN of all hosts must be setup properly. For e.g. FQDNs may have to be configured in the /etc/hosts file on each host. You must confirm that each FQDN can be accessed from any other host. For e.g. you can do this by using the `ping` command. If you have a DNS server on your network, contact your network administrator for assistance.
+
+### Step 1
+
+If any previous version of TDengine has been installed and configured on any host, the installation needs to be removed and the data needs to be cleaned up. For details about uninstalling please refer to [Install and Uninstall](/operation/pkg-install). To clean up the data, please use `rm -rf /var/lib/taos/\*` assuming the `dataDir` is configured as `/var/lib/taos`.
+
+:::note
+FQDN information is written to file. If you have started TDengine without configuring or changing the FQDN, ensure that data is backed up or no longer needed before running the `rm -rf /var/lib\taos/\*` command.
+:::
+
+:::note
+- The host where the client program runs also needs to be configured properly for FQDN, to make sure all hosts for client or server can be accessed from any other. In other words, the hosts where the client is running are also considered as a part of the cluster.
+:::
+
+### Step 2
+
+- Please ensure that your firewall rules do not block TCP/UDP on ports 6030-6042 on all hosts in the cluster.
+
+### Step 3
+
+Now it's time to install TDengine on all hosts but without starting `taosd`. Note that the versions on all hosts should be same. If you are prompted to input the existing TDengine cluster, simply press carriage return to ignore the prompt.
+
+### Step 4
+
+Now each physical node (referred to, hereinafter, as `dnode` which is an abbreviation for "data node") of TDengine needs to be configured properly.
+
+To get the hostname on any host, the command `hostname -f` can be executed.
+
+`ping ` command can be executed on each host to check whether any other host is accessible from it. If any host is not accessible, the network configuration, like /etc/hosts or DNS configuration, needs to be checked and revised, to make any two hosts accessible to each other. Hosts that are not accessible to each other cannot form a cluster.
+
+On the physical machine running the application, ping the dnode that is running taosd. If the dnode is not accessible, the application cannot connect to taosd. In this case, verify the DNS and hosts settings on the physical node running the application.
+
+The end point of each dnode is the output hostname and port, such as h1.tdengine.com:6030.
+
+### Step 5
+
+Modify the TDengine configuration file `/etc/taos/taos.cfg` on each node. Assuming the first dnode of TDengine cluster is "h1.tdengine.com:6030", its `taos.cfg` is configured as following.
+
+```c
+// firstEp is the end point to connect to when any dnode starts
+firstEp h1.tdengine.com:6030
+
+// must be configured to the FQDN of the host where the dnode is launched
+fqdn h1.tdengine.com
+
+// the port used by the dnode, default is 6030
+serverPort 6030
+
+```
+
+`firstEp` and `fqdn` must be configured properly. In `taos.cfg` of all dnodes in TDengine cluster, `firstEp` must be configured to point to same address, i.e. the first dnode of the cluster. `fqdn` and `serverPort` compose the address of each node itself. Retain the default values for other parameters.
+
+For all the dnodes in a TDengine cluster, the below parameters must be configured exactly the same, any node whose configuration is different from dnodes already in the cluster can't join the cluster.
+
+| **#** | **Parameter** | **Definition** |
+| ----- | ------------------ | ------------------------------------------- |
+| 1 | statusInterval | The interval by which dnode reports its status to mnode |
+| 2 | timezone | Timezone |
+| 3 | locale | System region and encoding |
+| 4 | charset | Character set |
+
+## Start Cluster
+
+The first dnode can be started following the instructions in [Get Started](/get-started/). Then TDengine CLI `taos` can be launched to execute command `show dnodes`, the output is as following for example:
+
+```
+taos> show dnodes;
+id | endpoint | vnodes | support_vnodes | status | create_time | note |
+============================================================================================================================================
+1 | h1.tdengine.com:6030 | 0 | 1024 | ready | 2022-07-16 10:50:42.673 | |
+Query OK, 1 rows affected (0.007984s)
+
+
+```
+
+From the above output, it is shown that the end point of the started dnode is "h1.tdengine.com:6030", which is the `firstEp` of the cluster.
+
+## Add DNODE
+
+There are a few steps necessary to add other dnodes in the cluster.
+
+Second, we can start `taosd` as instructed in [Get Started](/get-started/).
+
+Then, on the first dnode i.e. h1.tdengine.com in our example, use TDengine CLI `taos` to execute the following command:
+
+```sql
+CREATE DNODE "h2.taos.com:6030";
+````
+
+This adds the end point of the new dnode (from Step 4) into the end point list of the cluster. In the command "fqdn:port" should be quoted using double quotes. Change `"h2.taos.com:6030"` to the end point of your new dnode.
+
+Then on the first dnode h1.tdengine.com, execute `show dnodes` in `taos`
+
+```sql
+SHOW DNODES;
+```
+
+to show whether the second dnode has been added in the cluster successfully or not. If the status of the newly added dnode is offline, please check:
+
+- Whether the `taosd` process is running properly or not
+- In the log file `taosdlog.0` to see whether the fqdn and port are correct and add the correct end point if not.
+The above process can be repeated to add more dnodes in the cluster.
+
+:::tip
+
+Any node that is in the cluster and online can be the firstEp of new nodes.
+Nodes use the firstEp parameter only when joining a cluster for the first time. After a node has joined the cluster, it stores the latest mnode in its end point list and no longer makes use of firstEp.
+
+However, firstEp is used by clients that connect to the cluster. For example, if you run TDengine CLI `taos` without arguments, it connects to the firstEp by default.
+
+Two dnodes that are launched without a firstEp value operate independently of each other. It is not possible to add one dnode to the other dnode and form a cluster. It is also not possible to form two independent clusters into a new cluster.
+
+:::
+
+## Show DNODEs
+
+The below command can be executed in TDengine CLI `taos`
+
+```sql
+SHOW DNODES;
+```
+
+to list all dnodes in the cluster, including ID, end point (fqdn:port), status (ready, offline), number of vnodes, number of free vnodes and so on. We recommend executing this command after adding or removing a dnode.
+
+Below is the example output of this command.
+
+```
+taos> show dnodes;
+ id | endpoint | vnodes | support_vnodes | status | create_time | note |
+============================================================================================================================================
+ 1 | trd01:6030 | 100 | 1024 | ready | 2022-07-15 16:47:47.726 | |
+Query OK, 1 rows affected (0.006684s)
+```
+
+## Show VGROUPs
+
+To utilize system resources efficiently and provide scalability, data sharding is required. The data of each database is divided into multiple shards and stored in multiple vnodes. These vnodes may be located on different dnodes. One way of scaling out is to add more vnodes on dnodes. Each vnode can only be used for a single DB, but one DB can have multiple vnodes. The allocation of vnode is scheduled automatically by mnode based on system resources of the dnodes.
+
+Launch TDengine CLI `taos` and execute below command:
+
+```sql
+USE SOME_DATABASE;
+SHOW VGROUPS;
+```
+
+The example output is below:
+
+```
+taos> use db;
+Database changed.
+
+taos> show vgroups;
+ vgroup_id | db_name | tables | v1_dnode | v1_status | v2_dnode | v2_status | v3_dnode | v3_status | status | nfiles | file_size | tsma |
+================================================================================================================================================================================================
+ 2 | db | 0 | 1 | leader | NULL | NULL | NULL | NULL | NULL | NULL | NULL | 0 |
+ 3 | db | 0 | 1 | leader | NULL | NULL | NULL | NULL | NULL | NULL | NULL | 0 |
+ 4 | db | 0 | 1 | leader | NULL | NULL | NULL | NULL | NULL | NULL | NULL | 0 |
+Query OK, 8 row(s) in set (0.001154s)
+```
+
+## Drop DNODE
+
+Before running the TDengine CLI, ensure that the taosd process has been stopped on the dnode that you want to delete.
+
+```sql
+DROP DNODE "fqdn:port";
+```
+
+or
+
+```sql
+DROP DNODE dnodeId;
+```
+
+to drop or remove a dnode from the cluster. In the command, you can get `dnodeId` from `show dnodes`.
+
+:::warning
+
+- Once a dnode is dropped, it can't rejoin the cluster. To rejoin, the dnode needs to deployed again after cleaning up the data directory. Before dropping a dnode, the data belonging to the dnode MUST be migrated/backed up according to your data retention, data security or other SOPs.
+- Please note that `drop dnode` is different from stopping `taosd` process. `drop dnode` just removes the dnode out of TDengine cluster. Only after a dnode is dropped, can the corresponding `taosd` process be stopped.
+- Once a dnode is dropped, other dnodes in the cluster will be notified of the drop and will not accept the request from the dropped dnode.
+- dnodeID is allocated automatically and can't be manually modified. dnodeID is generated in ascending order without duplication.
+
+:::
diff --git a/docs/en/10-deployment/03-k8s.md b/docs/en/10-deployment/03-k8s.md
new file mode 100644
index 0000000000000000000000000000000000000000..b0aa6777130864404e97dc332cf0e5ce830bf8ed
--- /dev/null
+++ b/docs/en/10-deployment/03-k8s.md
@@ -0,0 +1,393 @@
+---
+sidebar_label: Kubernetes
+title: Deploying a TDengine Cluster in Kubernetes
+---
+
+TDengine is a cloud-native time-series database that can be deployed on Kubernetes. This document gives a step-by-step description of how you can use YAML files to create a TDengine cluster and introduces common operations for TDengine in a Kubernetes environment.
+
+## Prerequisites
+
+Before deploying TDengine on Kubernetes, perform the following:
+
+* Current steps are compatible with Kubernetes v1.5 and later version.
+* Install and configure minikube, kubectl, and helm.
+* Install and deploy Kubernetes and ensure that it can be accessed and used normally. Update any container registries or other services as necessary.
+
+You can download the configuration files in this document from [GitHub](https://github.com/taosdata/TDengine-Operator/tree/3.0/src/tdengine).
+
+## Configure the service
+
+Create a service configuration file named `taosd-service.yaml`. Record the value of `metadata.name` (in this example, `taos`) for use in the next step. Add the ports required by TDengine:
+
+```yaml
+---
+apiVersion: v1
+kind: Service
+metadata:
+ name: "taosd"
+ labels:
+ app: "tdengine"
+spec:
+ ports:
+ - name: tcp6030
+ - protocol: "TCP"
+ port: 6030
+ - name: tcp6041
+ - protocol: "TCP"
+ port: 6041
+ selector:
+ app: "tdengine"
+```
+
+## Configure the service as StatefulSet
+
+Configure the TDengine service as a StatefulSet.
+Create the `tdengine.yaml` file and set `replicas` to 3. In this example, the region is set to Asia/Shanghai and 10 GB of standard storage are allocated per node. You can change the configuration based on your environment and business requirements.
+
+```yaml
+---
+apiVersion: apps/v1
+kind: StatefulSet
+metadata:
+ name: "tdengine"
+ labels:
+ app: "tdengine"
+spec:
+ serviceName: "taosd"
+ replicas: 3
+ updateStrategy:
+ type: RollingUpdate
+ selector:
+ matchLabels:
+ app: "tdengine"
+ template:
+ metadata:
+ name: "tdengine"
+ labels:
+ app: "tdengine"
+ spec:
+ containers:
+ - name: "tdengine"
+ image: "tdengine/tdengine:3.0.0.0"
+ imagePullPolicy: "IfNotPresent"
+ ports:
+ - name: tcp6030
+ - protocol: "TCP"
+ containerPort: 6030
+ - name: tcp6041
+ - protocol: "TCP"
+ containerPort: 6041
+ env:
+ # POD_NAME for FQDN config
+ - name: POD_NAME
+ valueFrom:
+ fieldRef:
+ fieldPath: metadata.name
+ # SERVICE_NAME and NAMESPACE for fqdn resolve
+ - name: SERVICE_NAME
+ value: "taosd"
+ - name: STS_NAME
+ value: "tdengine"
+ - name: STS_NAMESPACE
+ valueFrom:
+ fieldRef:
+ fieldPath: metadata.namespace
+ # TZ for timezone settings, we recommend to always set it.
+ - name: TZ
+ value: "Asia/Shanghai"
+ # TAOS_ prefix will configured in taos.cfg, strip prefix and camelCase.
+ - name: TAOS_SERVER_PORT
+ value: "6030"
+ # Must set if you want a cluster.
+ - name: TAOS_FIRST_EP
+ value: "$(STS_NAME)-0.$(SERVICE_NAME).$(STS_NAMESPACE).svc.cluster.local:$(TAOS_SERVER_PORT)"
+ # TAOS_FQDN should always be set in k8s env.
+ - name: TAOS_FQDN
+ value: "$(POD_NAME).$(SERVICE_NAME).$(STS_NAMESPACE).svc.cluster.local"
+ volumeMounts:
+ - name: taosdata
+ mountPath: /var/lib/taos
+ readinessProbe:
+ exec:
+ command:
+ - taos-check
+ initialDelaySeconds: 5
+ timeoutSeconds: 5000
+ livenessProbe:
+ exec:
+ command:
+ - taos-check
+ initialDelaySeconds: 15
+ periodSeconds: 20
+ volumeClaimTemplates:
+ - metadata:
+ name: taosdata
+ spec:
+ accessModes:
+ - "ReadWriteOnce"
+ storageClassName: "standard"
+ resources:
+ requests:
+ storage: "10Gi"
+```
+
+## Use kubectl to deploy TDengine
+
+Run the following commands:
+
+```bash
+kubectl apply -f taosd-service.yaml
+kubectl apply -f tdengine.yaml
+```
+
+The preceding configuration generates a TDengine cluster with three nodes in which dnodes are automatically configured. You can run the `show dnodes` command to query the nodes in the cluster:
+
+```bash
+kubectl exec -i -t tdengine-0 -- taos -s "show dnodes"
+kubectl exec -i -t tdengine-1 -- taos -s "show dnodes"
+kubectl exec -i -t tdengine-2 -- taos -s "show dnodes"
+```
+
+The output is as follows:
+
+```
+taos> show dnodes
+ id | endpoint | vnodes | support_vnodes | status | create_time | note |
+============================================================================================================================================
+ 1 | tdengine-0.taosd.default.sv... | 0 | 256 | ready | 2022-08-10 13:14:57.285 | |
+ 2 | tdengine-1.taosd.default.sv... | 0 | 256 | ready | 2022-08-10 13:15:11.302 | |
+ 3 | tdengine-2.taosd.default.sv... | 0 | 256 | ready | 2022-08-10 13:15:23.290 | |
+Query OK, 3 rows in database (0.003655s)
+```
+
+## Enable port forwarding
+
+The kubectl port forwarding feature allows applications to access the TDengine cluster running on Kubernetes.
+
+```
+kubectl port-forward tdengine-0 6041:6041 &
+```
+
+Use curl to verify that the TDengine REST API is working on port 6041:
+
+```
+$ curl -u root:taosdata -d "show databases" 127.0.0.1:6041/rest/sql
+Handling connection for 6041
+{"code":0,"column_meta":[["name","VARCHAR",64],["create_time","TIMESTAMP",8],["vgroups","SMALLINT",2],["ntables","BIGINT",8],["replica","TINYINT",1],["strict","VARCHAR",4],["duration","VARCHAR",10],["keep","VARCHAR",32],["buffer","INT",4],["pagesize","INT",4],["pages","INT",4],["minrows","INT",4],["maxrows","INT",4],["comp","TINYINT",1],["precision","VARCHAR",2],["status","VARCHAR",10],["retention","VARCHAR",60],["single_stable","BOOL",1],["cachemodel","VARCHAR",11],["cachesize","INT",4],["wal_level","TINYINT",1],["wal_fsync_period","INT",4],["wal_retention_period","INT",4],["wal_retention_size","BIGINT",8],["wal_roll_period","INT",4],["wal_segment_size","BIGINT",8]],"data":[["information_schema",null,null,16,null,null,null,null,null,null,null,null,null,null,null,"ready",null,null,null,null,null,null,null,null,null,null],["performance_schema",null,null,10,null,null,null,null,null,null,null,null,null,null,null,"ready",null,null,null,null,null,null,null,null,null,null]],"rows":2}
+```
+
+## Enable the dashboard for visualization
+
+ The minikube dashboard command enables visualized cluster management.
+
+```
+$ minikube dashboard
+* Verifying dashboard health ...
+* Launching proxy ...
+* Verifying proxy health ...
+* Opening http://127.0.0.1:46617/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/ in your default browser...
+http://127.0.0.1:46617/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/
+```
+
+In some public clouds, minikube cannot be remotely accessed if it is bound to 127.0.0.1. In this case, use the kubectl proxy command to map the port to 0.0.0.0. Then, you can access the dashboard by using a web browser to open the dashboard URL above on the public IP address and port of the virtual machine.
+
+```
+$ kubectl proxy --accept-hosts='^.*$' --address='0.0.0.0'
+```
+
+## Scaling Out Your Cluster
+
+TDengine clusters can scale automatically:
+
+```bash
+kubectl scale statefulsets tdengine --replicas=4
+```
+
+The preceding command increases the number of replicas to 4. After running this command, query the pod status:
+
+```bash
+kubectl get pods -l app=tdengine
+```
+
+The output is as follows:
+
+```
+NAME READY STATUS RESTARTS AGE
+tdengine-0 1/1 Running 0 161m
+tdengine-1 1/1 Running 0 161m
+tdengine-2 1/1 Running 0 32m
+tdengine-3 1/1 Running 0 32m
+```
+
+The status of all pods is Running. Once the pod status changes to Ready, you can check the dnode status:
+
+```bash
+kubectl exec -i -t tdengine-3 -- taos -s "show dnodes"
+```
+
+The following output shows that the TDengine cluster has been expanded to 4 replicas:
+
+```
+taos> show dnodes
+ id | endpoint | vnodes | support_vnodes | status | create_time | note |
+============================================================================================================================================
+ 1 | tdengine-0.taosd.default.sv... | 0 | 256 | ready | 2022-08-10 13:14:57.285 | |
+ 2 | tdengine-1.taosd.default.sv... | 0 | 256 | ready | 2022-08-10 13:15:11.302 | |
+ 3 | tdengine-2.taosd.default.sv... | 0 | 256 | ready | 2022-08-10 13:15:23.290 | |
+ 4 | tdengine-3.taosd.default.sv... | 0 | 256 | ready | 2022-08-10 13:33:16.039 | |
+Query OK, 4 rows in database (0.008377s)
+```
+
+## Scaling In Your Cluster
+
+When you scale in a TDengine cluster, your data is migrated to different nodes. You must run the drop dnodes command in TDengine to remove dnodes before scaling in your Kubernetes environment.
+
+Note: In a Kubernetes StatefulSet service, the newest pods are always removed first. For this reason, when you scale in your TDengine cluster, ensure that you drop the newest dnodes.
+
+```
+$ kubectl exec -i -t tdengine-0 -- taos -s "drop dnode 4"
+```
+
+```bash
+$ kubectl exec -it tdengine-0 -- taos -s "show dnodes"
+
+taos> show dnodes
+ id | endpoint | vnodes | support_vnodes | status | create_time | note |
+============================================================================================================================================
+ 1 | tdengine-0.taosd.default.sv... | 0 | 256 | ready | 2022-08-10 13:14:57.285 | |
+ 2 | tdengine-1.taosd.default.sv... | 0 | 256 | ready | 2022-08-10 13:15:11.302 | |
+ 3 | tdengine-2.taosd.default.sv... | 0 | 256 | ready | 2022-08-10 13:15:23.290 | |
+Query OK, 3 rows in database (0.004861s)
+```
+
+Verify that the dnode have been successfully removed by running the `kubectl exec -i -t tdengine-0 -- taos -s "show dnodes"` command. Then run the following command to remove the pod:
+
+```
+kubectl scale statefulsets tdengine --replicas=3
+```
+
+The newest pod in the deployment is removed. Run the `kubectl get pods -l app=tdengine` command to query the pod status:
+
+```
+$ kubectl get pods -l app=tdengine
+NAME READY STATUS RESTARTS AGE
+tdengine-0 1/1 Running 0 4m7s
+tdengine-1 1/1 Running 0 3m55s
+tdengine-2 1/1 Running 0 2m28s
+```
+
+After the pod has been removed, manually delete the PersistentVolumeClaim (PVC). Otherwise, future scale-outs will attempt to use existing data.
+
+```bash
+$ kubectl delete pvc taosdata-tdengine-3
+```
+
+Your cluster has now been safely scaled in, and you can scale it out again as necessary.
+
+```bash
+$ kubectl scale statefulsets tdengine --replicas=4
+statefulset.apps/tdengine scaled
+it@k8s-2:~/TDengine-Operator/src/tdengine$ kubectl get pods -l app=tdengine
+NAME READY STATUS RESTARTS AGE
+tdengine-0 1/1 Running 0 35m
+tdengine-1 1/1 Running 0 34m
+tdengine-2 1/1 Running 0 12m
+tdengine-3 0/1 ContainerCreating 0 4s
+it@k8s-2:~/TDengine-Operator/src/tdengine$ kubectl get pods -l app=tdengine
+NAME READY STATUS RESTARTS AGE
+tdengine-0 1/1 Running 0 35m
+tdengine-1 1/1 Running 0 34m
+tdengine-2 1/1 Running 0 12m
+tdengine-3 0/1 Running 0 7s
+it@k8s-2:~/TDengine-Operator/src/tdengine$ kubectl exec -it tdengine-0 -- taos -s "show dnodes"
+
+taos> show dnodes
+id | endpoint | vnodes | support_vnodes | status | create_time | offline reason |
+======================================================================================================================================
+1 | tdengine-0.taosd.default.sv... | 0 | 4 | ready | 2022-07-25 17:38:49.012 | |
+2 | tdengine-1.taosd.default.sv... | 1 | 4 | ready | 2022-07-25 17:39:01.517 | |
+5 | tdengine-2.taosd.default.sv... | 0 | 4 | ready | 2022-07-25 18:01:36.479 | |
+6 | tdengine-3.taosd.default.sv... | 0 | 4 | ready | 2022-07-25 18:13:54.411 | |
+Query OK, 4 row(s) in set (0.001348s)
+```
+
+## Remove a TDengine Cluster
+
+To fully remove a TDengine cluster, you must delete its statefulset, svc, configmap, and pvc entries:
+
+```bash
+kubectl delete statefulset -l app=tdengine
+kubectl delete svc -l app=tdengine
+kubectl delete pvc -l app=tdengine
+kubectl delete configmap taoscfg
+
+```
+
+## Troubleshooting
+
+### Error 1
+
+If you remove a pod without first running `drop dnode`, some TDengine nodes will go offline.
+
+```
+$ kubectl exec -it tdengine-0 -- taos -s "show dnodes"
+
+taos> show dnodes
+id | endpoint | vnodes | support_vnodes | status | create_time | offline reason |
+======================================================================================================================================
+1 | tdengine-0.taosd.default.sv... | 0 | 4 | ready | 2022-07-25 17:38:49.012 | |
+2 | tdengine-1.taosd.default.sv... | 1 | 4 | ready | 2022-07-25 17:39:01.517 | |
+5 | tdengine-2.taosd.default.sv... | 0 | 4 | offline | 2022-07-25 18:01:36.479 | status msg timeout |
+6 | tdengine-3.taosd.default.sv... | 0 | 4 | offline | 2022-07-25 18:13:54.411 | status msg timeout |
+Query OK, 4 row(s) in set (0.001323s)
+```
+
+### Error 2
+
+If the number of nodes after a scale-in is less than the value of the replica parameter, the cluster will go down:
+
+Create a database with replica set to 2 and add data.
+
+```bash
+kubectl exec -i -t tdengine-0 -- \
+ taos -s \
+ "create database if not exists test replica 2;
+ use test;
+ create table if not exists t1(ts timestamp, n int);
+ insert into t1 values(now, 1)(now+1s, 2);"
+
+
+```
+
+Scale in to one node:
+
+```bash
+kubectl scale statefulsets tdengine --replicas=1
+
+```
+
+In the TDengine CLI, you can see that no database operations succeed:
+
+```
+taos> show dnodes;
+ id | end_point | vnodes | cores | status | role | create_time | offline reason |
+======================================================================================================================================
+ 1 | tdengine-0.taosd.default.sv... | 2 | 40 | ready | any | 2021-06-01 15:55:52.562 | |
+ 2 | tdengine-1.taosd.default.sv... | 1 | 40 | offline | any | 2021-06-01 15:56:07.212 | status msg timeout |
+Query OK, 2 row(s) in set (0.000845s)
+
+taos> show dnodes;
+ id | end_point | vnodes | cores | status | role | create_time | offline reason |
+======================================================================================================================================
+ 1 | tdengine-0.taosd.default.sv... | 2 | 40 | ready | any | 2021-06-01 15:55:52.562 | |
+ 2 | tdengine-1.taosd.default.sv... | 1 | 40 | offline | any | 2021-06-01 15:56:07.212 | status msg timeout |
+Query OK, 2 row(s) in set (0.000837s)
+
+taos> use test;
+Database changed.
+
+taos> insert into t1 values(now, 3);
+
+DB error: Unable to resolve FQDN (0.013874s)
+
+```
diff --git a/docs/en/10-deployment/05-helm.md b/docs/en/10-deployment/05-helm.md
new file mode 100644
index 0000000000000000000000000000000000000000..a4fa68100078efe85fff5e1b078ebd07e5337d5a
--- /dev/null
+++ b/docs/en/10-deployment/05-helm.md
@@ -0,0 +1,298 @@
+---
+sidebar_label: Helm
+title: Use Helm to deploy TDengine
+---
+
+Helm is a package manager for Kubernetes that can provide more capabilities in deploying on Kubernetes.
+
+## Install Helm
+
+```bash
+curl -fsSL -o get_helm.sh \
+ https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
+chmod +x get_helm.sh
+./get_helm.sh
+
+```
+
+Helm uses the kubectl and kubeconfig configurations to perform Kubernetes operations. For more information, see the Rancher configuration for Kubernetes installation.
+
+## Install TDengine Chart
+
+To use TDengine Chart, download it from GitHub:
+
+```bash
+wget https://github.com/taosdata/TDengine-Operator/raw/3.0/helm/tdengine-3.0.0.tgz
+
+```
+
+Query the storageclass of your Kubernetes deployment:
+
+```bash
+kubectl get storageclass
+
+```
+
+With minikube, the default value is standard.
+
+Use Helm commands to install TDengine:
+
+```bash
+helm install tdengine tdengine-3.0.0.tgz \
+ --set storage.className=
+
+```
+
+You can configure a small storage size in minikube to ensure that your deployment does not exceed your available disk space.
+
+```bash
+helm install tdengine tdengine-3.0.0.tgz \
+ --set storage.className=standard \
+ --set storage.dataSize=2Gi \
+ --set storage.logSize=10Mi
+
+```
+
+After TDengine is deployed, TDengine Chart outputs information about how to use TDengine:
+
+```bash
+export POD_NAME=$(kubectl get pods --namespace default \
+ -l "app.kubernetes.io/name=tdengine,app.kubernetes.io/instance=tdengine" \
+ -o jsonpath="{.items[0].metadata.name}")
+kubectl --namespace default exec $POD_NAME -- taos -s "show dnodes; show mnodes"
+kubectl --namespace default exec -it $POD_NAME -- taos
+
+```
+
+You can test the deployment by creating a table:
+
+```bash
+kubectl --namespace default exec $POD_NAME -- \
+ taos -s "create database test;
+ use test;
+ create table t1 (ts timestamp, n int);
+ insert into t1 values(now, 1)(now + 1s, 2);
+ select * from t1;"
+
+```
+
+## Configuring Values
+
+You can configure custom parameters in TDengine with the `values.yaml` file.
+
+Run the `helm show values` command to see all parameters supported by TDengine Chart.
+
+```bash
+helm show values tdengine-3.0.0.tgz
+
+```
+
+Save the output of this command as `values.yaml`. Then you can modify this file with your desired values and use it to deploy a TDengine cluster:
+
+```bash
+helm install tdengine tdengine-3.0.0.tgz -f values.yaml
+
+```
+
+The parameters are described as follows:
+
+```yaml
+# Default values for tdengine.
+# This is a YAML-formatted file.
+# Declare variables to be passed into helm templates.
+
+replicaCount: 1
+
+image:
+ prefix: tdengine/tdengine
+ #pullPolicy: Always
+ # Overrides the image tag whose default is the chart appVersion.
+# tag: "3.0.0.0"
+
+service:
+ # ClusterIP is the default service type, use NodeIP only if you know what you are doing.
+ type: ClusterIP
+ ports:
+ # TCP range required
+ tcp: [6030, 6041, 6042, 6043, 6044, 6046, 6047, 6048, 6049, 6060]
+ # UDP range
+ udp: [6044, 6045]
+
+
+# Set timezone here, not in taoscfg
+timezone: "Asia/Shanghai"
+
+resources:
+ # We usually recommend not to specify default resources and to leave this as a conscious
+ # choice for the user. This also increases chances charts run on environments with little
+ # resources, such as Minikube. If you do want to specify resources, uncomment the following
+ # lines, adjust them as necessary, and remove the curly braces after 'resources:'.
+ # limits:
+ # cpu: 100m
+ # memory: 128Mi
+ # requests:
+ # cpu: 100m
+ # memory: 128Mi
+
+storage:
+ # Set storageClassName for pvc. K8s use default storage class if not set.
+ #
+ className: ""
+ dataSize: "100Gi"
+ logSize: "10Gi"
+
+nodeSelectors:
+ taosd:
+ # node selectors
+
+clusterDomainSuffix: ""
+# Config settings in taos.cfg file.
+#
+# The helm/k8s support will use environment variables for taos.cfg,
+# converting an upper-snake-cased variable like `TAOS_DEBUG_FLAG`,
+# to a camelCase taos config variable `debugFlag`.
+#
+# See the [Configuration Variables](../../reference/config)
+#
+# Note:
+# 1. firstEp/secondEp: should not be setted here, it's auto generated at scale-up.
+# 2. serverPort: should not be setted, we'll use the default 6030 in many places.
+# 3. fqdn: will be auto generated in kubenetes, user should not care about it.
+# 4. role: currently role is not supported - every node is able to be mnode and vnode.
+#
+# Btw, keep quotes "" around the value like below, even the value will be number or not.
+taoscfg:
+ # Starts as cluster or not, must be 0 or 1.
+ # 0: all pods will start as a seperate TDengine server
+ # 1: pods will start as TDengine server cluster. [default]
+ CLUSTER: "1"
+
+ # number of replications, for cluster only
+ TAOS_REPLICA: "1"
+
+ #
+ # TAOS_NUM_OF_RPC_THREADS: number of threads for RPC
+ #TAOS_NUM_OF_RPC_THREADS: "2"
+
+
+ #
+ # TAOS_NUM_OF_COMMIT_THREADS: number of threads to commit cache data
+ #TAOS_NUM_OF_COMMIT_THREADS: "4"
+
+ # enable/disable installation / usage report
+ #TAOS_TELEMETRY_REPORTING: "1"
+
+ # time interval of system monitor, seconds
+ #TAOS_MONITOR_INTERVAL: "30"
+
+ # time interval of dnode status reporting to mnode, seconds, for cluster only
+ #TAOS_STATUS_INTERVAL: "1"
+
+ # time interval of heart beat from shell to dnode, seconds
+ #TAOS_SHELL_ACTIVITY_TIMER: "3"
+
+ # minimum sliding window time, milli-second
+ #TAOS_MIN_SLIDING_TIME: "10"
+
+ # minimum time window, milli-second
+ #TAOS_MIN_INTERVAL_TIME: "1"
+
+ # the compressed rpc message, option:
+ # -1 (no compression)
+ # 0 (all message compressed),
+ # > 0 (rpc message body which larger than this value will be compressed)
+ #TAOS_COMPRESS_MSG_SIZE: "-1"
+
+ # max number of connections allowed in dnode
+ #TAOS_MAX_SHELL_CONNS: "50000"
+
+ # stop writing logs when the disk size of the log folder is less than this value
+ #TAOS_MINIMAL_LOG_DIR_G_B: "0.1"
+
+ # stop writing temporary files when the disk size of the tmp folder is less than this value
+ #TAOS_MINIMAL_TMP_DIR_G_B: "0.1"
+
+ # if disk free space is less than this value, taosd service exit directly within startup process
+ #TAOS_MINIMAL_DATA_DIR_G_B: "0.1"
+
+ # One mnode is equal to the number of vnode consumed
+ #TAOS_MNODE_EQUAL_VNODE_NUM: "4"
+
+ # enbale/disable http service
+ #TAOS_HTTP: "1"
+
+ # enable/disable system monitor
+ #TAOS_MONITOR: "1"
+
+ # enable/disable async log
+ #TAOS_ASYNC_LOG: "1"
+
+ #
+ # time of keeping log files, days
+ #TAOS_LOG_KEEP_DAYS: "0"
+
+ # The following parameters are used for debug purpose only.
+ # debugFlag 8 bits mask: FILE-SCREEN-UNUSED-HeartBeat-DUMP-TRACE_WARN-ERROR
+ # 131: output warning and error
+ # 135: output debug, warning and error
+ # 143: output trace, debug, warning and error to log
+ # 199: output debug, warning and error to both screen and file
+ # 207: output trace, debug, warning and error to both screen and file
+ #
+ # debug flag for all log type, take effect when non-zero value\
+ #TAOS_DEBUG_FLAG: "143"
+
+ # generate core file when service crash
+ #TAOS_ENABLE_CORE_FILE: "1"
+```
+
+## Scaling Out
+
+For information about scaling out your deployment, see Kubernetes. Additional Helm-specific is described as follows.
+
+First, obtain the name of the StatefulSet service for your deployment.
+
+```bash
+export STS_NAME=$(kubectl get statefulset \
+ -l "app.kubernetes.io/name=tdengine" \
+ -o jsonpath="{.items[0].metadata.name}")
+
+```
+
+You can scale out your deployment by adding replicas. The following command scales a deployment to three nodes:
+
+```bash
+kubectl scale --replicas 3 statefulset/$STS_NAME
+
+```
+
+Run the `show dnodes` and `show mnodes` commands to check whether the scale-out was successful.
+
+## Scaling In
+
+:::warning
+Exercise caution when scaling in a cluster.
+
+:::
+
+Determine which dnodes you want to remove and drop them manually.
+
+```bash
+kubectl --namespace default exec $POD_NAME -- \
+ cat /var/lib/taos/dnode/dnodeEps.json \
+ | jq '.dnodeInfos[1:] |map(.dnodeFqdn + ":" + (.dnodePort|tostring)) | .[]' -r
+kubectl --namespace default exec $POD_NAME -- taos -s "show dnodes"
+kubectl --namespace default exec $POD_NAME -- taos -s 'drop dnode ""'
+
+```
+
+## Remove a TDengine Cluster
+
+You can use Helm to remove your cluster:
+
+```bash
+helm uninstall tdengine
+
+```
+
+However, Helm does not remove PVCs automatically. After you remove your cluster, manually remove all PVCs.
diff --git a/docs/en/10-deployment/_category_.yml b/docs/en/10-deployment/_category_.yml
new file mode 100644
index 0000000000000000000000000000000000000000..0bb1ba461bd4c0e350c60fa3a8bc7723429a3f9f
--- /dev/null
+++ b/docs/en/10-deployment/_category_.yml
@@ -0,0 +1 @@
+label: Deployment
diff --git a/docs/en/10-cluster/index.md b/docs/en/10-deployment/index.md
similarity index 78%
rename from docs/en/10-cluster/index.md
rename to docs/en/10-deployment/index.md
index 5a45a2ce7b08c67322265cf1bbd54ef66cbfc027..7054a33e4a40222ed5eb9a15837990e3e7a81cff 100644
--- a/docs/en/10-cluster/index.md
+++ b/docs/en/10-deployment/index.md
@@ -1,11 +1,10 @@
---
-title: Cluster
-keywords: ["cluster", "high availability", "load balance", "scale out"]
+title: Deployment
---
TDengine has a native distributed design and provides the ability to scale out. A few nodes can form a TDengine cluster. If you need higher processing power, you just need to add more nodes into the cluster. TDengine uses virtual node technology to virtualize a node into multiple virtual nodes to achieve load balancing. At the same time, TDengine can group virtual nodes on different nodes into virtual node groups, and use the replication mechanism to ensure the high availability of the system. The cluster feature of TDengine is completely open source.
-This chapter mainly introduces cluster deployment, maintenance, and how to achieve high availability and load balancing.
+This document describes how to manually deploy a cluster on a host as well as how to deploy on Kubernetes and by using Helm.
```mdx-code-block
import DocCardList from '@theme/DocCardList';
diff --git a/docs/en/12-taos-sql/01-data-type.md b/docs/en/12-taos-sql/01-data-type.md
index d038219c8ac66db52416001f7a79c71018e2ca33..876de50f35ee3ba533bd7d5916632de853a84c0e 100644
--- a/docs/en/12-taos-sql/01-data-type.md
+++ b/docs/en/12-taos-sql/01-data-type.md
@@ -1,16 +1,17 @@
---
+sidebar_label: Data Types
title: Data Types
description: "TDengine supports a variety of data types including timestamp, float, JSON and many others."
---
-## TIMESTAMP
+## Timestamp
When using TDengine to store and query data, the most important part of the data is timestamp. Timestamp must be specified when creating and inserting data rows. Timestamp must follow the rules below:
- The format must be `YYYY-MM-DD HH:mm:ss.MS`, the default time precision is millisecond (ms), for example `2017-08-12 18:25:58.128`
- Internal function `now` can be used to get the current timestamp on the client side
- The current timestamp of the client side is applied when `now` is used to insert data
-- Epoch Time:timestamp can also be a long integer number, which means the number of seconds, milliseconds or nanoseconds, depending on the time precision, from 1970-01-01 00:00:00.000 (UTC/GMT)
+- Epoch Time:timestamp can also be a long integer number, which means the number of seconds, milliseconds or nanoseconds, depending on the time precision, from UTC 1970-01-01 00:00:00.
- Add/subtract operations can be carried out on timestamps. For example `now-2h` means 2 hours prior to the time at which query is executed. The units of time in operations can be b(nanosecond), u(microsecond), a(millisecond), s(second), m(minute), h(hour), d(day), or w(week). So `select * from t1 where ts > now-2w and ts <= now-1w` means the data between two weeks ago and one week ago. The time unit can also be n (calendar month) or y (calendar year) when specifying the time window for down sampling operations.
Time precision in TDengine can be set by the `PRECISION` parameter when executing `CREATE DATABASE`. The default time precision is millisecond. In the statement below, the precision is set to nanonseconds.
@@ -18,52 +19,54 @@ Time precision in TDengine can be set by the `PRECISION` parameter when executin
```sql
CREATE DATABASE db_name PRECISION 'ns';
```
-
## Data Types
In TDengine, the data types below can be used when specifying a column or tag.
| # | **type** | **Bytes** | **Description** |
-| --- | :-------: | --------- | ------------------------- |
-| 1 | TIMESTAMP | 8 | Default precision is millisecond, microsecond and nanosecond are also supported |
+| --- | :-------: | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| 1 | TIMESTAMP | 8 | Default precision is millisecond, microsecond and nanosecond are also supported |
| 2 | INT | 4 | Integer, the value range is [-2^31, 2^31-1] |
-| 3 |INT UNSIGNED|4 | Unsigned integer, the value range is [0, 2^31-1] |
+| 3 | INT UNSIGNED| 4| unsigned integer, the value range is [0, 2^32-1]
| 4 | BIGINT | 8 | Long integer, the value range is [-2^63, 2^63-1] |
-| 5 | BIGINT UNSIGNED | 8 | Unsigned long integer, the value range is [0, 2^63-1] |
+| 5 | BIGINT UNSIGNED | 8 | unsigned long integer, the value range is [0, 2^64-1] |
| 6 | FLOAT | 4 | Floating point number, the effective number of digits is 6-7, the value range is [-3.4E38, 3.4E38] |
| 7 | DOUBLE | 8 | Double precision floating point number, the effective number of digits is 15-16, the value range is [-1.7E308, 1.7E308] |
-| 8 | BINARY | User Defined | Single-byte string for ASCII visible characters. Length must be specified when defining a column or tag of binary type. The string length can be up to 16374 bytes. The string value must be quoted with single quotes. The literal single quote inside the string must be preceded with back slash like `\'` |
-| 9 | SMALLINT | 2 | Short integer, the value range is [-32768, 32767] |
-| 10 | SMALLINT UNSIGNED | 2 | Unsigned short integer, the value range is [0, 32767] |
-| 11 | TINYINT | 1 | Single-byte integer, the value range is [-128, 127] |
-| 12 | TINYINT UNSIGNED | 1 | Unsigned single-byte integer, the value range is [0, 127] |
-| 13 | BOOL | 1 | Bool, the value range is {true, false} |
-| 14 | NCHAR | User Defined| Multi-Byte string that can include multi byte characters like Chinese characters. Each character of NCHAR type consumes 4 bytes storage. The string value should be quoted with single quotes. Literal single quote inside the string must be preceded with backslash, like `\’`. The length must be specified when defining a column or tag of NCHAR type, for example nchar(10) means it can store at most 10 characters of nchar type and will consume fixed storage of 40 bytes. An error will be reported if the string value exceeds the length defined. |
+| 8 | BINARY | User Defined | Single-byte string for ASCII visible characters. Length must be specified when defining a column or tag of binary type. |
+| 9 | SMALLINT | 2 | Short integer, the value range is [-32768, 32767] |
+| 10 | INT UNSIGNED| 2| unsigned integer, the value range is [0, 65535]|
+| 11 | TINYINT | 1 | Single-byte integer, the value range is [-128, 127] |
+| 12 | TINYINT UNSIGNED | 1 | unsigned single-byte integer, the value range is [0, 255] |
+| 13 | BOOL | 1 | Bool, the value range is {true, false} |
+| 14 | NCHAR | User Defined| Multi-Byte string that can include multi byte characters like Chinese characters. Each character of NCHAR type consumes 4 bytes storage. The string value should be quoted with single quotes. Literal single quote inside the string must be preceded with backslash, like `\’`. The length must be specified when defining a column or tag of NCHAR type, for example nchar(10) means it can store at most 10 characters of nchar type and will consume fixed storage of 40 bytes. An error will be reported if the string value exceeds the length defined. |
| 15 | JSON | | JSON type can only be used on tags. A tag of json type is excluded with any other tags of any other type |
-| 16 | VARCHAR | User Defined| Alias of BINARY type |
+| 16 | VARCHAR | User-defined | Alias of BINARY |
+
:::note
- TDengine is case insensitive and treats any characters in the sql command as lower case by default, case sensitive strings must be quoted with single quotes.
-- Only ASCII visible characters are suggested to be used in a column or tag of BINARY type. Multi-byte characters must be stored in NCHAR type.
+- Only ASCII visible characters are suggested to be used in a column or tag of BINARY type. Multi-byte characters must be stored in NCHAR type.
+- The length of BINARY can be up to 16374 bytes. The string value must be quoted with single quotes. You must specify a length in bytes for a BINARY value, for example binary(20) for up to twenty single-byte characters. If the data exceeds the specified length, an error will occur. The literal single quote inside the string must be preceded with back slash like `\'`
- Numeric values in SQL statements will be determined as integer or float type according to whether there is decimal point or whether scientific notation is used, so attention must be paid to avoid overflow. For example, 9999999999999999999 will be considered as overflow because it exceeds the upper limit of long integer, but 9999999999999999999.0 will be considered as a legal float number.
:::
+
## Constants
-TDengine supports constants of multiple data type.
+TDengine supports a variety of constants:
| # | **Syntax** | **Type** | **Description** |
| --- | :-------: | --------- | -------------------------------------- |
-| 1 | [{+ \| -}]123 | BIGINT | Numeric constants are treated as BIGINT type. The value will be truncated if it exceeds the range of BIGINT type. |
-| 2 | 123.45 | DOUBLE | Floating number constants are treated as DOUBLE type. TDengine determines whether it's a floating number based on if decimal point or scientific notation is used. |
-| 3 | 1.2E3 | DOUBLE | Constants in scientific notation are treated ad DOUBLE type. |
-| 4 | 'abc' | BINARY | String constants enclosed by single quotes are treated as BINARY type. Its size is determined as the acutal length. Single quote itself can be included by preceding backslash, i.e. `\'`, in a string constant. |
-| 5 | "abc" | BINARY | String constants enclosed by double quotes are treated as BINARY type. Its size is determined as the acutal length. Double quote itself can be included by preceding backslash, i.e. `\"`, in a string constant. |
-| 6 | TIMESTAMP {'literal' \| "literal"} | TIMESTAMP | A string constant following `TIMESTAMP` keyword is treated as TIMESTAMP type. The string should be in the format of "YYYY-MM-DD HH:mm:ss.MS". Its time precision is same as that of the current database being used. |
-| 7 | {TRUE \| FALSE} | BOOL | BOOL type contant. |
-| 8 | {'' \| "" \| '\t' \| "\t" \| ' ' \| " " \| NULL } | -- | NULL constant, it can be used for any type.|
+| 1 | [{+ \| -}]123 | BIGINT | Integer literals are of type BIGINT. Data that exceeds the length of the BIGINT type is truncated. |
+| 2 | 123.45 | DOUBLE | Floating-point literals are of type DOUBLE. Numeric values will be determined as integer or float type according to whether there is decimal point or whether scientific notation is used. |
+| 3 | 1.2E3 | DOUBLE | Literals in scientific notation are of type DOUBLE. |
+| 4 | 'abc' | BINARY | Content enclosed in single quotation marks is of type BINARY. The size of a BINARY is the size of the string in bytes. A literal single quote inside the string must be escaped with a backslash (\'). |
+| 5 | 'abc' | BINARY | Content enclosed in double quotation marks is of type BINARY. The size of a BINARY is the size of the string in bytes. A literal double quote inside the string must be escaped with a backslash (\"). |
+| 6 | TIMESTAMP {'literal' \| "literal"} | TIMESTAMP | The TIMESTAMP keyword indicates that the following string literal is interpreted as a timestamp. The string must be in YYYY-MM-DD HH:mm:ss.MS format. The precision is inherited from the database configuration. |
+| 7 | {TRUE \| FALSE} | BOOL | Boolean literals are of type BOOL. |
+| 8 | {'' \| "" \| '\t' \| "\t" \| ' ' \| " " \| NULL } | -- | The preceding characters indicate null literals. These can be used with any data type. |
:::note
-- TDengine determines whether it's a floating number based on if decimal point or scientific notation is used. So whether the value is determined as overflow depends on both the value and the determined type. For example, 9999999999999999999 is determined as overflow because it exceeds the upper limit of BIGINT type, while 9999999999999999999.0 is considered as a valid floating number because it is within the range of DOUBLE type.
+Numeric values will be determined as integer or float type according to whether there is decimal point or whether scientific notation is used, so attention must be paid to avoid overflow. For example, 9999999999999999999 will be considered as overflow because it exceeds the upper limit of long integer, but 9999999999999999999.0 will be considered as a legal float number.
:::
diff --git a/docs/en/12-taos-sql/02-database.md b/docs/en/12-taos-sql/02-database.md
index c2961d62415cd7d23b031777082801426b221190..d9dadae976bf07bbf6cfb49401d55bb0bf18da49 100644
--- a/docs/en/12-taos-sql/02-database.md
+++ b/docs/en/12-taos-sql/02-database.md
@@ -4,123 +4,153 @@ title: Database
description: "create and drop database, show or change database parameters"
---
-## Create Database
+## Create a Database
+
+```sql
+CREATE DATABASE [IF NOT EXISTS] db_name [database_options]
+
+database_options:
+ database_option ...
+
+database_option: {
+ BUFFER value
+ | CACHEMODEL {'none' | 'last_row' | 'last_value' | 'both'}
+ | CACHESIZE value
+ | COMP {0 | 1 | 2}
+ | DURATION value
+ | WAL_FSYNC_PERIOD value
+ | MAXROWS value
+ | MINROWS value
+ | KEEP value
+ | PAGES value
+ | PAGESIZE value
+ | PRECISION {'ms' | 'us' | 'ns'}
+ | REPLICA value
+ | RETENTIONS ingestion_duration:keep_duration ...
+ | STRICT {'off' | 'on'}
+ | WAL_LEVEL {1 | 2}
+ | VGROUPS value
+ | SINGLE_STABLE {0 | 1}
+ | WAL_RETENTION_PERIOD value
+ | WAL_ROLL_PERIOD value
+ | WAL_RETENTION_SIZE value
+ | WAL_SEGMENT_SIZE value
+}
+```
+
+## Parameters
+
+- BUFFER: specifies the size (in MB) of the write buffer for each vnode. Enter a value between 3 and 16384. The default value is 96.
+- CACHEMODEL: specifies how the latest data in subtables is stored in the cache. The default value is none.
+ - none: The latest data is not cached.
+ - last_row: The last row of each subtable is cached. This option significantly improves the performance of the LAST_ROW function.
+ - last_value: The last non-null value of each column in each subtable is cached. This option significantly improves the performance of the LAST function under normal circumstances, such as statements including the WHERE, ORDER BY, GROUP BY, and INTERVAL keywords.
+ - both: The last row of each subtable and the last non-null value of each column in each subtable are cached.
+- CACHESIZE: specifies the amount (in MB) of memory used for subtable caching on each vnode. Enter a value between 1 and 65536. The default value is 1.
+- COMP: specifies how databases are compressed. The default value is 2.
+ - 0: Compression is disabled.
+ - 1: One-pass compression is enabled.
+ - 2: Two-pass compression is enabled.
+- DURATION: specifies the time period contained in each data file. After the time specified by this parameter has elapsed, TDengine creates a new data file to store incoming data. You can use m (minutes), h (hours), and d (days) as the unit, for example DURATION 100h or DURATION 10d. If you do not include a unit, d is used by default.
+- WAL_FSYNC_PERIOD: specifies the interval (in milliseconds) at which data is written from the WAL to disk. This parameter takes effect only when the WAL parameter is set to 2. The default value is 3000. Enter a value between 0 and 180000. The value 0 indicates that incoming data is immediately written to disk.
+- MAXROWS: specifies the maximum number of rows recorded in a block. The default value is 4096.
+- MINROWS: specifies the minimum number of rows recorded in a block. The default value is 100.
+- KEEP: specifies the time for which data is retained. Enter a value between 1 and 365000. The default value is 3650. The value of the KEEP parameter must be greater than or equal to the value of the DURATION parameter. TDengine automatically deletes data that is older than the value of the KEEP parameter. You can use m (minutes), h (hours), and d (days) as the unit, for example KEEP 100h or KEEP 10d. If you do not include a unit, d is used by default.
+- PAGES: specifies the number of pages in the metadata storage engine cache on each vnode. Enter a value greater than or equal to 64. The default value is 256. The space occupied by metadata storage on each vnode is equal to the product of the values of the PAGESIZE and PAGES parameters. The space occupied by default is 1 MB.
+- PAGESIZE: specifies the size (in KB) of each page in the metadata storage engine cache on each vnode. The default value is 4. Enter a value between 1 and 16384.
+- PRECISION: specifies the precision at which a database records timestamps. Enter ms for milliseconds, us for microseconds, or ns for nanoseconds. The default value is ms.
+- REPLICA: specifies the number of replicas that are made of the database. Enter 1 or 3. The default value is 1. The value of the REPLICA parameter cannot exceed the number of dnodes in the cluster.
+- RETENTIONS: specifies the retention period for data aggregated at various intervals. For example, RETENTIONS 15s:7d,1m:21d,15m:50d indicates that data aggregated every 15 seconds is retained for 7 days, data aggregated every 1 minute is retained for 21 days, and data aggregated every 15 minutes is retained for 50 days. You must enter three aggregation intervals and corresponding retention periods.
+- STRICT: specifies whether strong data consistency is enabled. The default value is off.
+ - on: Strong consistency is enabled and implemented through the Raft consensus algorithm. In this mode, an operation is considered successful once it is confirmed by half of the nodes in the cluster.
+ - off: Strong consistency is disabled. In this mode, an operation is considered successful when it is initiated by the local node.
+- WAL_LEVEL: specifies whether fsync is enabled. The default value is 1.
+ - 1: WAL is enabled but fsync is disabled.
+ - 2: WAL and fsync are both enabled.
+- VGROUPS: specifies the initial number of vgroups when a database is created.
+- SINGLE_STABLE: specifies whether the database can contain more than one supertable.
+ - 0: The database can contain multiple supertables.
+ - 1: The database can contain only one supertable.
+- WAL_RETENTION_PERIOD: specifies the time after which WAL files are deleted. This parameter is used for data subscription. Enter a time in seconds. The default value is 0. A value of 0 indicates that each WAL file is deleted immediately after its contents are written to disk. -1: WAL files are never deleted.
+- WAL_RETENTION_SIZE: specifies the size at which WAL files are deleted. This parameter is used for data subscription. Enter a size in KB. The default value is 0. A value of 0 indicates that each WAL file is deleted immediately after its contents are written to disk. -1: WAL files are never deleted.
+- WAL_ROLL_PERIOD: specifies the time after which WAL files are rotated. After this period elapses, a new WAL file is created. The default value is 0. A value of 0 indicates that a new WAL file is created only after the previous WAL file was written to disk.
+- WAL_SEGMENT_SIZE: specifies the maximum size of a WAL file. After the current WAL file reaches this size, a new WAL file is created. The default value is 0. A value of 0 indicates that a new WAL file is created only after the previous WAL file was written to disk.
+
+### Example Statement
+
+```sql
+create database if not exists db vgroups 10 buffer 10
+
+```
+
+The preceding SQL statement creates a database named db that has 10 vgroups and whose vnodes have a 10 MB cache.
+
+### Specify the Database in Use
```
-CREATE DATABASE [IF NOT EXISTS] db_name [KEEP keep] [DAYS days] [UPDATE 1];
+USE db_name;
```
-:::info
-
-1. KEEP specifies the number of days for which the data in the database will be retained. The default value is 3650 days, i.e. 10 years. The data will be deleted automatically once its age exceeds this threshold.
-2. UPDATE specifies whether the data can be updated and how the data can be updated.
- 1. UPDATE set to 0 means update operation is not allowed. The update for data with an existing timestamp will be discarded silently and the original record in the database will be preserved as is.
- 2. UPDATE set to 1 means the whole row will be updated. The columns for which no value is specified will be set to NULL.
- 3. UPDATE set to 2 means updating a subset of columns for a row is allowed. The columns for which no value is specified will be kept unchanged.
-3. The maximum length of database name is 33 bytes.
-4. The maximum length of a SQL statement is 65,480 bytes.
-5. Below are the parameters that can be used when creating a database
- - cache: [Description](/reference/config/#cache)
- - blocks: [Description](/reference/config/#blocks)
- - days: [Description](/reference/config/#days)
- - keep: [Description](/reference/config/#keep)
- - minRows: [Description](/reference/config/#minrows)
- - maxRows: [Description](/reference/config/#maxrows)
- - wal: [Description](/reference/config/#wallevel)
- - fsync: [Description](/reference/config/#fsync)
- - update: [Description](/reference/config/#update)
- - cacheLast: [Description](/reference/config/#cachelast)
- - replica: [Description](/reference/config/#replica)
- - quorum: [Description](/reference/config/#quorum)
- - comp: [Description](/reference/config/#comp)
- - precision: [Description](/reference/config/#precision)
-6. Please note that all of the parameters mentioned in this section are configured in configuration file `taos.cfg` on the TDengine server. If not specified in the `create database` statement, the values from taos.cfg are used by default. To override default parameters, they must be specified in the `create database` statement.
-
-:::
+The preceding SQL statement switches to the specified database. (If you connect to TDengine over the REST API, this statement does not take effect.)
-## Show Current Configuration
+## Drop a Database
```
-SHOW VARIABLES;
+DROP DATABASE [IF EXISTS] db_name
```
-## Specify The Database In Use
+The preceding SQL statement deletes the specified database. This statement will delete all tables in the database and destroy all vgroups associated with it. Exercise caution when using this statement.
-```
-USE db_name;
-```
-
-:::note
-This way is not applicable when using a REST connection. In a REST connection the database name must be specified before a table or stable name. For e.g. to query the stable "meters" in database "test" the query would be "SELECT count(*) from test.meters"
+## Change Database Configuration
-:::
+```sql
+ALTER DATABASE db_name [alter_database_options]
-## Drop Database
+alter_database_options:
+ alter_database_option ...
-```
-DROP DATABASE [IF EXISTS] db_name;
+alter_database_option: {
+ CACHEMODEL {'none' | 'last_row' | 'last_value' | 'both'}
+ | CACHESIZE value
+ | WAL_LEVEL value
+ | WAL_FSYNC_PERIOD value
+ | KEEP value
+}
```
:::note
-All data in the database will be deleted too. This command must be used with extreme caution. Please follow your organization's data integrity, data backup, data security or any other applicable SOPs before using this command.
+Other parameters cannot be modified after the database has been created.
:::
-## Change Database Configuration
+## View Databases
-Some examples are shown below to demonstrate how to change the configuration of a database. Please note that some configuration parameters can be changed after the database is created, but some cannot. For details of the configuration parameters of database please refer to [Configuration Parameters](/reference/config/).
+### View All Databases
```
-ALTER DATABASE db_name COMP 2;
-```
-
-COMP parameter specifies whether the data is compressed and how the data is compressed.
-
-```
-ALTER DATABASE db_name REPLICA 2;
-```
-
-REPLICA parameter specifies the number of replicas of the database.
-
-```
-ALTER DATABASE db_name KEEP 365;
+SHOW DATABASES;
```
-KEEP parameter specifies the number of days for which the data will be kept.
+### View the CREATE Statement for a Database
```
-ALTER DATABASE db_name QUORUM 2;
+SHOW CREATE DATABASE db_name;
```
-QUORUM parameter specifies the necessary number of confirmations to determine whether the data is written successfully.
+The preceding SQL statement can be used in migration scenarios. This command can be used to get the CREATE statement, which can be used in another TDengine instance to create the exact same database.
-```
-ALTER DATABASE db_name BLOCKS 100;
-```
+### View Database Configuration
-BLOCKS parameter specifies the number of memory blocks used by each VNODE.
-
-```
-ALTER DATABASE db_name CACHELAST 0;
+```sql
+SHOW DATABASES \G;
```
-CACHELAST parameter specifies whether and how the latest data of a sub table is cached.
+The preceding SQL statement shows the value of each parameter for the specified database. One value is displayed per line.
-:::tip
-The above parameters can be changed using `ALTER DATABASE` command without restarting. For more details of all configuration parameters please refer to [Configuration Parameters](/reference/config/).
-
-:::
+## Delete Expired Data
-## Show All Databases
-
-```
-SHOW DATABASES;
-```
-
-## Show The Create Statement of A Database
-
-```
-SHOW CREATE DATABASE db_name;
+```sql
+TRIM DATABASE db_name;
```
-This command is useful when migrating the data from one TDengine cluster to another. This command can be used to get the CREATE statement, which can be used in another TDengine instance to create the exact same database.
+The preceding SQL statement deletes data that has expired and orders the remaining data in accordance with the storage configuration.
diff --git a/docs/en/12-taos-sql/03-table.md b/docs/en/12-taos-sql/03-table.md
index f065a8e2396583bb7a512446b513ed60056ad55e..5a2c8ed6ee4a5ea129023fec68fa97d577832f60 100644
--- a/docs/en/12-taos-sql/03-table.md
+++ b/docs/en/12-taos-sql/03-table.md
@@ -1,127 +1,198 @@
---
-sidebar_label: Table
title: Table
-description: create super table, normal table and sub table, drop tables and change tables
---
## Create Table
-```
-CREATE TABLE [IF NOT EXISTS] tb_name (timestamp_field_name TIMESTAMP, field1_name data_type1 [, field2_name data_type2 ...]);
-```
-
-:::info
+You create standard tables and subtables with the `CREATE TABLE` statement.
+
+```sql
+CREATE TABLE [IF NOT EXISTS] [db_name.]tb_name (create_definition [, create_definitionn] ...) [table_options]
+
+CREATE TABLE create_subtable_clause
+
+CREATE TABLE [IF NOT EXISTS] [db_name.]tb_name (create_definition [, create_definitionn] ...)
+ [TAGS (create_definition [, create_definitionn] ...)]
+ [table_options]
+
+create_subtable_clause: {
+ create_subtable_clause [create_subtable_clause] ...
+ | [IF NOT EXISTS] [db_name.]tb_name USING [db_name.]stb_name [(tag_name [, tag_name] ...)] TAGS (tag_value [, tag_value] ...)
+}
+
+create_definition:
+ col_name column_definition
+
+column_definition:
+ type_name [comment 'string_value']
+
+table_options:
+ table_option ...
+
+table_option: {
+ COMMENT 'string_value'
+ | WATERMARK duration[,duration]
+ | MAX_DELAY duration[,duration]
+ | ROLLUP(func_name [, func_name] ...)
+ | SMA(col_name [, col_name] ...)
+ | TTL value
+}
+
+```
+
+**More explanations**
1. The first column of a table MUST be of type TIMESTAMP. It is automatically set as the primary key.
2. The maximum length of the table name is 192 bytes.
3. The maximum length of each row is 48k bytes, please note that the extra 2 bytes used by each BINARY/NCHAR column are also counted.
4. The name of the subtable can only consist of characters from the English alphabet, digits and underscore. Table names can't start with a digit. Table names are case insensitive.
5. The maximum length in bytes must be specified when using BINARY or NCHAR types.
-6. Escape character "\`" can be used to avoid the conflict between table names and reserved keywords, above rules will be bypassed when using escape character on table names, but the upper limit for the name length is still valid. The table names specified using escape character are case sensitive. Only ASCII visible characters can be used with escape character.
+6. Escape character "\`" can be used to avoid the conflict between table names and reserved keywords, above rules will be bypassed when using escape character on table names, but the upper limit for the name length is still valid. The table names specified using escape character are case sensitive.
For example \`aBc\` and \`abc\` are different table names but `abc` and `aBc` are same table names because they are both converted to `abc` internally.
+ Only ASCII visible characters can be used with escape character.
-:::
+**Parameter description**
+1. COMMENT: specifies comments for the table. This parameter can be used with supertables, standard tables, and subtables.
+2. WATERMARK: specifies the time after which the window is closed. The default value is 5 seconds. Enter a value between 0 and 15 minutes in milliseconds, seconds, or minutes. You can enter multiple values separated by commas (,). This parameter applies only to supertables and takes effect only when the RETENTIONS parameter has been specified for the database.
+3. MAX_DELAY: specifies the maximum latency for pushing computation results. The default value is 15 minutes or the value of the INTERVAL parameter, whichever is smaller. Enter a value between 0 and 15 minutes in milliseconds, seconds, or minutes. You can enter multiple values separated by commas (,). Note: Retain the default value if possible. Configuring a small MAX_DELAY may cause results to be frequently pushed, affecting storage and query performance. This parameter applies only to supertables and takes effect only when the RETENTIONS parameter has been specified for the database.
+4. ROLLUP: specifies aggregate functions to roll up. Rolling up a function provides downsampled results based on multiple axes. This parameter applies only to supertables and takes effect only when the RETENTIONS parameter has been specified for the database. You can specify only one function to roll up. The rollup takes effect on all columns except TS. Enter one of the following values: avg, sum, min, max, last, or first.
+5. SMA: specifies functions on which to enable small materialized aggregates (SMA). SMA is user-defined precomputation of aggregates based on data blocks. Enter one of the following values: max, min, or sum This parameter can be used with supertables and standard tables.
+6. TTL: specifies the time to live (TTL) for the table. If TTL is specified when creatinga table, after the time period for which the table has been existing is over TTL, TDengine will automatically delete the table. Please be noted that the system may not delete the table at the exact moment that the TTL expires but guarantee there is such a system and finally the table will be deleted. The unit of TTL is in days. The default value is 0, i.e. never expire.
-### Create Subtable Using STable As Template
+## Create Subtables
-```
+### Create a Subtable
+
+```sql
CREATE TABLE [IF NOT EXISTS] tb_name USING stb_name TAGS (tag_value1, ...);
```
-The above command creates a subtable using the specified super table as a template and the specified tag values.
+### Create a Subtable with Specified Tags
-### Create Subtable Using STable As Template With A Subset of Tags
-
-```
+```sql
CREATE TABLE [IF NOT EXISTS] tb_name USING stb_name (tag_name1, ...) TAGS (tag_value1, ...);
```
-The tags for which no value is specified will be set to NULL.
+The preceding SQL statement creates a subtable based on a supertable but specifies a subset of tags to use. Tags that are not included in this subset are assigned a null value.
-### Create Tables in Batch
+### Create Multiple Subtables
-```
+```sql
CREATE TABLE [IF NOT EXISTS] tb_name1 USING stb_name TAGS (tag_value1, ...) [IF NOT EXISTS] tb_name2 USING stb_name TAGS (tag_value2, ...) ...;
```
-This can be used to create a lot of tables in a single SQL statement while making table creation much faster.
+You can create multiple subtables in a single SQL statement provided that all subtables use the same supertable. For performance reasons, do not create more than 3000 tables per statement.
+
+## Modify a Table
-:::info
+```sql
+ALTER TABLE [db_name.]tb_name alter_table_clause
+
+alter_table_clause: {
+ alter_table_options
+ | ADD COLUMN col_name column_type
+ | DROP COLUMN col_name
+ | MODIFY COLUMN col_name column_type
+ | RENAME COLUMN old_col_name new_col_name
+}
+
+alter_table_options:
+ alter_table_option ...
+
+alter_table_option: {
+ TTL value
+ | COMMENT 'string_value'
+}
-- Creating tables in batch must use a super table as a template.
-- The length of single statement is suggested to be between 1,000 and 3,000 bytes for best performance.
+```
-:::
+**More explanations**
+You can perform the following modifications on existing tables:
+1. ADD COLUMN: adds a column to the supertable.
+2. DROP COLUMN: deletes a column from the supertable.
+3. MODIFY COLUMN: changes the length of the data type specified for the column. Note that you can only specify a length greater than the current length.
+4. RENAME COLUMN: renames a specified column in the table.
-## Drop Tables
+### Add a Column
-```
-DROP TABLE [IF EXISTS] tb_name;
+```sql
+ALTER TABLE tb_name ADD COLUMN field_name data_type;
```
-## Show All Tables In Current Database
+### Delete a Column
-```
-SHOW TABLES [LIKE tb_name_wildcard];
+```sql
+ALTER TABLE tb_name DROP COLUMN field_name;
```
-## Show Create Statement of A Table
+### Modify the Data Length
+```sql
+ALTER TABLE tb_name MODIFY COLUMN field_name data_type(length);
```
-SHOW CREATE TABLE tb_name;
-```
-
-This is useful when migrating the data in one TDengine cluster to another one because it can be used to create the exact same tables in the target database.
-## Show Table Definition
+### Rename a Column
+```sql
+ALTER TABLE tb_name RENAME COLUMN old_col_name new_col_name
```
-DESCRIBE tb_name;
+
+## Modify a Subtable
+
+```sql
+ALTER TABLE [db_name.]tb_name alter_table_clause
+
+alter_table_clause: {
+ alter_table_options
+ | SET TAG tag_name = new_tag_value
+}
+
+alter_table_options:
+ alter_table_option ...
+
+alter_table_option: {
+ TTL value
+ | COMMENT 'string_value'
+}
```
-## Change Table Definition
+**More explanations**
+1. Only the value of a tag can be modified directly. For all other modifications, you must modify the supertable from which the subtable was created.
-### Add A Column
+### Change Tag Value Of Sub Table
```
-ALTER TABLE tb_name ADD COLUMN field_name data_type;
+ALTER TABLE tb_name SET TAG tag_name=new_tag_value;
```
-:::info
+## Delete a Table
-1. The maximum number of columns is 4096, the minimum number of columns is 2.
-2. The maximum length of a column name is 64 bytes.
+The following SQL statement deletes one or more tables.
-:::
-
-### Remove A Column
-
-```
-ALTER TABLE tb_name DROP COLUMN field_name;
+```sql
+DROP TABLE [IF EXISTS] [db_name.]tb_name [, [IF EXISTS] [db_name.]tb_name] ...
```
-:::note
-If a table is created using a super table as template, the table definition can only be changed on the corresponding super table, and the change will be automatically applied to all the subtables created using this super table as template. For tables created in the normal way, the table definition can be changed directly on the table.
+## View Tables
-:::
+### View All Tables
-### Change Column Length
+The following SQL statement shows all tables in the current database.
-```
-ALTER TABLE tb_name MODIFY COLUMN field_name data_type(length);
+```sql
+SHOW TABLES [LIKE tb_name_wildchar];
```
-If the type of a column is variable length, like BINARY or NCHAR, this command can be used to change the length of the column.
+### View the CREATE Statement for a Table
-:::note
-If a table is created using a super table as template, the table definition can only be changed on the corresponding super table, and the change will be automatically applied to all the subtables created using this super table as template. For tables created in the normal way, the table definition can be changed directly on the table.
+```
+SHOW CREATE TABLE tb_name;
+```
-:::
+This command is useful in migrating data from one TDengine cluster to another because it can be used to create the exact same tables in the target database.
-### Change Tag Value Of Sub Table
+## View the Table Schema
```
-ALTER TABLE tb_name SET TAG tag_name=new_tag_value;
-```
-
-This command can be used to change the tag value if the table is created using a super table as template.
+DESCRIBE [db_name.]tb_name;
+```
\ No newline at end of file
diff --git a/docs/en/12-taos-sql/04-stable.md b/docs/en/12-taos-sql/04-stable.md
index b8a608792ab327a81129d29ddd0ff44d7af6e6c5..6a0a0922cce7d9f831f333e4999789798be8d867 100644
--- a/docs/en/12-taos-sql/04-stable.md
+++ b/docs/en/12-taos-sql/04-stable.md
@@ -1,118 +1,159 @@
---
-sidebar_label: STable
-title: Super Table
+sidebar_label: Supertable
+title: Supertable
---
-:::note
+## Create a Supertable
-Keyword `STable`, abbreviated for super table, is supported since version 2.0.15.
+```sql
+CREATE STABLE [IF NOT EXISTS] stb_name (create_definition [, create_definitionn] ...) TAGS (create_definition [, create_definition] ...) [table_options]
+
+create_definition:
+ col_name column_definition
+
+column_definition:
+ type_name [COMMENT 'string_value']
+```
-:::
+**More explanations**
+- Each supertable can have a maximum of 4096 columns, including tags. The minimum number of columns is 3: a timestamp column used as the key, one tag column, and one data column.
+- When you create a supertable, you can add comments to columns and tags.
+- The TAGS keyword defines the tag columns for the supertable. The following restrictions apply to tag columns:
+ - A tag column can use the TIMESTAMP data type, but the values in the column must be fixed numbers. Timestamps including formulae, such as "now + 10s", cannot be stored in a tag column.
+ - The name of a tag column cannot be the same as the name of any other column.
+ - The name of a tag column cannot be a reserved keyword.
+ - Each supertable must contain between 1 and 128 tags. The total length of the TAGS keyword cannot exceed 16 KB.
+- For more information about table parameters, see Create a Table.
-## Create STable
+## View a Supertable
+
+### View All Supertables
```
-CREATE STable [IF NOT EXISTS] stb_name (timestamp_field_name TIMESTAMP, field1_name data_type1 [, field2_name data_type2 ...]) TAGS (tag1_name tag_type1, tag2_name tag_type2 [, tag3_name tag_type3]);
+SHOW STABLES [LIKE tb_name_wildcard];
```
-The SQL statement of creating a STable is similar to that of creating a table, but a special column set named `TAGS` must be specified with the names and types of the tags.
-
-:::info
+The preceding SQL statement shows all supertables in the current TDengine database, including the name, creation time, number of columns, number of tags, and number of subtabels for each supertable.
-1. A tag can be of type timestamp, since version 2.1.3.0, but its value must be fixed and arithmetic operations cannot be performed on it. Prior to version 2.1.3.0, tag types specified in TAGS could not be of type timestamp.
-2. The tag names specified in TAGS should NOT be the same as other columns.
-3. The tag names specified in TAGS should NOT be the same as any reserved keywords.(Please refer to [keywords](/taos-sql/keywords/)
-4. The maximum number of tags specified in TAGS is 128, there must be at least one tag, and the total length of all tag columns should NOT exceed 16KB.
-
-:::
-
-## Drop STable
+### View the CREATE Statement for a Supertable
```
-DROP STable [IF EXISTS] stb_name;
+SHOW CREATE STABLE stb_name;
```
-All the subtables created using the deleted STable will be deleted automatically.
+The preceding SQL statement can be used in migration scenarios. It returns the CREATE statement that was used to create the specified supertable. You can then use the returned statement to create an identical supertable on another TDengine database.
-## Show All STables
+## View the Supertable Schema
```
-SHOW STableS [LIKE tb_name_wildcard];
+DESCRIBE [db_name.]stb_name;
```
-This command can be used to display the information of all STables in the current database, including name, creation time, number of columns, number of tags, and number of tables created using this STable.
-
-## Show The Create Statement of A STable
+## Drop STable
```
-SHOW CREATE STable stb_name;
+DROP STABLE [IF EXISTS] [db_name.]stb_name
```
-This command is useful in migrating data from one TDengine cluster to another because it can be used to create the exact same STable in the target database.
+Note: Deleting a supertable will delete all subtables created from the supertable, including all data within those subtables.
-## Get STable Definition
+## Modify a Supertable
+
+```sql
+ALTER STABLE [db_name.]tb_name alter_table_clause
+
+alter_table_clause: {
+ alter_table_options
+ | ADD COLUMN col_name column_type
+ | DROP COLUMN col_name
+ | MODIFY COLUMN col_name column_type
+ | ADD TAG tag_name tag_type
+ | DROP TAG tag_name
+ | MODIFY TAG tag_name tag_type
+ | RENAME TAG old_tag_name new_tag_name
+}
+
+alter_table_options:
+ alter_table_option ...
+
+alter_table_option: {
+ COMMENT 'string_value'
+}
```
-DESCRIBE stb_name;
-```
-## Change Columns Of STable
+**More explanations**
+
+Modifications to the table schema of a supertable take effect on all subtables within the supertable. You cannot modify the table schema of subtables individually. When you modify the tag schema of a supertable, the modifications automatically take effect on all of its subtables.
+
+- ADD COLUMN: adds a column to the supertable.
+- DROP COLUMN: deletes a column from the supertable.
+- MODIFY COLUMN: changes the length of a BINARY or NCHAR column. Note that you can only specify a length greater than the current length.
+- ADD TAG: adds a tag to the supertable.
+- DROP TAG: deletes a tag from the supertable. When you delete a tag from a supertable, it is automatically deleted from all subtables within the supertable.
+- MODIFY TAG: modifies the definition of a tag in the supertable. You can use this keyword to change the length of a BINARY or NCHAR tag column. Note that you can only specify a length greater than the current length.
+- RENAME TAG: renames a specified tag in the supertable. When you rename a tag in a supertable, it is automatically renamed in all subtables within the supertable.
-### Add A Column
+### Add a Column
```
-ALTER STable stb_name ADD COLUMN field_name data_type;
+ALTER STABLE stb_name ADD COLUMN col_name column_type;
```
-### Remove A Column
+### Delete a Column
```
-ALTER STable stb_name DROP COLUMN field_name;
+ALTER STABLE stb_name DROP COLUMN col_name;
```
-### Change Column Length
+### Modify the Data Length
```
-ALTER STable stb_name MODIFY COLUMN field_name data_type(length);
+ALTER STABLE stb_name MODIFY COLUMN col_name data_type(length);
```
-This command can be used to change (or more specifically, increase) the length of a column of variable length types, like BINARY or NCHAR.
-
-## Change Tags of A STable
+The preceding SQL statement changes the length of a BINARY or NCHAR data column. Note that you can only specify a length greater than the current length.
### Add A Tag
```
-ALTER STable stb_name ADD TAG new_tag_name tag_type;
+ALTER STABLE stb_name ADD TAG tag_name tag_type;
```
-This command is used to add a new tag for a STable and specify the tag type.
+The preceding SQL statement adds a tag of the specified type to the supertable. A supertable cannot contain more than 128 tags. The total length of all tags in a supertable cannot exceed 16 KB.
### Remove A Tag
```
-ALTER STable stb_name DROP TAG tag_name;
+ALTER STABLE stb_name DROP TAG tag_name;
```
-The tag will be removed automatically from all the subtables, created using the super table as template, once a tag is removed from a super table.
+The preceding SQL statement deletes a tag from the supertable. When you delete a tag from a supertable, it is automatically deleted from all subtables within the supertable.
### Change A Tag
```
-ALTER STable stb_name CHANGE TAG old_tag_name new_tag_name;
+ALTER STABLE stb_name RENAME TAG old_tag_name new_tag_name;
```
-The tag name will be changed automatically for all the subtables, created using the super table as template, once a tag name is changed for a super table.
+The preceding SQL statement renames a tag in the supertable. When you rename a tag in a supertable, it is automatically renamed in all subtables within the supertable.
### Change Tag Length
```
-ALTER STable stb_name MODIFY TAG tag_name data_type(length);
+ALTER STABLE stb_name MODIFY TAG tag_name data_type(length);
```
-This command can be used to change (or more specifically, increase) the length of a tag of variable length types, like BINARY or NCHAR.
+The preceding SQL statement changes the length of a BINARY or NCHAR tag column. Note that you can only specify a length greater than the current length. (Available in 2.1.3.0 and later versions)
+
+### View a Supertable
+You can run projection and aggregate SELECT queries on supertables, and you can filter by tag or column by using the WHERE keyword.
+
+If you do not include an ORDER BY clause, results are returned by subtable. These results are not ordered. You can include an ORDER BY clause in your query to strictly order the results.
+
+
:::note
-Changing tag values can be applied to only subtables. All other tag operations, like add tag, remove tag, however, can be applied to only STable. If a new tag is added for a STable, the tag will be added with NULL value for all its subtables.
+All tag operations except for updating the value of a tag must be performed on the supertable and not on individual subtables. If you add a tag to an existing supertable, the tag is automatically added with a null value to all subtables within the supertable.
:::
diff --git a/docs/en/12-taos-sql/05-insert.md b/docs/en/12-taos-sql/05-insert.md
index 1336cd7238a19190583ea9d268a64df242ffd3c9..e7d56fb3c734affa92c8c71c190b1132cd89e335 100644
--- a/docs/en/12-taos-sql/05-insert.md
+++ b/docs/en/12-taos-sql/05-insert.md
@@ -1,4 +1,5 @@
---
+sidebar_label: Insert
title: Insert
---
@@ -17,47 +18,62 @@ INSERT INTO
...];
```
-## Insert Single or Multiple Rows
+**Timestamps**
-Single row or multiple rows specified with VALUES can be inserted into a specific table. For example:
+1. All data writes must include a timestamp. With regard to timestamps, note the following:
-A single row is inserted using the below statement.
+2. The precision of a timestamp depends on its format. The precision configured for the database affects only timestamps that are inserted as long integers (UNIX time). Timestamps inserted as date and time strings are not affected. As an example, the timestamp 2021-07-13 16:16:48 is equivalent to 1626164208 in UNIX time. This UNIX time is modified to 1626164208000 for databases with millisecond precision, 1626164208000000 for databases with microsecond precision, and 1626164208000000000 for databases with nanosecond precision.
-```sq;
+3. If you want to insert multiple rows simultaneously, do not use the NOW function in the timestamp. Using the NOW function in this situation will cause multiple rows to have the same timestamp and prevent them from being stored correctly. This is because the NOW function obtains the current time on the client, and multiple instances of NOW in a single statement will return the same time.
+ The earliest timestamp that you can use when inserting data is equal to the current time on the server minus the value of the KEEP parameter. The latest timestamp that you can use when inserting data is equal to the current time on the server plus the value of the DURATION parameter. You can configure the KEEP and DURATION parameters when you create a database. The default values are 3650 days for the KEEP parameter and 10 days for the DURATION parameter.
+
+**Syntax**
+
+1. The USING clause automatically creates the specified subtable if it does not exist. If it's unknown whether the table already exists, the table can be created automatically while inserting using the SQL statement below. To use this functionality, a STable must be used as template and tag values must be provided. Any tags that you do not specify will be assigned a null value.
+
+2. You can insert data into specified columns. Any columns in which you do not insert data will be assigned a null value.
+
+3. The VALUES clause inserts one or more rows of data into a table.
+
+4. The FILE clause inserts tags or data from a comma-separates values (CSV) file. Do not include headers in your CSV files.
+
+5. A single INSERT statement can write data to multiple tables.
+
+6. The INSERT statement is fully parsed before being executed, so that if any element of the statement fails, the entire statement will fail. For example, the following statement will not create a table because the latter part of the statement is invalid:
+
+ ```sql
+ INSERT INTO d1001 USING meters TAGS('Beijing.Chaoyang', 2) VALUES('a');
+ ```
+
+7. However, an INSERT statement that writes data to multiple subtables can succeed for some tables and fail for others. This situation is caused because vnodes perform write operations independently of each other. One vnode failing to write data does not affect the ability of other vnodes to write successfully.
+
+## Insert a Record
+
+Single row or multiple rows specified with VALUES can be inserted into a specific table. A single row is inserted using the below statement.
+
+```sql
INSERT INTO d1001 VALUES (NOW, 10.2, 219, 0.32);
```
+## Insert Multiple Records
+
Double rows are inserted using the below statement.
```sql
INSERT INTO d1001 VALUES ('2021-07-13 14:06:32.272', 10.2, 219, 0.32) (1626164208000, 10.15, 217, 0.33);
```
-:::note
-
-1. In the second example above, different formats are used in the two rows to be inserted. In the first row, the timestamp format is a date and time string, which is interpreted from the string value only. In the second row, the timestamp format is a long integer, which will be interpreted based on the database time precision.
-2. When trying to insert multiple rows in a single statement, only the timestamp of one row can be set as NOW, otherwise there will be duplicate timestamps among the rows and the result may be out of expectation because NOW will be interpreted as the time when the statement is executed.
-3. The oldest timestamp that is allowed is subtracting the KEEP parameter from current time.
-4. The newest timestamp that is allowed is adding the DAYS parameter to current time.
-
-:::
-
-## Insert Into Specific Columns
+## Write to a Specified Column
-Data can be inserted into specific columns, either single row or multiple row, while other columns will be inserted as NULL value.
+Data can be inserted into specific columns, either single row or multiple row, while other columns will be inserted as NULL value. The key (timestamp) cannot be null. For example:
-```
+```sql
INSERT INTO d1001 (ts, current, phase) VALUES ('2021-07-13 14:06:33.196', 10.27, 0.31);
```
-:::info
-If no columns are explicitly specified, all the columns must be provided with values, this is called "all column mode". The insert performance of all column mode is much better than specifying a subset of columns, so it's encouraged to use "all column mode" while providing NULL value explicitly for the columns for which no actual value can be provided.
-
-:::
-
## Insert Into Multiple Tables
-One or multiple rows can be inserted into multiple tables in a single SQL statement, with or without specifying specific columns.
+One or multiple rows can be inserted into multiple tables in a single SQL statement, with or without specifying specific columns. For example:
```sql
INSERT INTO d1001 VALUES ('2021-07-13 14:06:34.630', 10.2, 219, 0.32) ('2021-07-13 14:06:35.779', 10.15, 217, 0.33)
@@ -66,19 +82,19 @@ INSERT INTO d1001 VALUES ('2021-07-13 14:06:34.630', 10.2, 219, 0.32) ('2021-07-
## Automatically Create Table When Inserting
-If it's unknown whether the table already exists, the table can be created automatically while inserting using the SQL statement below. To use this functionality, a STable must be used as template and tag values must be provided.
+If it's unknown whether the table already exists, the table can be created automatically while inserting using the SQL statement below. To use this functionality, a STable must be used as template and tag values must be provided. For example:
```sql
INSERT INTO d21001 USING meters TAGS ('California.SanFrancisco', 2) VALUES ('2021-07-13 14:06:32.272', 10.2, 219, 0.32);
```
-It's not necessary to provide values for all tags when creating tables automatically, the tags without values provided will be set to NULL.
+It's not necessary to provide values for all tags when creating tables automatically, the tags without values provided will be set to NULL. For example:
```sql
INSERT INTO d21001 USING meters (groupId) TAGS (2) VALUES ('2021-07-13 14:06:33.196', 10.15, 217, 0.33);
```
-Multiple rows can also be inserted into the same table in a single SQL statement.
+Multiple rows can also be inserted into the same table in a single SQL statement. For example:
```sql
INSERT INTO d21001 USING meters TAGS ('California.SanFrancisco', 2) VALUES ('2021-07-13 14:06:34.630', 10.2, 219, 0.32) ('2021-07-13 14:06:35.779', 10.15, 217, 0.33)
@@ -86,10 +102,6 @@ INSERT INTO d21001 USING meters TAGS ('California.SanFrancisco', 2) VALUES ('202
d21003 USING meters (groupId) TAGS (2) (ts, current, phase) VALUES ('2021-07-13 14:06:34.255', 10.27, 0.31);
```
-:::info
-Prior to version 2.0.20.5, when using `INSERT` to create tables automatically and specifying the columns, the column names must follow the table name immediately. From version 2.0.20.5, the column names can follow the table name immediately, also can be put between `TAGS` and `VALUES`. In the same SQL statement, however, these two ways of specifying column names can't be mixed.
-:::
-
## Insert Rows From A File
Besides using `VALUES` to insert one or multiple rows, the data to be inserted can also be prepared in a CSV file with comma as separator and each field value quoted by single quotes. Table definition is not required in the CSV file. For example, if file "/tmp/csvfile.csv" contains the below data:
@@ -107,58 +119,13 @@ INSERT INTO d1001 FILE '/tmp/csvfile.csv';
## Create Tables Automatically and Insert Rows From File
-From version 2.1.5.0, tables can be automatically created using a super table as template when inserting data from a CSV file, like below:
-
```sql
INSERT INTO d21001 USING meters TAGS ('California.SanFrancisco', 2) FILE '/tmp/csvfile.csv';
```
-Multiple tables can be automatically created and inserted in a single SQL statement, like below:
+When writing data from a file, you can automatically create the specified subtable if it does not exist. For example:
```sql
INSERT INTO d21001 USING meters TAGS ('California.SanFrancisco', 2) FILE '/tmp/csvfile_21001.csv'
d21002 USING meters (groupId) TAGS (2) FILE '/tmp/csvfile_21002.csv';
```
-
-## More About Insert
-
-For SQL statement like `insert`, a stream parsing strategy is applied. That means before an error is found and the execution is aborted, the part prior to the error point has already been executed. Below is an experiment to help understand the behavior.
-
-First, a super table is created.
-
-```sql
-CREATE TABLE meters(ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS(location BINARY(30), groupId INT);
-```
-
-It can be proven that the super table has been created by `SHOW STableS`, but no table exists using `SHOW TABLES`.
-
-```
-taos> SHOW STableS;
- name | created_time | columns | tags | tables |
-============================================================================================
- meters | 2020-08-06 17:50:27.831 | 4 | 2 | 0 |
-Query OK, 1 row(s) in set (0.001029s)
-
-taos> SHOW TABLES;
-Query OK, 0 row(s) in set (0.000946s)
-```
-
-Then, try to create table d1001 automatically when inserting data into it.
-
-```sql
-INSERT INTO d1001 USING meters TAGS('California.SanFrancisco', 2) VALUES('a');
-```
-
-The output shows the value to be inserted is invalid. But `SHOW TABLES` proves that the table has been created automatically by the `INSERT` statement.
-
-```
-DB error: invalid SQL: 'a' (invalid timestamp) (0.039494s)
-
-taos> SHOW TABLES;
- table_name | created_time | columns | STable_name |
-======================================================================================================
- d1001 | 2020-08-06 17:52:02.097 | 4 | meters |
-Query OK, 1 row(s) in set (0.001091s)
-```
-
-From the above experiment, we can see that while the value to be inserted is invalid the table is still created.
diff --git a/docs/en/12-taos-sql/06-select.md b/docs/en/12-taos-sql/06-select.md
index 8a017cf92e40aa4a854dcd531b7df291a9243515..1dd0caed38235d3d10813b2cd74fec6446c5ec24 100644
--- a/docs/en/12-taos-sql/06-select.md
+++ b/docs/en/12-taos-sql/06-select.md
@@ -1,118 +1,124 @@
---
+sidebar_label: Select
title: Select
---
## Syntax
-```SQL
-SELECT select_expr [, select_expr ...]
- FROM {tb_name_list}
- [WHERE where_condition]
- [SESSION(ts_col, tol_val)]
- [STATE_WINDOW(col)]
- [INTERVAL(interval_val [, interval_offset]) [SLIDING sliding_val]]
- [FILL(fill_mod_and_val)]
- [GROUP BY col_list]
- [ORDER BY col_list { DESC | ASC }]
+```sql
+SELECT {DATABASE() | CLIENT_VERSION() | SERVER_VERSION() | SERVER_STATUS() | NOW() | TODAY() | TIMEZONE()}
+
+SELECT [DISTINCT] select_list
+ from_clause
+ [WHERE condition]
+ [PARTITION BY tag_list]
+ [window_clause]
+ [group_by_clause]
+ [order_by_clasue]
[SLIMIT limit_val [SOFFSET offset_val]]
[LIMIT limit_val [OFFSET offset_val]]
- [>> export_file];
-```
+ [>> export_file]
-## Wildcard
+select_list:
+ select_expr [, select_expr] ...
-Wildcard \* can be used to specify all columns. The result includes only data columns for normal tables.
+select_expr: {
+ *
+ | query_name.*
+ | [schema_name.] {table_name | view_name} .*
+ | t_alias.*
+ | expr [[AS] c_alias]
+}
-```
-taos> SELECT * FROM d1001;
- ts | current | voltage | phase |
-======================================================================================
- 2018-10-03 14:38:05.000 | 10.30000 | 219 | 0.31000 |
- 2018-10-03 14:38:15.000 | 12.60000 | 218 | 0.33000 |
- 2018-10-03 14:38:16.800 | 12.30000 | 221 | 0.31000 |
-Query OK, 3 row(s) in set (0.001165s)
-```
+from_clause: {
+ table_reference [, table_reference] ...
+ | join_clause [, join_clause] ...
+}
+
+table_reference:
+ table_expr t_alias
+
+table_expr: {
+ table_name
+ | view_name
+ | ( subquery )
+}
-The result includes both data columns and tag columns for super table.
+join_clause:
+ table_reference [INNER] JOIN table_reference ON condition
+window_clause: {
+ SESSION(ts_col, tol_val)
+ | STATE_WINDOW(col)
+ | INTERVAL(interval_val [, interval_offset]) [SLIDING (sliding_val)] [WATERMARK(watermark_val)] [FILL(fill_mod_and_val)]
+
+changes_option: {
+ DURATION duration_val
+ | ROWS rows_val
+}
+
+group_by_clause:
+ GROUP BY expr [, expr] ... HAVING condition
+
+order_by_clasue:
+ ORDER BY order_expr [, order_expr] ...
+
+order_expr:
+ {expr | position | c_alias} [DESC | ASC] [NULLS FIRST | NULLS LAST]
```
-taos> SELECT * FROM meters;
- ts | current | voltage | phase | location | groupid |
-=====================================================================================================================================
- 2018-10-03 14:38:05.500 | 11.80000 | 221 | 0.28000 | California.LoSangeles | 2 |
- 2018-10-03 14:38:16.600 | 13.40000 | 223 | 0.29000 | California.LoSangeles | 2 |
- 2018-10-03 14:38:05.000 | 10.80000 | 223 | 0.29000 | California.LoSangeles | 3 |
- 2018-10-03 14:38:06.500 | 11.50000 | 221 | 0.35000 | California.LoSangeles | 3 |
- 2018-10-03 14:38:04.000 | 10.20000 | 220 | 0.23000 | California.SanFrancisco | 3 |
- 2018-10-03 14:38:16.650 | 10.30000 | 218 | 0.25000 | California.SanFrancisco | 3 |
- 2018-10-03 14:38:05.000 | 10.30000 | 219 | 0.31000 | California.SanFrancisco | 2 |
- 2018-10-03 14:38:15.000 | 12.60000 | 218 | 0.33000 | California.SanFrancisco | 2 |
- 2018-10-03 14:38:16.800 | 12.30000 | 221 | 0.31000 | California.SanFrancisco | 2 |
-Query OK, 9 row(s) in set (0.002022s)
+
+## Lists
+
+A query can be performed on some or all columns. Data and tag columns can all be included in the SELECT list.
+
+## Wildcards
+
+You can use an asterisk (\*) as a wildcard character to indicate all columns. For standard tables, the asterisk indicates only data columns. For supertables and subtables, tag columns are also included.
+
+```sql
+SELECT * FROM d1001;
```
-Wildcard can be used with table name as prefix. Both SQL statements below have the same effect and return all columns.
+You can use a table name as a prefix before an asterisk. For example, the following SQL statements both return all columns from the d1001 table:
-```SQL
+```sql
SELECT * FROM d1001;
SELECT d1001.* FROM d1001;
```
-In a JOIN query, however, the results are different with or without a table name prefix. \* without table prefix will return all the columns of both tables, but \* with table name as prefix will return only the columns of that table.
+However, in a JOIN query, using a table name prefix with an asterisk returns different results. In this case, querying * returns all data in all columns in all tables (not including tags), whereas using a table name prefix returns all data in all columns in the specified table only.
-```
-taos> SELECT * FROM d1001, d1003 WHERE d1001.ts=d1003.ts;
- ts | current | voltage | phase | ts | current | voltage | phase |
-==================================================================================================================================
- 2018-10-03 14:38:05.000 | 10.30000| 219 | 0.31000 | 2018-10-03 14:38:05.000 | 10.80000| 223 | 0.29000 |
-Query OK, 1 row(s) in set (0.017385s)
+```sql
+SELECT * FROM d1001, d1003 WHERE d1001.ts=d1003.ts;
+SELECT d1001.* FROM d1001,d1003 WHERE d1001.ts = d1003.ts;
```
-```
-taos> SELECT d1001.* FROM d1001,d1003 WHERE d1001.ts = d1003.ts;
- ts | current | voltage | phase |
-======================================================================================
- 2018-10-03 14:38:05.000 | 10.30000 | 219 | 0.31000 |
-Query OK, 1 row(s) in set (0.020443s)
-```
+The first of the preceding SQL statements returns all columns from the d1001 and d1003 tables, but the second of the preceding SQL statements returns all columns from the d1001 table only.
-Wildcard \* can be used with some functions, but the result may be different depending on the function being used. For example, `count(*)` returns only one column, i.e. the number of rows; `first`, `last` and `last_row` return all columns of the selected row.
+With regard to the other SQL functions that support wildcards, the differences are as follows:
+`count(*)` only returns one column. `first`, `last`, and `last_row` return all columns.
-```
-taos> SELECT COUNT(*) FROM d1001;
- count(*) |
-========================
- 3 |
-Query OK, 1 row(s) in set (0.001035s)
-```
+### Tag Columns
-```
-taos> SELECT FIRST(*) FROM d1001;
- first(ts) | first(current) | first(voltage) | first(phase) |
-=========================================================================================
- 2018-10-03 14:38:05.000 | 10.30000 | 219 | 0.31000 |
-Query OK, 1 row(s) in set (0.000849s)
+You can query tag columns in supertables and subtables and receive results in the same way as querying data columns.
+
+```sql
+SELECT location, groupid, current FROM d1001 LIMIT 2;
```
-## Tags
+### Distinct Values
-Starting from version 2.0.14, tag columns can be selected together with data columns when querying sub tables. Please note however, that, wildcard \* cannot be used to represent any tag column. This means that tag columns must be specified explicitly like the example below.
+The DISTINCT keyword returns only values that are different over one or more columns. You can use the DISTINCT keyword with tag columns and data columns.
-```
-taos> SELECT location, groupid, current FROM d1001 LIMIT 2;
- location | groupid | current |
-======================================================================
- California.SanFrancisco | 2 | 10.30000 |
- California.SanFrancisco | 2 | 12.60000 |
-Query OK, 2 row(s) in set (0.003112s)
-```
+The following SQL statement returns distinct values from a tag column:
-## Get distinct values
+```sql
+SELECT DISTINCT tag_name [, tag_name ...] FROM stb_name;
+```
-`DISTINCT` keyword can be used to get all the unique values of tag columns from a super table. It can also be used to get all the unique values of data columns from a table or subtable.
+The following SQL statement returns distinct values from a data column:
```sql
-SELECT DISTINCT tag_name [, tag_name ...] FROM stb_name;
SELECT DISTINCT col_name [, col_name ...] FROM tb_name;
```
@@ -124,231 +130,188 @@ SELECT DISTINCT col_name [, col_name ...] FROM tb_name;
:::
-## Columns Names of Result Set
+### Column Names
-When using `SELECT`, the column names in the result set will be the same as that in the select clause if `AS` is not used. `AS` can be used to rename the column names in the result set. For example
+When using `SELECT`, the column names in the result set will be the same as that in the select clause if `AS` is not used. `AS` can be used to rename the column names in the result set. For example:
-```
+```sql
taos> SELECT ts, ts AS primary_key_ts FROM d1001;
- ts | primary_key_ts |
-====================================================
- 2018-10-03 14:38:05.000 | 2018-10-03 14:38:05.000 |
- 2018-10-03 14:38:15.000 | 2018-10-03 14:38:15.000 |
- 2018-10-03 14:38:16.800 | 2018-10-03 14:38:16.800 |
-Query OK, 3 row(s) in set (0.001191s)
```
`AS` can't be used together with `first(*)`, `last(*)`, or `last_row(*)`.
-## Implicit Columns
+### Pseudocolumns
+
+**TBNAME**
+The TBNAME pseudocolumn in a supertable contains the names of subtables within the supertable.
-`Select_exprs` can be column names of a table, or function expression or arithmetic expression on columns. The maximum number of allowed column names and expressions is 256. Timestamp and the corresponding tag names will be returned in the result set if `interval` or `group by tags` are used, and timestamp will always be the first column in the result set.
+The following SQL statement returns all unique subtable names and locations within the meters supertable:
-## Table List
+```mysql
+SELECT DISTINCT TBNAME, location FROM meters;
+```
-`FROM` can be followed by a number of tables or super tables, or can be followed by a sub-query. If no database is specified as current database in use, table names must be preceded with database name, like `power.d1001`.
+Use the `INS_TAGS` system table in `INFORMATION_SCHEMA` to query the information for subtables in a supertable. For example, the following statement returns the name and tag values for each subtable in the `meters` supertable.
-```SQL
-SELECT * FROM power.d1001;
+```mysql
+SELECT table_name, tag_name, tag_type, tag_value FROM information_schema.ins_tags WHERE stable_name='meters';
```
-has same effect as
+The following SQL statement returns the number of subtables within the meters supertable.
-```SQL
-USE power;
-SELECT * FROM d1001;
+```mysql
+SELECT COUNT(*) FROM (SELECT DISTINCT TBNAME FROM meters);
```
-## Special Query
+In the preceding two statements, only tags can be used as filtering conditions in the WHERE clause. For example:
-Some special query functions can be invoked without `FROM` sub-clause. For example, the statement below can be used to get the current database in use.
+**\_QSTART and \_QEND**
-```
-taos> SELECT DATABASE();
- database() |
-=================================
- power |
-Query OK, 1 row(s) in set (0.000079s)
-```
+The \_QSTART and \_QEND pseudocolumns contain the beginning and end of the time range of a query. If the WHERE clause in a statement does not contain valid timestamps, the time range is equal to [-2^63, 2^63 - 1].
-If no database is specified upon logging in and no database is specified with `USE` after login, NULL will be returned by `select database()`.
+The \_QSTART and \_QEND pseudocolumns cannot be used in a WHERE clause.
-```
-taos> SELECT DATABASE();
- database() |
-=================================
- NULL |
-Query OK, 1 row(s) in set (0.000184s)
-```
+**\_WSTART, \_WEND, and \_WDURATION**
-The statement below can be used to get the version of client or server.
+The \_WSTART, \_WEND, and \_WDURATION pseudocolumns indicate the beginning, end, and duration of a window.
-```
-taos> SELECT CLIENT_VERSION();
- client_version() |
-===================
- 2.0.0.0 |
-Query OK, 1 row(s) in set (0.000070s)
+These pseudocolumns can be used only in time window-based aggregations and must occur after the aggregation clause.
-taos> SELECT SERVER_VERSION();
- server_version() |
-===================
- 2.0.0.0 |
-Query OK, 1 row(s) in set (0.000077s)
-```
+**\_c0 and \_ROWTS**
-The statement below is used to check the server status. An integer, like `1`, is returned if the server status is OK, otherwise an error code is returned. This is compatible with the status check for TDengine from connection pool or 3rd party tools, and can avoid the problem of losing the connection from a connection pool when using the wrong heartbeat checking SQL statement.
+In TDengine, the first column of all tables must be a timestamp. This column is the primary key of the table. The \_c0 and \_ROWTS pseudocolumns both represent the values of this column. These pseudocolumns enable greater flexibility and standardization. For example, you can use functions such as MAX and MIN with these pseudocolumns.
+```sql
+select _rowts, max(current) from meters;
```
-taos> SELECT SERVER_STATUS();
- server_status() |
-==================
- 1 |
-Query OK, 1 row(s) in set (0.000074s)
-taos> SELECT SERVER_STATUS() AS status;
- status |
-==============
- 1 |
-Query OK, 1 row(s) in set (0.000081s)
-```
+## Query Objects
-## \_block_dist
+`FROM` can be followed by a number of tables or super tables, or can be followed by a sub-query.
+If no database is specified as current database in use, table names must be preceded with database name, for example, `power.d1001`.
-**Description**: Get the data block distribution of a table or STable.
+You can perform INNER JOIN statements based on the primary key. The following conditions apply:
-```SQL title="Syntax"
-SELECT _block_dist() FROM { tb_name | stb_name }
-```
+1. You can use FROM table list or an explicit JOIN clause.
+2. For standard tables and subtables, you must specify an ON condition and the condition must be equivalent to the primary key.
+3. For supertables, the ON condition must be equivalent to the primary key. In addition, the tag columns of the tables on which the INNER JOIN is performed must have a one-to-one relationship. You cannot specify an OR condition.
+4. The tables that are included in a JOIN clause must be of the same type (supertable, standard table, or subtable).
+5. You can include subqueries before and after the JOIN keyword.
+6. You cannot include more than ten tables in a JOIN clause.
+7. You cannot include a FILL clause and a JOIN clause in the same statement.
-**Restrictions**:No argument is allowed, where clause is not allowed
+## GROUP BY
-**Sub Query**:Sub query or nested query are not supported
+If you use a GROUP BY clause, the SELECT list can only include the following items:
-**Return value**: A string which includes the data block distribution of the specified table or STable, i.e. the histogram of rows stored in the data blocks of the table or STable.
+1. Constants
+2. Aggregate functions
+3. Expressions that are consistent with the expression following the GROUP BY clause
+4. Expressions that include the preceding expression
-```text title="Result"
-summary:
-5th=[392], 10th=[392], 20th=[392], 30th=[392], 40th=[792], 50th=[792] 60th=[792], 70th=[792], 80th=[792], 90th=[792], 95th=[792], 99th=[792] Min=[392(Rows)] Max=[800(Rows)] Avg=[666(Rows)] Stddev=[2.17] Rows=[2000], Blocks=[3], Size=[5.440(Kb)] Comp=[0.23] RowsInMem=[0] SeekHeaderTime=[1(us)]
-```
+The GROUP BY clause groups each row of data by the value of the expression following the clause and returns a combined result for each group.
-**More explanation about above example**:
+The expressions in a GROUP BY clause can include any column in any table or view. It is not necessary that the expressions appear in the SELECT list.
-- Histogram about the rows stored in the data blocks of the table or STable: the value of rows for 5%, 10%, 20%, 30%, 40%, 50%, 60%, 70%, 80%, 90%, 95%, and 99%
-- Minimum number of rows stored in a data block, i.e. Min=[392(Rows)]
-- Maximum number of rows stored in a data block, i.e. Max=[800(Rows)]
-- Average number of rows stored in a data block, i.e. Avg=[666(Rows)]
-- stddev of number of rows, i.e. Stddev=[2.17]
-- Total number of rows, i.e. Rows[2000]
-- Total number of data blocks, i.e. Blocks=[3]
-- Total disk size consumed, i.e. Size=[5.440(Kb)]
-- Compression ratio, which means the compressed size divided by original size, i.e. Comp=[0.23]
-- Total number of rows in memory, i.e. RowsInMem=[0], which means no rows in memory
-- The time spent on reading head file (to retrieve data block information), i.e. SeekHeaderTime=[1(us)], which means 1 microsecond.
+The GROUP BY clause does not guarantee that the results are ordered. If you want to ensure that grouped data is ordered, use the ORDER BY clause.
-## Special Keywords in TAOS SQL
-- `TBNAME`: it is treated as a special tag when selecting on a super table, representing the name of subtables in that super table.
-- `_c0`: represents the first column of a table or super table.
+## PARTITION BY
-## Tips
+The PARTITION BY clause is a TDengine-specific extension to standard SQL. This clause partitions data based on the part_list and performs computations per partition.
-To get all the subtables and corresponding tag values from a super table:
+For more information, see TDengine Extensions.
-```SQL
-SELECT TBNAME, location FROM meters;
-```
+## ORDER BY
+
+The ORDER BY keyword orders query results. If you do not include an ORDER BY clause in a query, the order of the results can be inconsistent.
+
+You can specify integers after ORDER BY to indicate the order in which you want the items in the SELECT list to be displayed. For example, 1 indicates the first item in the select list.
+
+You can specify ASC for ascending order or DESC for descending order.
+
+You can also use the NULLS keyword to specify the position of null values. Ascending order uses NULLS LAST by default. Descending order uses NULLS FIRST by default.
+
+## LIMIT
+
+The LIMIT keyword controls the number of results that are displayed. You can also use the OFFSET keyword to specify the result to display first. `LIMIT` and `OFFSET` are executed after `ORDER BY` in the query execution. You can include an offset in a LIMIT clause. For example, LIMIT 5 OFFSET 2 can also be written LIMIT 2, 5. Both of these clauses display the third through the seventh results.
+
+In a statement that includes a PARTITON BY clause, the LIMIT keyword is performed on each partition, not on the entire set of results.
+
+## SLIMIT
+
+The SLIMIT keyword is used with a PARTITION BY clause to control the number of partitions that are displayed. You can include an offset in a SLIMIT clause. For example, SLIMIT 5 OFFSET 2 can also be written LIMIT 2, 5. Both of these clauses display the third through the seventh partitions.
+
+Note: If you include an ORDER BY clause, only one partition can be displayed.
+
+## Special Query
-To get the number of sub tables in a super table:
+Some special query functions can be invoked without `FROM` sub-clause.
-```SQL
-SELECT COUNT(TBNAME) FROM meters;
+## Obtain Current Database
+
+The following SQL statement returns the current database. If a database has not been specified on login or with the `USE` command, a null value is returned.
+
+```sql
+SELECT DATABASE();
```
-Only filter on `TAGS` are allowed in the `where` clause for above two query statements. For example:
+### Obtain Current Version
+```sql
+SELECT CLIENT_VERSION();
+SELECT SERVER_VERSION();
```
-taos> SELECT TBNAME, location FROM meters;
- tbname | location |
-==================================================================
- d1004 | California.LosAngeles |
- d1003 | California.LosAngeles |
- d1002 | California.SanFrancisco |
- d1001 | California.SanFrancisco |
-Query OK, 4 row(s) in set (0.000881s)
-taos> SELECT COUNT(tbname) FROM meters WHERE groupId > 2;
- count(tbname) |
-========================
- 2 |
-Query OK, 1 row(s) in set (0.001091s)
+## Obtain Server Status
+
+The following SQL statement returns the status of the TDengine server. An integer indicates that the server is running normally. An error code indicates that an error has occurred. This statement can also detect whether a connection pool or third-party tool is connected to TDengine properly. By using this statement, you can ensure that connections in a pool are not lost due to an incorrect heartbeat detection statement.
+
+```sql
+SELECT SERVER_STATUS();
```
-- Wildcard \* can be used to get all columns, or specific column names can be specified. Arithmetic operation can be performed on columns of numerical types, columns can be renamed in the result set.
-- Arithmetic operation on columns can't be used in where clause. For example, `where a*2>6;` is not allowed but `where a>6/2;` can be used instead for the same purpose.
-- Arithmetic operation on columns can't be used as the objectives of select statement. For example, `select min(2*a) from t;` is not allowed but `select 2*min(a) from t;` can be used instead.
-- Logical operation can be used in `WHERE` clause to filter numeric values, wildcard can be used to filter string values.
-- Result sets are arranged in ascending order of the first column, i.e. timestamp, but it can be controlled to output as descending order of timestamp. If `order by` is used on other columns, the result may not be as expected. By the way, \_c0 is used to represent the first column, i.e. timestamp.
-- `LIMIT` parameter is used to control the number of rows to output. `OFFSET` parameter is used to specify from which row to output. `LIMIT` and `OFFSET` are executed after `ORDER BY` in the query execution. A simple tip is that `LIMIT 5 OFFSET 2` can be abbreviated as `LIMIT 2, 5`.
-- What is controlled by `LIMIT` is the number of rows in each group when `GROUP BY` is used.
-- `SLIMIT` parameter is used to control the number of groups when `GROUP BY` is used. Similar to `LIMIT`, `SLIMIT 5 OFFSET 2` can be abbreviated as `SLIMIT 2, 5`.
-- ">>" can be used to output the result set of `select` statement to the specified file.
+### Obtain Current Time
-## Where
+```sql
+SELECT NOW();
+```
-Logical operations in below table can be used in the `where` clause to filter the resulting rows.
+### Obtain Current Date
-| **Operation** | **Note** | **Applicable Data Types** |
-| ------------- | ------------------------ | ----------------------------------------- |
-| > | larger than | all types except bool |
-| < | smaller than | all types except bool |
-| >= | larger than or equal to | all types except bool |
-| <= | smaller than or equal to | all types except bool |
-| = | equal to | all types |
-| <\> | not equal to | all types |
-| is [not] null | is null or is not null | all types |
-| between and | within a certain range | all types except bool |
-| in | match any value in a set | all types except first column `timestamp` |
-| like | match a wildcard string | **`binary`** **`nchar`** |
-| match/nmatch | filter regex | **`binary`** **`nchar`** |
+```sql
+SELECT TODAY();
+```
-**Explanations**:
+### Obtain Current Time Zone
-- Operator `<\>` is equal to `!=`, please note that this operator can't be used on the first column of any table, i.e.timestamp column.
-- Operator `like` is used together with wildcards to match strings
- - '%' matches 0 or any number of characters, '\_' matches any single ASCII character.
- - `\_` is used to match the \_ in the string.
- - The maximum length of wildcard string is 100 bytes from version 2.1.6.1 (before that the maximum length is 20 bytes). `maxWildCardsLength` in `taos.cfg` can be used to control this threshold. A very long wildcard string may slowdown the execution performance of `LIKE` operator.
-- `AND` keyword can be used to filter multiple columns simultaneously. AND/OR operation can be performed on single or multiple columns from version 2.3.0.0. However, before 2.3.0.0 `OR` can't be used on multiple columns.
-- For timestamp column, only one condition can be used; for other columns or tags, `OR` keyword can be used to combine multiple logical operators. For example, `((value > 20 AND value < 30) OR (value < 12))`.
- - From version 2.3.0.0, multiple conditions can be used on timestamp column, but the result set can only contain single time range.
-- From version 2.0.17.0, operator `BETWEEN AND` can be used in where clause, for example `WHERE col2 BETWEEN 1.5 AND 3.25` means the filter condition is equal to "1.5 ≤ col2 ≤ 3.25".
-- From version 2.1.4.0, operator `IN` can be used in the where clause. For example, `WHERE city IN ('California.SanFrancisco', 'California.SanDiego')`. For bool type, both `{true, false}` and `{0, 1}` are allowed, but integers other than 0 or 1 are not allowed. FLOAT and DOUBLE types are impacted by floating point precision errors. Only values that match the condition within the tolerance will be selected. Non-primary key column of timestamp type can be used with `IN`.
-- From version 2.3.0.0, regular expression is supported in the where clause with keyword `match` or `nmatch`. The regular expression is case insensitive.
+```sql
+SELECT TIMEZONE();
+```
## Regular Expression
### Syntax
-```SQL
+```txt
WHERE (column|tbname) **match/MATCH/nmatch/NMATCH** _regex_
```
### Specification
-The regular expression being used must be compliant with POSIX specification, please refer to [Regular Expressions](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html).
+TDengine supports POSIX regular expression syntax. For more information, see [Regular Expressions](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html).
### Restrictions
-Regular expression can be used against only table names, i.e. `tbname`, and tags of binary/nchar types, but can't be used against data columns.
+Regular expression filtering is supported only on table names (TBNAME), BINARY tags, and NCHAR tags. Regular expression filtering cannot be performed on data columns.
-The maximum length of regular expression string is 128 bytes. Configuration parameter `maxRegexStringLen` can be used to set the maximum allowed regular expression. It's a configuration parameter on the client side, and will take effect after restarting the client.
+A regular expression string cannot exceed 128 bytes. You can configure this value by modifying the maxRegexStringLen parameter on the TDengine Client. The modified value takes effect when the client is restarted.
## JOIN
-From version 2.2.0.0, inner join is fully supported in TDengine. More specifically, the inner join between table and table, between STable and STable, and between sub query and sub query are supported.
+TDengine supports natural joins between supertables, between standard tables, and between subqueries. The difference between natural joins and inner joins is that natural joins require that the fields being joined in the supertables or standard tables must have the same name. Data or tag columns must be joined with the equivalent column in another table.
-Only primary key, i.e. timestamp, can be used in the join operation between table and table. For example:
+For standard tables, only the timestamp (primary key) can be used in join operations. For example:
```sql
SELECT *
@@ -356,25 +319,26 @@ FROM temp_tb_1 t1, pressure_tb_1 t2
WHERE t1.ts = t2.ts
```
-In the join operation between STable and STable, besides the primary key, i.e. timestamp, tags can also be used. For example:
+For supertables, tags as well as timestamps can be used in join operations. For example:
```sql
SELECT *
-FROM temp_STable t1, temp_STable t2
+FROM temp_stable t1, temp_stable t2
WHERE t1.ts = t2.ts AND t1.deviceid = t2.deviceid AND t1.status=0;
```
-Similarly, join operations can be performed on the result set of multiple sub queries.
+Similarly, join operations can be performed on the result sets of multiple subqueries.
:::note
-Restrictions on join operation:
-- The number of tables or STables in a single join operation can't exceed 10.
-- `FILL` is not allowed in the query statement that includes JOIN operation.
-- Arithmetic operation is not allowed on the result set of join operation.
-- `GROUP BY` is not allowed on a part of tables that participate in join operation.
-- `OR` can't be used in the conditions for join operation
-- join operation can't be performed on data columns, i.e. can only be performed on tags or primary key, i.e. timestamp
+The following restriction apply to JOIN statements:
+
+- The number of tables or supertables in a single join operation cannot exceed 10.
+- `FILL` cannot be used in a JOIN statement.
+- Arithmetic operations cannot be performed on the result sets of join operation.
+- `GROUP BY` is not allowed on a segment of the tables that participate in a join operation.
+- `OR` cannot be used in the conditions for join operation
+- Join operation can be performed only on tags or timestamps. You cannot perform a join operation on data columns.
:::
@@ -384,7 +348,7 @@ Nested query is also called sub query. This means that in a single SQL statement
From 2.2.0.0, unassociated sub query can be used in the `FROM` clause. Unassociated means the sub query doesn't use the parameters in the parent query. More specifically, in the `tb_name_list` of `SELECT` statement, an independent SELECT statement can be used. So a complete nested query looks like:
-```SQL
+```
SELECT ... FROM (SELECT ... FROM ...) ...;
```
@@ -408,42 +372,42 @@ SELECT ... FROM (SELECT ... FROM ...) ...;
## UNION ALL
-```SQL title=Syntax
+```txt title=Syntax
SELECT ...
UNION ALL SELECT ...
[UNION ALL SELECT ...]
```
-`UNION ALL` operator can be used to combine the result set from multiple select statements as long as the result set of these select statements have exactly the same columns. `UNION ALL` doesn't remove redundant rows from multiple result sets. In a single SQL statement, at most 100 `UNION ALL` can be supported.
+TDengine supports the `UNION ALL` operation. `UNION ALL` operator can be used to combine the result set from multiple select statements as long as the result set of these select statements have exactly the same columns. `UNION ALL` doesn't remove redundant rows from multiple result sets. In a single SQL statement, at most 100 `UNION ALL` can be supported.
### Examples
table `tb1` is created using below SQL statement:
-```SQL
+```
CREATE TABLE tb1 (ts TIMESTAMP, col1 INT, col2 FLOAT, col3 BINARY(50));
```
The rows in the past one hour in `tb1` can be selected using below SQL statement:
-```SQL
+```
SELECT * FROM tb1 WHERE ts >= NOW - 1h;
```
The rows between 2018-06-01 08:00:00.000 and 2018-06-02 08:00:00.000 and col3 ends with 'nny' can be selected in the descending order of timestamp using below SQL statement:
-```SQL
+```
SELECT * FROM tb1 WHERE ts > '2018-06-01 08:00:00.000' AND ts <= '2018-06-02 08:00:00.000' AND col3 LIKE '%nny' ORDER BY ts DESC;
```
The sum of col1 and col2 for rows later than 2018-06-01 08:00:00.000 and whose col2 is bigger than 1.2 can be selected and renamed as "complex", while only 10 rows are output from the 5th row, by below SQL statement:
-```SQL
+```
SELECT (col1 + col2) AS 'complex' FROM tb1 WHERE ts > '2018-06-01 08:00:00.000' AND col2 > 1.2 LIMIT 10 OFFSET 5;
```
The rows in the past 10 minutes and whose col2 is bigger than 3.14 are selected and output to the result file `/home/testoutput.csv` with below SQL statement:
-```SQL
+```
SELECT COUNT(*) FROM tb1 WHERE ts >= NOW - 10m AND col2 > 3.14 >> /home/testoutput.csv;
```
diff --git a/docs/en/12-taos-sql/08-delete-data.mdx b/docs/en/12-taos-sql/08-delete-data.mdx
index 86443dca53b08f5f5c489d40f4a2ea8afc8081fb..999c467ad05b6d3e349e322141acfb02a49de5ff 100644
--- a/docs/en/12-taos-sql/08-delete-data.mdx
+++ b/docs/en/12-taos-sql/08-delete-data.mdx
@@ -4,8 +4,7 @@ description: "Delete data from table or Stable"
title: Delete Data
---
-TDengine provides the functionality of deleting data from a table or STable according to specified time range, it can be used to cleanup abnormal data generated due to device failure. Please be noted that this functionality is only available in Enterprise version, please refer to [TDengine Enterprise Edition](https://tdengine.com/products#enterprise-edition-link)
-
+TDengine provides the functionality of deleting data from a table or STable according to specified time range, it can be used to cleanup abnormal data generated due to device failure.
**Syntax:**
@@ -16,21 +15,21 @@ DELETE FROM [ db_name. ] tb_name [WHERE condition];
**Description:** Delete data from a table or STable
**Parameters:**
-
+
- `db_name`: Optional parameter, specifies the database in which the table exists; if not specified, the current database will be used.
- `tb_name`: Mandatory parameter, specifies the table name from which data will be deleted, it can be normal table, subtable or STable.
-- `condition`: Optional parameter, specifies the data filter condition. If no condition is specified all data will be deleted, so please be cautions to delete data without any condition. The condition used here is only applicable to the first column, i.e. the timestamp column. If the table is a STable, the condition is also applicable to tag columns.
+- `condition`: Optional parameter, specifies the data filter condition. If no condition is specified all data will be deleted, so please be cautions to delete data without any condition. The condition used here is only applicable to the first column, i.e. the timestamp column.
**More Explanations:**
-
-The data can't be recovered once deleted, so please be cautious to use the functionality of deleting data. It's better to firstly make sure the data to be deleted using `select` then execute `delete`.
+
+The data can't be recovered once deleted, so please be cautious to use the functionality of deleting data. It's better to firstly make sure the data to be deleted using `select` then execute `delete`.
**Example:**
-
-`meters` is a STable, in which `groupid` is a tag column of int type. Now we want to delete the data older than 2021-10-01 10:40:00.100 and `groupid` is 1. The SQL for this purpose is like below:
+
+`meters` is a STable, in which `groupid` is a tag column of int type. Now we want to delete the data older than 2021-10-01 10:40:00.100. You can perform this action by running the following SQL statement:
```sql
-delete from meters where ts < '2021-10-01 10:40:00.100' and groupid=1 ;
+delete from meters where ts < '2021-10-01 10:40:00.100' ;
```
The output is:
diff --git a/docs/en/12-taos-sql/10-function.md b/docs/en/12-taos-sql/10-function.md
index 6375422b07a2ee7d5c9b6a0074060a39888da773..d6905c84a11ecf1f827ad239076ad5d4c93f8e3e 100644
--- a/docs/en/12-taos-sql/10-function.md
+++ b/docs/en/12-taos-sql/10-function.md
@@ -1,13 +1,14 @@
---
+sidebar_label: Functions
title: Functions
toc_max_heading_level: 4
---
-## Single-Row Functions
+## Single Row Functions
-Single-Row functions return a result row for each row in the query result.
+Single row functions return a result for each row.
-### Numeric Functions
+### Mathematical Functions
#### ABS
@@ -17,16 +18,15 @@ SELECT ABS(field_name) FROM { tb_name | stb_name } [WHERE clause]
**Description**: The absolute value of a specific field.
-**Return value type**: Same as input type.
+**Return value type**: Same as the field being used
-**Applicable data types**: Numeric types.
+**Applicable data types**: Numeric
-**Applicable table types**: table, STable.
+**Nested query**: It can be used in both the outer query and inner query in a nested query.
-**Applicable nested query**: Inner query and Outer query.
+**Applicable table types**: standard tables and supertables
-**More explanations**:
-- Cannot be used with aggregate functions.
+**Usage**: This function can only be used on data columns. It can be used with selection and projection functions but not with aggregation functions.
#### ACOS
@@ -34,18 +34,17 @@ SELECT ABS(field_name) FROM { tb_name | stb_name } [WHERE clause]
SELECT ACOS(field_name) FROM { tb_name | stb_name } [WHERE clause]
```
-**Description**: The anti-cosine of a specific field.
+**Description**: The arc cosine of a specific field.
-**Return value type**: DOUBLE.
+**Return value type**: Double
-**Applicable data types**: Numeric types.
+**Applicable data types**: Numeric
-**Applicable table types**: table, STable.
+**Nested query**: It can be used in both the outer query and inner query in a nested query.
-**Applicable nested query**: Inner query and Outer query.
+**Applicable table types**: standard tables and supertables
-**More explanations**:
-- Cannot be used with aggregate functions.
+**Usage**: This function can only be used on data columns. It can be used with selection and projection functions but not with aggregation functions.
#### ASIN
@@ -53,18 +52,18 @@ SELECT ACOS(field_name) FROM { tb_name | stb_name } [WHERE clause]
SELECT ASIN(field_name) FROM { tb_name | stb_name } [WHERE clause]
```
-**Description**: The anti-sine of a specific field.
+**Description**: The arc sine of a specific field.
-**Return value type**: DOUBLE.
+**Return value type**: Double
-**Applicable data types**: Numeric types.
+**Applicable data types**: Numeric
-**Applicable table types**: table, STable
+**Nested query**: It can be used in both the outer query and inner query in a nested query.
-**Applicable nested query**: Inner query and Outer query.
+**Applicable table types**: standard tables and supertables
+
+**Usage**: This function can only be used on data columns. It can be used with selection and projection functions but not with aggregation functions.
-**More explanations**:
-- Cannot be used with aggregate functions.
#### ATAN
@@ -72,37 +71,36 @@ SELECT ASIN(field_name) FROM { tb_name | stb_name } [WHERE clause]
SELECT ATAN(field_name) FROM { tb_name | stb_name } [WHERE clause]
```
-**Description**: anti-tangent of a specific field.
+**Description**: The arc tangent of a specific field.
-**Return value type**: DOUBLE.
+**Return value type**: Double
-**Applicable data types**: Numeric types.
+**Applicable data types**: Numeric
-**Applicable table types**: table, STable
+**Nested query**: It can be used in both the outer query and inner query in a nested query.
-**Applicable nested query**: Inner query and Outer query.
+**Applicable table types**: standard tables and supertables
+
+**Usage**: This function can only be used on data columns. It can be used with selection and projection functions but not with aggregation functions.
-**More explanations**:
-- Cannot be used with aggregate functions.
#### CEIL
-```
+```sql
SELECT CEIL(field_name) FROM { tb_name | stb_name } [WHERE clause];
```
-**Description**: The rounded up value of a specific field.
+**Description**: The rounded up value of a specific field
-**Return value type**: Same as input type.
+**Return value type**: Same as the field being used
-**Applicable data types**: Numeric types.
+**Applicable data types**: Numeric
-**Applicable table types**: table, STable
+**Applicable table types**: standard tables and supertables
-**Applicable nested query**: Inner query and outer query.
+**Nested query**: It can be used in both the outer query and inner query in a nested query.
-**More explanations**:
-- Can't be used with aggregate functions.
+**Usage**: This function can only be used on data columns. It can be used with selection and projection functions but not with aggregation functions.
#### COS
@@ -112,45 +110,43 @@ SELECT COS(field_name) FROM { tb_name | stb_name } [WHERE clause]
**Description**: The cosine of a specific field.
-**Return value type**: DOUBLE.
+**Return value type**: Double
-**Applicable data types**: Numeric types.
+**Applicable data types**: Numeric
-**Applicable table types**: table, STable.
+**Nested query**: It can be used in both the outer query and inner query in a nested query.
-**Applicable nested query**: Inner query and Outer query.
+**Applicable table types**: standard tables and supertables
-**More explanations**:
-- Can't be used with aggregate functions.
+**Usage**: This function can only be used on data columns. It can be used with selection and projection functions but not with aggregation functions.
#### FLOOR
-```
+```sql
SELECT FLOOR(field_name) FROM { tb_name | stb_name } [WHERE clause];
```
-**Description**: The rounded down value of a specific field.
-
-**More explanations**: Refer to `CEIL` function for usage restrictions.
+**Description**: The rounded down value of a specific field
+ **More explanations**: The restrictions are same as those of the `CEIL` function.
#### LOG
```sql
-SELECT LOG(field_name, base) FROM { tb_name | stb_name } [WHERE clause]
+SELECT LOG(field_name[, base]) FROM { tb_name | stb_name } [WHERE clause]
```
-**Description**: The logarithm of a specific field with `base` as the radix. If `base` parameter is ignored, natural logarithm of the field is returned.
+**Description**: The logarithm of a specific field with `base` as the radix. If you do not enter a base, the natural logarithm of the field is returned.
-**Return value type**: DOUBLE.
+**Return value type**: Double
-**Applicable data types**: Numeric types.
+**Applicable data types**: Numeric
-**Applicable table types**: table, STable.
+**Nested query**: It can be used in both the outer query and inner query in a nested query.
-**Applicable nested query**: Inner query and Outer query.
+**Applicable table types**: standard tables and supertables
+
+**Usage**: This function can only be used on data columns. It can be used with selection and projection functions but not with aggregation functions.
-**More explanations**:
-- Can't be used with aggregate functions
#### POW
@@ -158,28 +154,28 @@ SELECT LOG(field_name, base) FROM { tb_name | stb_name } [WHERE clause]
SELECT POW(field_name, power) FROM { tb_name | stb_name } [WHERE clause]
```
-**Description**: The power of a specific field with `power` as the index.
+**Description**: The power of a specific field with `power` as the exponent.
-**Return value type**: DOUBLE.
+**Return value type**: Double
-**Applicable data types**: Numeric types.
+**Applicable data types**: Numeric
-**Applicable table types**: table, STable.
+**Nested query**: It can be used in both the outer query and inner query in a nested query.
-**Applicable nested query**: Inner query and Outer query.
+**Applicable table types**: standard tables and supertables
+
+**Usage**: This function can only be used on data columns. It can be used with selection and projection functions but not with aggregation functions.
-**More explanations**:
-- Can't be used with aggregate functions.
#### ROUND
-```
+```sql
SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause];
```
-**Description**: The rounded value of a specific field.
+**Description**: The rounded value of a specific field.
+ **More explanations**: The restrictions are same as those of the `CEIL` function.
-**More explanations**: Refer to `CEIL` function for usage restrictions.
#### SIN
@@ -189,18 +185,15 @@ SELECT SIN(field_name) FROM { tb_name | stb_name } [WHERE clause]
**Description**: The sine of a specific field.
-**Description**: The anti-cosine of a specific field.
-
-**Return value type**: DOUBLE.
+**Return value type**: Double
-**Applicable data types**: Numeric types.
+**Applicable data types**: Numeric
-**Applicable table types**: table, STable.
+**Nested query**: It can be used in both the outer query and inner query in a nested query.
-**Applicable nested query**: Inner query and Outer query.
+**Applicable table types**: standard tables and supertables
-**More explanations**:
-- Can't be used with aggregate functions.
+**Usage**: This function can only be used on data columns. It can be used with selection and projection functions but not with aggregation functions.
#### SQRT
@@ -210,16 +203,15 @@ SELECT SQRT(field_name) FROM { tb_name | stb_name } [WHERE clause]
**Description**: The square root of a specific field.
-**Return value type**: DOUBLE.
+**Return value type**: Double
-**Applicable data types**: Numeric types.
+**Applicable data types**: Numeric
-**Applicable table types**: table, STable.
+**Nested query**: It can be used in both the outer query and inner query in a nested query.
-**Applicable nested query**: Inner query and Outer query.
+**Applicable table types**: standard tables and supertables
-**More explanations**:
-- Can't be used with aggregate functions.
+**Usage**: This function can only be used on data columns. It can be used with selection and projection functions but not with aggregation functions.
#### TAN
@@ -229,39 +221,35 @@ SELECT TAN(field_name) FROM { tb_name | stb_name } [WHERE clause]
**Description**: The tangent of a specific field.
-**Description**: The anti-cosine of a specific field.
-
-**Return value type**: DOUBLE.
+**Return value type**: Double
-**Applicable data types**: Numeric types.
+**Applicable data types**: Numeric
-**Applicable table types**: table, STable.
+**Nested query**: It can be used in both the outer query and inner query in a nested query.
-**Applicable nested query**: Inner query and Outer query.
+**Applicable table types**: standard tables and supertables
-**More explanations**:
-- Can't be used with aggregate functions.
+**Usage**: This function can only be used on data columns. It can be used with selection and projection functions but not with aggregation functions.
-### String Functions
+### Concatenation Functions
-String functiosn take strings as input and output numbers or strings.
+Concatenation functions take strings as input and produce string or numeric values as output.
#### CHAR_LENGTH
-```
+```sql
SELECT CHAR_LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause]
```
-**Description**: The mumber of characters of a string.
+**Description**: The length in number of characters of a string
-**Return value type**: INTEGER.
+**Return value type**: Bigint
-**Applicable data types**: VARCHAR, NCHAR.
+**Applicable data types**: VARCHAR and NCHAR
-**Applicable table types**: table, STable.
-
-**Applicable nested query**: Inner query and Outer query.
+**Nested query**: It can be used in both the outer query and inner query in a nested query.
+**Applicable table types**: standard tables and supertables
#### CONCAT
@@ -269,144 +257,139 @@ SELECT CHAR_LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause]
SELECT CONCAT(str1|column1, str2|column2, ...) FROM { tb_name | stb_name } [WHERE clause]
```
-**Description**: The concatenation result of two or more strings.
+**Description**: The concatenation result of two or more strings
-**Return value type**: If all input strings are VARCHAR type, the result is VARCHAR type too. If any one of input strings is NCHAR type, then the result is NCHAR. If input strings contain NULL value, the result is NULL.
+**Return value type**: If the concatenated strings are VARCHARs, the result is a VARCHAR. If the concatenated strings are NCHARs, the result is an NCHAR. If an input value is null, the result is null.
-**Applicable data types**: VARCHAR, NCHAR. At least 2 input strings are required, and at most 8 input strings are allowed.
+**Applicable data types**: VARCHAR and NCHAR You can concatenate between 2 and 8 strings.
-**Applicable table types**: table, STable.
+**Nested query**: It can be used in both the outer query and inner query in a nested query.
-**Applicable nested query**: Inner query and Outer query.
+**Applicable table types**: standard tables and supertables
#### CONCAT_WS
-```
+```sql
SELECT CONCAT_WS(separator, str1|column1, str2|column2, ...) FROM { tb_name | stb_name } [WHERE clause]
```
-**Description**: The concatenation result of two or more strings with separator.
+**Description**: The concatenation result of two or more strings with separator
-**Return value type**: If all input strings are VARCHAR type, the result is VARCHAR type too. If any one of input strings is NCHAR type, then the result is NCHAR. If input strings contain NULL value, the result is NULL.
+**Return value type**: If the concatenated strings are VARCHARs, the result is a VARCHAR. If the concatenated strings are NCHARs, the result is an NCHAR. If an input value is null, the result is null.
-**Applicable data types**: VARCHAR, NCHAR. At least 3 input strings are required, and at most 9 input strings are allowed.
+**Applicable data types**: VARCHAR and NCHAR You can concatenate between 3 and 9 strings.
-**Applicable table types**: table, STable.
+**Nested query**: It can be used in both the outer query and inner query in a nested query.
-**Applicable nested query**: Inner query and Outer query.
+**Applicable table types**: standard tables and supertables
#### LENGTH
-```
+```sql
SELECT LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause]
```
-**Description**: The length in bytes of a string.
+**Description**: The length in bytes of a string
-**Return value type**: INTEGER.
+**Return value type**: Bigint
-**Applicable data types**: VARCHAR, NCHAR.
+**Applicable data types**: VARCHAR and NCHAR fields or columns
-**Applicable table types**: table, STable.
+**Nested query**: It can be used in both the outer query and inner query in a nested query.
-**Applicable nested query**: Inner query and Outer query.
+**Applicable table types**: standard tables and supertables
#### LOWER
-```
+```sql
SELECT LOWER(str|column) FROM { tb_name | stb_name } [WHERE clause]
```
-**Description**: Convert the input string to lower case.
+**Description**: Convert the input string to lower case
-**Return value type**: Same as input type.
+**Return value type**: Same as input
-**Applicable data types**: VARCHAR, NCHAR.
+**Applicable data types**: VARCHAR and NCHAR
-**Applicable table types**: table, STable.
+**Nested query**: It can be used in both the outer query and inner query in a nested query.
-**Applicable nested query**: Inner query and Outer query.
+**Applicable table types**: standard tables and supertables
#### LTRIM
-```
+```sql
SELECT LTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause]
```
-**Description**: Remove the left leading blanks of a string.
+**Description**: Remove the left leading blanks of a string
-**Return value type**: Same as input type.
+**Return value type**: Same as input
-**Applicable data types**: VARCHAR, NCHAR.
+**Applicable data types**: VARCHAR and NCHAR
-**Applicable table types**: table, STable.
+**Nested query**: It can be used in both the outer query and inner query in a nested query.
-**Applicable nested query**: Inner query and Outer query.
+**Applicable table types**: standard tables and supertables
#### RTRIM
-```
-SELECT RTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause]
+```sql
+SELECT LTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause]
```
-**Description**: Remove the right tailing blanks of a string.
+**Description**: Remove the right tailing blanks of a string
-**Return value type**: Same as input type.
+**Return value type**: Same as input
-**Applicable data types**: VARCHAR, NCHAR.
+**Applicable data types**: VARCHAR and NCHAR
-**Applicable table types**: table, STable.
+**Nested query**: It can be used in both the outer query and inner query in a nested query.
-**Applicable nested query**: Inner query and Outer query.
+**Applicable table types**: standard tables and supertables
#### SUBSTR
-```
+```sql
SELECT SUBSTR(str,pos[,len]) FROM { tb_name | stb_name } [WHERE clause]
```
-**Description**: The sub-string starting from `pos` with length of `len` from the original string `str`.
-
-**Return value type**: Same as input type.
+**Description**: The sub-string starting from `pos` with length of `len` from the original string `str` - If `len` is not specified, it means from `pos` to the end.
-**Applicable data types**: VARCHAR, NCHAR.
+**Return value type**: Same as input
-**Applicable table types**: table, STable.
+**Applicable data types**: VARCHAR and NCHAR Parameter `pos` can be an positive or negative integer; If it's positive, the starting position will be counted from the beginning of the string; if it's negative, the starting position will be counted from the end of the string.
-**Applicable nested query**: Inner query and Outer query.
+**Nested query**: It can be used in both the outer query and inner query in a nested query.
-**More explanations**:
+**Applicable table types**: table, STable
-- If the input is NULL, the output is NULL
-- Parameter `pos` can be an positive or negative integer; If it's positive, the starting position will be counted from the beginning of the string; if it's negative, the starting position will be counted from the end of the string.
-- If `len` is not specified, it means from `pos` to the end of string.
#### UPPER
-```
+```sql
SELECT UPPER(str|column) FROM { tb_name | stb_name } [WHERE clause]
```
-**Description**: Convert the input string to upper case.
+**Description**: Convert the input string to upper case
-**Return value type**: Same as input type.
+**Return value type**: Same as input
-**Applicable data types**: VARCHAR, NCHAR.
+**Applicable data types**: VARCHAR and NCHAR
-**Applicable table types**: table, STable.
+**Nested query**: It can be used in both the outer query and inner query in a nested query.
-**Applicable nested query**: Inner query and Outer query.
+**Applicable table types**: table, STable
### Conversion Functions
-Conversion functions convert from one data type to another.
+Conversion functions change the data type of a value.
#### CAST
@@ -414,19 +397,23 @@ Conversion functions convert from one data type to another.
SELECT CAST(expression AS type_name) FROM { tb_name | stb_name } [WHERE clause]
```
-**Description**: Used for type casting. Convert `expression` to the type specified by `type_name`.
+**Description**: Convert the input data `expression` into the type specified by `type_name`. This function can be used only in SELECT statements.
-**Return value type**: The type specified by parameter `type_name`.
+**Return value type**: The type specified by parameter `type_name`
-**Applicable data types**: `expression` can be any data type except for JSON.
+**Applicable data types**: All data types except JSON
+
+**Nested query**: It can be used in both the outer query and inner query in a nested query.
+
+**Applicable table types**: standard tables and supertables
**More explanations**:
-- Error will be reported for unsupported type casting.
+- Error will be reported for unsupported type casting
- Some values of some supported data types may not be casted, below are known issues:
- 1)When casting VARCHAR/NCHAR to BIGINT/BIGINT UNSIGNED, some characters may be treated as illegal, for example "a" may be converted to 0.
- 2)When casting to numeric type, if converted result is out of range the destination data type can hold, overflow may occur and casting behavior is undefined.
- 3) When casting to VARCHAR/NCHAR type, if converted string length exceeds the length specified in `type_name`, the result will be truncated. (e.g. CAST("abcd" as BINARY(2)) will return string "ab").
+ 1. Some strings cannot be converted to numeric values. For example, the string `a` may be converted to `0`. However, this does not produce an error.
+ 2. If a converted numeric value is larger than the maximum size for the specified type, an overflow will occur. However, this does not produce an error.
+ 3. If a converted string value is larger than the maximum size for the specified type, the output value will be truncated. However, this does not produce an error.
#### TO_ISO8601
@@ -434,18 +421,22 @@ SELECT CAST(expression AS type_name) FROM { tb_name | stb_name } [WHERE clause]
SELECT TO_ISO8601(ts[, timezone]) FROM { tb_name | stb_name } [WHERE clause];
```
-**Description**: The ISO8601 date/time format converted from a UNIX timestamp, with timezone attached. `timezone` parameter allows attaching any customized timezone string to the output format. If `timezone` parameter is not specified, the timezone information of client side system will be attached.
+**Description**: The ISO8601 date/time format converted from a UNIX timestamp, plus the timezone. You can specify any time zone with the timezone parameter. If you do not enter this parameter, the time zone on the client is used.
-**Return value type**: VARCHAR.
+**Return value type**: VARCHAR
-**Applicable data types**: INTEGER, TIMESTAMP.
+**Applicable data types**: Integers and timestamps
-**Applicable table types**: table, STable.
+**Nested query**: It can be used in both the outer query and inner query in a nested query.
+
+**Applicable table types**: standard tables and supertables
**More explanations**:
-- If the input is INTEGER represents UNIX timestamp, the precision of the returned value is determined by the digits of the input integer.
-- If the input is of TIMESTAMP type, The precision of the returned value is same as the precision set for the current database in use.
+- You can specify a time zone in the following format: [z/Z, +/-hhmm, +/-hh, +/-hh:mm]。 For example, TO_ISO8601(1, "+00:00").
+- If the input is a UNIX timestamp, the precision of the returned value is determined by the digits of the input timestamp
+- If the input is a column of TIMESTAMP type, the precision of the returned value is same as the precision set for the current data base in use
+
#### TO_JSON
@@ -453,38 +444,44 @@ SELECT TO_ISO8601(ts[, timezone]) FROM { tb_name | stb_name } [WHERE clause];
SELECT TO_JSON(str_literal) FROM { tb_name | stb_name } [WHERE clause];
```
-**Description**: Convert a JSON string to a JSON body.
+**Description**: Converts a string into JSON.
+
+**Return value type**: JSON
-**Return value type**: JSON.
+**Applicable data types**: JSON strings in the form `{"literal": literal}`. `{}` indicates a null value. The key must be a string literal. The value can be a numeric literal, string literal, Boolean literal, or null literal. str_literal cannot include escape characters.
-**Applicable data types**: JSON string, in the format like '{ "literal" : literal }'. '{}' is NULL value. keys in the string must be string constants, values can be constants of numeric types, bool, string or NULL. Escaping characters are not allowed in the JSON string.
+**Nested query**: It can be used in both the outer query and inner query in a nested query.
-**Applicable table types**: table, STable.
+**Applicable table types**: table, STable
-**Applicable nested query**: Inner query and Outer query.
#### TO_UNIXTIMESTAMP
```sql
-SELECT TO_UNIXTIMESTAMP(datetime_string | ts_col) FROM { tb_name | stb_name } [WHERE clause];
+SELECT TO_UNIXTIMESTAMP(datetime_string) FROM { tb_name | stb_name } [WHERE clause];
```
-**Description**: UNIX timestamp converted from a string of date/time format.
+**Description**: UNIX timestamp converted from a string of date/time format
+
+**Return value type**: BIGINT
-**Return value type**: BIGINT.
+**Applicable column types**: VARCHAR and NCHAR
-**Applicable data types**: VARCHAR, NCHAR.
+**Nested query**: It can be used in both the outer query and inner query in a nested query.
-**Applicable table types**: table, STable.
+**Applicable table types**: standard tables and supertables
**More explanations**:
-- The input string must be compatible with ISO8601/RFC3339 standard, NULL will be returned if the string cannot be converted.
-- The precision of the returned timestamp is same as the precision set for the current database in use.
+- The input string must be compatible with ISO8601/RFC3339 standard, NULL will be returned if the string can't be converted
+- The precision of the returned timestamp is same as the precision set for the current data base in use
+
-### DateTime Functions
+### Time and Date Functions
-DateTime functions applied to timestamp data. NOW(), TODAY() and TIMEZONE() are executed only once even though they may occur multiple times in a single SQL statement.
+These functions perform operations on times and dates.
+
+All functions that return the current time, such as `NOW`, `TODAY`, and `TIMEZONE`, are calculated only once per statement even if they appear multiple times.
#### NOW
@@ -494,61 +491,66 @@ SELECT select_expr FROM { tb_name | stb_name } WHERE ts_col cond_operatior NOW()
INSERT INTO tb_name VALUES (NOW(), ...);
```
-**Description**: The current time of the client side system.
+**Description**: The current time of the client side system
-**Return value type**: TIMESTAMP.
+**Return value type**: TIMESTAMP
-**Applicable data types**: TIMESTAMP only if used in WHERE/INSERT clause.
+**Applicable column types**: TIMESTAMP only
-**Applicable table types**: table, STable.
+**Applicable table types**: standard tables and supertables
+
+**Nested query**: It can be used in both the outer query and inner query in a nested query.
**More explanations**:
-- Addition and Subtraction operation with time duration can be performed, for example NOW() + 1s, the time unit can be one of the followings:
- b(nanosecond), u(microsecond), a(millisecond)), s(second), m(minute), h(hour), d(day), w(week).
-- The precision of the returned timestamp is same as the precision set for the current database in use.
+- Add and Subtract operation can be performed, for example NOW() + 1s, the time unit can be:
+ b(nanosecond), u(microsecond), a(millisecond)), s(second), m(minute), h(hour), d(day), w(week)
+- The precision of the returned timestamp is same as the precision set for the current data base in use
+
#### TIMEDIFF
```sql
-SELECT TIMEDIFF(ts1 | datetime_string1, ts2 | datetime_string2 [, time_unit]) FROM { tb_name | stb_name } [WHERE clause];
+SELECT TIMEDIFF(ts | datetime_string1, ts | datetime_string2 [, time_unit]) FROM { tb_name | stb_name } [WHERE clause];
```
-**Description**: The difference(duration) between two timestamps, and rounded to the time unit specified by `time_unit`.
+**Description**: The difference between two timestamps, and rounded to the time unit specified by `time_unit`
-**Return value type**: BIGINT.
+**Return value type**: BIGINT
-**Applicable data types**: INTEGER/TIMESTAMP represents UNIX timestamp, or VARCHAR/NCHAR string in date/time format.
+**Applicable column types**: UNIX-style timestamps in BIGINT and TIMESTAMP format and other timestamps in VARCHAR and NCHAR format
-**Applicable table types**: table, STable.
+**Applicable table types**: standard tables and supertables
-**More explanations**:
+**Nested query**: It can be used in both the outer query and inner query in a nested query.
+**More explanations**:
- Time unit specified by `time_unit` can be:
- 1b(nanosecond), 1u(microsecond),1a(millisecond),1s(second),1m(minute),1h(hour),1d(day),1w(week).
-- If `time_unit` parameter is not specified, the precision of the returned time duration is same as the precision set for the current database in use.
-- If input date-time string cannot be converted to UNIX timestamp, NULL value is returned.
+ 1b (nanoseconds), 1u (microseconds), 1a (milliseconds), 1s (seconds), 1m (minutes), 1h (hours), 1d (days), or 1w (weeks)
+- The precision of the returned timestamp is same as the precision set for the current data base in use
+- If the input data is not formatted as a timestamp, the returned value is null.
+
#### TIMETRUNCATE
```sql
-SELECT TIMETRUNCATE(ts_val | datetime_string | ts_col, time_unit) FROM { tb_name | stb_name } [WHERE clause];
+SELECT TIMETRUNCATE(ts | datetime_string , time_unit) FROM { tb_name | stb_name } [WHERE clause];
```
-**Description**: Truncate the input timestamp with unit specified by `time_unit`.
+**Description**: Truncate the input timestamp with unit specified by `time_unit`
-**Return value type**: TIMESTAMP.
+**Return value type**: TIMESTAMP
-**Applicable data types**: INTEGER/TIMESTAMP represents UNIX timestamp, or VARCHAR/NCHAR string in date/time format.
+**Applicable column types**: UNIX-style timestamps in BIGINT and TIMESTAMP format and other timestamps in VARCHAR and NCHAR format
-**Applicable table types**: table, STable.
+**Applicable table types**: standard tables and supertables
**More explanations**:
-
- Time unit specified by `time_unit` can be:
- 1b(nanosecond),1u(microsecond),1a(millisecond),1s(second),1m(minute),1h(hour),1d(day),1w(week).
-- The precision of the returned timestamp is same as the precision set for the current database in use.
-- If input date-time string cannot be converted to UNIX timestamp, NULL value is returned.
+ 1b (nanoseconds), 1u (microseconds), 1a (milliseconds), 1s (seconds), 1m (minutes), 1h (hours), 1d (days), or 1w (weeks)
+- The precision of the returned timestamp is same as the precision set for the current data base in use
+- If the input data is not formatted as a timestamp, the returned value is null.
+
#### TIMEZONE
@@ -556,13 +558,14 @@ SELECT TIMETRUNCATE(ts_val | datetime_string | ts_col, time_unit) FROM { tb_name
SELECT TIMEZONE() FROM { tb_name | stb_name } [WHERE clause];
```
-**Description**: The timezone of the client side system.
+**Description**: The timezone of the client side system
+
+**Applicable data types**: VARCHAR
-**Return value type**: VARCHAR.
+**Applicable column types**: None
-**Applicable data types**: None.
+**Applicable table types**: standard tables and supertables
-**Applicable table types**: table, STable.
#### TODAY
@@ -572,269 +575,269 @@ SELECT select_expr FROM { tb_name | stb_name } WHERE ts_col cond_operatior TODAY
INSERT INTO tb_name VALUES (TODAY(), ...);
```
-**Description**: The timestamp of 00:00:00 of the client side system.
+**Description**: The timestamp of 00:00:00 of the client side system
-**Return value type**: TIMESTAMP.
+**Return value type**: TIMESTAMP
-**Applicable data types**: TIMESTAMP only if used in WHERE/INSERT clause.
+**Applicable column types**: TIMESTAMP only
-**Applicable table types**: table, STable.
+**Applicable table types**: standard tables and supertables
**More explanations**:
-- Addition and Subtraction operation can be performed with time durations, for example NOW() + 1s, the time unit can be:
- b(nanosecond), u(microsecond), a(millisecond)), s(second), m(minute), h(hour), d(day), w(week).
-- The precision of the returned timestamp is same as the precision set for the current database in use.
+- Add and Subtract operation can be performed, for example TODAY() + 1s, the time unit can be:
+ b(nanosecond), u(microsecond), a(millisecond)), s(second), m(minute), h(hour), d(day), w(week)
+- The precision of the returned timestamp is same as the precision set for the current data base in use
+
## Aggregate Functions
-Aggregate functions return single result row for each group in the query result set. Groups are determined by `GROUP BY` clause or time window clause if they are used; or the whole result is considered a group if neither of them is used.
+Aggregate functions return one row per group. You can use windows or GROUP BY to group data. Otherwise, the entire query is considered a single group.
+
+TDengine supports the following aggregate functions:
### APERCENTILE
-```
-SELECT APERCENTILE(field_name, P[, algo_type])
-FROM { tb_name | stb_name } [WHERE clause]
+```sql
+SELECT APERCENTILE(field_name, P[, algo_type]) FROM { tb_name | stb_name } [WHERE clause]
```
-**Description**: Similar to `PERCENTILE`, but a approximated result is returned.
+**Description**: Similar to `PERCENTILE`, but a simulated result is returned
-**Return value type**: DOUBLE.
+**Return value type**: DOUBLE
-**Applicable data types**: Numeric types.
+**Applicable data types**: Numeric
-**Applicable table types**: table, STable.
-
-**More explanations**
+**Applicable table types**: standard tables and supertables
+**Explanations**:
- _P_ is in range [0,100], when _P_ is 0, the result is same as using function MIN; when _P_ is 100, the result is same as function MAX.
-- **algo_type** can only be input as `default` or `t-digest`, if it's not specified `default` will be used, i.e. `apercentile(column_name, 50)` is same as `apercentile(column_name, 50, "default")`.
-- If `default` is used, histogram based algorithm is used for calculation. If `t-digest` is used, `t-digest` sampling algorithm is used to calculate the result.
-
-**Nested query**: It can be used in both the outer query and inner query in a nested query.
+- `algo_type` can only be input as `default` or `t-digest` Enter `default` to use a histogram-based algorithm. Enter `t-digest` to use the t-digest algorithm to calculate the approximation of the quantile. `default` is used by default.
### AVG
-```
+```sql
SELECT AVG(field_name) FROM tb_name [WHERE clause];
```
-**Description**: Get the average value of a column in a table or STable.
+**Description**: The average value of the specified fields.
+
+**Return value type**: DOUBLE
-**Return value type**: DOUBLE.
+**Applicable data types**: Numeric
-**Applicable data types**: Numeric type.
+**Applicable table types**: standard tables and supertables
-**Applicable table types**: table, STable.
### COUNT
-```
+```sql
SELECT COUNT([*|field_name]) FROM tb_name [WHERE clause];
```
-**Description**: Get the number of rows in a table or a super table.
+**Description**: The number of records in the specified fields.
-**Return value type**: BIGINT.
+**Return value type**: BIGINT
-**Applicable data types**: All data types.
+**Applicable data types**: Numeric
-**Applicable table types**: table, STable.
+**Applicable table types**: standard tables and supertables
**More explanation**:
-- Wildcard (\*) is used to represent all columns. If \* used `COUNT` function will get the total number of all rows.
-- The number of non-NULL values will be returned if this function is used on a specific column.
+- Wildcard (\*) is used to represent all columns.
+If you input a specific column, the number of non-null values in the column is returned.
+
### ELAPSED
-```mysql
-SELECT ELAPSED(field_name[, time_unit]) FROM { tb_name | stb_name } [WHERE clause] [INTERVAL(interval [, offset]) [SLIDING sliding]];
+```sql
+SELECT ELAPSED(ts_primary_key [, time_unit]) FROM { tb_name | stb_name } [WHERE clause] [INTERVAL(interval [, offset]) [SLIDING sliding]];
```
-**Description**:`elapsed` function can be used to calculate the continuous time length in which there is valid data. If it's used with `INTERVAL` clause, the returned result is the calcualted time length within each time window. If it's used without `INTERVAL` caluse, the returned result is the calculated time duration within the specified time range. Please be noted that the calculated time duration is in the specified `time_unit`.
+**Description**:`elapsed` function can be used to calculate the continuous time length in which there is valid data. If it's used with `INTERVAL` clause, the returned result is the calcualted time length within each time window. If it's used without `INTERVAL` caluse, the returned result is the calculated time length within the specified time range. Please be noted that the return value of `elapsed` is the number of `time_unit` in the calculated time length.
-**Return value type**:DOUBLE.
+**Return value type**: Double if the input value is not NULL;
-**Applicable data type**:TIMESTAMP.
+**Return value type**: TIMESTAMP
-**Applicable tables**: table, STable, outter in nested query.
+**Applicable tables**: table, STable, outter in nested query
**Explanations**:
-
- `field_name` parameter can only be the first column of a table, i.e. timestamp primary key.
-- The minimum value of `time_unit` is the time precision of the database. If `time_unit` is not specified, the time precision of the database is used as the default ime unit.
+- The minimum value of `time_unit` is the time precision of the database. If `time_unit` is not specified, the time precision of the database is used as the default time unit. Time unit specified by `time_unit` can be:
+ 1b (nanoseconds), 1u (microseconds), 1a (milliseconds), 1s (seconds), 1m (minutes), 1h (hours), 1d (days), or 1w (weeks)
- It can be used with `INTERVAL` to get the time valid time length of each time window. Please be noted that the return value is same as the time window for all time windows except for the first and the last time window.
- `order by asc/desc` has no effect on the result.
- `group by tbname` must be used together when `elapsed` is used against a STable.
- `group by` must NOT be used together when `elapsed` is used against a table or sub table.
-- When used in nested query, it's only applicable when the inner query outputs an implicit timestamp column as the primary key. For example, `select elapsed(ts) from (select diff(value) from sub1)` is legal usage while `select elapsed(ts) from (select * from sub1)` is not.
-- It cannot be used with `leastsquares`, `diff`, `derivative`, `top`, `bottom`, `last_row`, `interp`.
+- When used in nested query, it's only applicable when the inner query outputs an implicit timestamp column as the primary key. For example, `select elapsed(ts) from (select diff(value) from sub1)` is legal usage while `select elapsed(ts) from (select * from sub1)` is not. In addition, because elapsed has a strict dependency on the timeline, a statement like `select elapsed(ts) from (select diff(value) from st group by tbname) will return a meaningless result.
+- It can't be used with `leastsquares`, `diff`, `derivative`, `top`, `bottom`, `last_row`, `interp`.
+
### LEASTSQUARES
-```
+```sql
SELECT LEASTSQUARES(field_name, start_val, step_val) FROM tb_name [WHERE clause];
```
**Description**: The linear regression function of the specified column and the timestamp column (primary key), `start_val` is the initial value and `step_val` is the step value.
-**Return value type**: VARCHAR string in the format of "(slope, intercept)".
+**Return value type**: A string in the format of "(slope, intercept)"
-**Applicable data types**: Numeric types.
+**Applicable data types**: Numeric
+
+**Applicable table types**: table only
-**Applicable table types**: table only.
### SPREAD
-```
+```sql
SELECT SPREAD(field_name) FROM { tb_name | stb_name } [WHERE clause];
```
-**Description**: The difference between the max and the min value of a specific column.
+**Description**: The difference between the max and the min of a specific column
-**Return value type**: DOUBLE.
+**Return value type**: DOUBLE
-**Applicable data types**: Numeric types.
+**Applicable data types**: Integers and timestamps
-**Applicable table types**: table, STable.
+**Applicable table types**: standard tables and supertables
-**More explanations**: Can be used on a column of TIMESTAMP type, the result time unit precision is same as the current database in use.
### STDDEV
-```
+```sql
SELECT STDDEV(field_name) FROM tb_name [WHERE clause];
```
-**Description**: Standard deviation of a specific column in a table or STable.
+**Description**: Standard deviation of a specific column in a table or STable
+
+**Return value type**: DOUBLE
-**Return value type**: DOUBLE.
+**Applicable data types**: Numeric
-**Applicable data types**: Numeric types.
+**Applicable table types**: standard tables and supertables
-**Applicable table types**: table, STable.
### SUM
-```
+```sql
SELECT SUM(field_name) FROM tb_name [WHERE clause];
```
-**Description**: The summation of values of a specific column in a table or STable.
+**Description**: The sum of a specific column in a table or STable
-**Return value type**: DOUBLE.
+**Return value type**: DOUBLE or BIGINT
-**Applicable data types**: Numeric types.
+**Applicable data types**: Numeric
+
+**Applicable table types**: standard tables and supertables
-**Applicable table types**: table, STable.
### HYPERLOGLOG
-```
+```sql
SELECT HYPERLOGLOG(field_name) FROM { tb_name | stb_name } [WHERE clause];
```
-**Description**:The cardinal number of a specific column is returned by using hyperloglog algorithm.
+**Description**:
+ The cardinal number of a specific column is returned by using hyperloglog algorithm. The benefit of using hyperloglog algorithm is that the memory usage is under control when the data volume is huge.
+ However, when the data volume is very small, the result may be not accurate, it's recommented to use `select count(data) from (select unique(col) as data from table)` in this case.
+
+**Return value type**: Integer
-**Return value type**: INTEGER.
+**Applicable data types**: Numeric
-**Applicable data types**: All data types.
+**Applicable table types**: standard tables and supertables
-**More explanations**: The benefit of using hyperloglog algorithm is that the memory usage is under control when the data volume is huge. However, when the data volume is very small, the result may be not accurate, it's recommented to use `select count(data) from (select unique(col) as data from table)` in this case.
### HISTOGRAM
-```
+```sql
SELECT HISTOGRAM(field_name,bin_type, bin_description, normalized) FROM tb_name [WHERE clause];
```
**Description**:Returns count of data points in user-specified ranges.
-**Return value type**:DOUBLE or BIGINT, depends on normalized parameter settings.
+**Return value type** If normalized is set to 1, a DOUBLE is returned; otherwise a BIGINT is returned
-**Applicable data type**:Numerical types.
+**Applicable data types**: Numeric
-**Applicable table types**: table, STable.
+**Applicable table types**: table, STable
**Explanations**:
-
- bin_type: parameter to indicate the bucket type, valid inputs are: "user_input", "linear_bin", "log_bin"。
-- bin_description: parameter to describe the rule to generate buckets,can be in the following JSON formats for each bin_type respectively:
-
- - "user_input": "[1, 3, 5, 7]": User specified bin values.
-
- - "linear_bin": "{"start": 0.0, "width": 5.0, "count": 5, "infinity": true}"
- "start" - bin starting point.
- "width" - bin offset.
- "count" - number of bins generated.
- "infinity" - whether to add(-inf, inf)as start/end point in generated set of bins.
- The above "linear_bin" descriptor generates a set of bins: [-inf, 0.0, 5.0, 10.0, 15.0, 20.0, +inf].
-
- - "log_bin": "{"start":1.0, "factor": 2.0, "count": 5, "infinity": true}"
- "start" - bin starting point.
- "factor" - exponential factor of bin offset.
- "count" - number of bins generated.
- "infinity" - whether to add(-inf, inf)as start/end point in generated range of bins.
- The above "log_bin" descriptor generates a set of bins:[-inf, 1.0, 2.0, 4.0, 8.0, 16.0, +inf].
+- bin_description: parameter to describe how to generate buckets,can be in the following JSON formats for each bin_type respectively:
+ - "user_input": "[1, 3, 5, 7]":
+ User specified bin values.
+
+ - "linear_bin": "{"start": 0.0, "width": 5.0, "count": 5, "infinity": true}"
+ "start" - bin starting point. "width" - bin offset. "count" - number of bins generated. "infinity" - whether to add(-inf, inf)as start/end point in generated set of bins.
+ The above "linear_bin" descriptor generates a set of bins: [-inf, 0.0, 5.0, 10.0, 15.0, 20.0, +inf].
+
+ - "log_bin": "{"start":1.0, "factor": 2.0, "count": 5, "infinity": true}"
+ "start" - bin starting point. "factor" - exponential factor of bin offset. "count" - number of bins generated. "infinity" - whether to add(-inf, inf)as start/end point in generated range of bins.
+ The above "linear_bin" descriptor generates a set of bins: [-inf, 1.0, 2.0, 4.0, 8.0, 16.0, +inf].
+- normalized: setting to 1/0 to turn on/off result normalization. Valid values are 0 or 1.
-- normalized: setting to 1/0 to turn on/off result normalization.
### PERCENTILE
-```
+```sql
SELECT PERCENTILE(field_name, P) FROM { tb_name } [WHERE clause];
```
**Description**: The value whose rank in a specific column matches the specified percentage. If such a value matching the specified percentage doesn't exist in the column, an interpolation value will be returned.
-**Return value type**: DOUBLE.
+**Return value type**: DOUBLE
-**Applicable data types**: Numeric types.
+**Applicable column types**: Numeric
-**Applicable table types**: table.
+**Applicable table types**: table only
**More explanations**: _P_ is in range [0,100], when _P_ is 0, the result is same as using function MIN; when _P_ is 100, the result is same as function MAX.
-## Selector Functions
-Selector functiosn choose one or more rows in the query result according to the semantics. You can specify to output primary timestamp column and other columns including tbname and tags so that you can easily know which rows the selected values belong to.
+## Selection Functions
+
+Selection functions return one or more results depending. You can specify the timestamp column, tbname pseudocolumn, or tag columns to show which rows contain the selected value.
### BOTTOM
-```
+```sql
SELECT BOTTOM(field_name, K) FROM { tb_name | stb_name } [WHERE clause];
```
**Description**: The least _k_ values of a specific column in a table or STable. If a value has multiple occurrences in the column but counting all of them in will exceed the upper limit _k_, then a part of them will be returned randomly.
-**Return value type**: Same as the column being operated upon.
+**Return value type**:Same as the data type of the column being operated upon
-**Applicable data types**: Numeric types.
+**Applicable data types**: Numeric
-**Applicable table types**: table, STable.
+**Applicable table types**: standard tables and supertables
-**More explanations**:
+**More explanation**:
-- _k_ must be in range [1,100].
-- The timestamp associated with the selected values are returned too.
-- Can't be used with `FILL`.
+- _k_ must be in range [1,100]
+- The timestamp associated with the selected values are returned too
+- Can't be used with `FILL`
### FIRST
-```
+```sql
SELECT FIRST(field_name) FROM { tb_name | stb_name } [WHERE clause];
```
-**Description**: The first non-null value of a specific column in a table or STable.
+**Description**: The first non-null value of a specific column in a table or STable
-**Return value type**: Same as the column being operated upon.
+**Return value type**:Same as the data type of the column being operated upon
-**Applicable data types**: All data types.
+**Applicable data types**: Numeric
-**Applicable table types**: table, STable.
+**Applicable table types**: standard tables and supertables
-**More explanations**:
+**More explanation**:
- FIRST(\*) can be used to get the first non-null value of all columns
- NULL will be returned if all the values of the specified column are all NULL
@@ -842,225 +845,231 @@ SELECT FIRST(field_name) FROM { tb_name | stb_name } [WHERE clause];
### INTERP
-```
-SELECT INTERP(field_name) FROM { tb_name | stb_name } [WHERE where_condition] [ RANGE(timestamp1,timestamp2) ] [EVERY(interval)] [FILL ({ VALUE | PREV | NULL | LINEAR | NEXT})];
+```sql
+SELECT INTERP(field_name) FROM { tb_name | stb_name } [WHERE where_condition] RANGE(timestamp1,timestamp2) EVERY(interval) FILL({ VALUE | PREV | NULL | LINEAR | NEXT});
```
**Description**: The value that matches the specified timestamp range is returned, if existing; or an interpolation value is returned.
-**Return value type**: Same as the column being operated upon.
+**Return value type**: Same as the column being operated upon
-**Applicable data types**: Numeric data types.
+**Applicable data types**: Numeric
-**Applicable table types**: table, STable, nested query.
+**Applicable table types**: standard tables and supertables
**More explanations**
- `INTERP` is used to get the value that matches the specified time slice from a column. If no such value exists an interpolation value will be returned based on `FILL` parameter.
- The input data of `INTERP` is the value of the specified column and a `where` clause can be used to filter the original data. If no `where` condition is specified then all original data is the input.
-- The output time range of `INTERP` is specified by `RANGE(timestamp1,timestamp2)` parameter, with timestamp1<=timestamp2. timestamp1 is the starting point of the output time range and must be specified. timestamp2 is the ending point of the output time range and must be specified. If `RANGE` is not specified, then the timestamp of the first row that matches the filter condition is treated as timestamp1, the timestamp of the last row that matches the filter condition is treated as timestamp2.
-- The number of rows in the result set of `INTERP` is determined by the parameter `EVERY`. Starting from timestamp1, one interpolation is performed for every time interval specified `EVERY` parameter. If `EVERY` parameter is not used, the time windows will be considered as no ending timestamp, i.e. there is only one time window from timestamp1.
-- Interpolation is performed based on `FILL` parameter. No interpolation is performed if `FILL` is not used, that means either the original data that matches is returned or nothing is returned.
-- `INTERP` can only be used to interpolate in single timeline. So it must be used with `group by tbname` when it's used on a STable. It can't be used with `GROUP BY` when it's used in the inner query of a nested query.
-- The result of `INTERP` is not influenced by `ORDER BY TIMESTAMP`, which impacts the output order only..
+- The output time range of `INTERP` is specified by `RANGE(timestamp1,timestamp2)` parameter, with timestamp1<=timestamp2. timestamp1 is the starting point of the output time range and must be specified. timestamp2 is the ending point of the output time range and must be specified.
+- The number of rows in the result set of `INTERP` is determined by the parameter `EVERY`. Starting from timestamp1, one interpolation is performed for every time interval specified `EVERY` parameter.
+- Interpolation is performed based on `FILL` parameter.
+- `INTERP` can only be used to interpolate in single timeline. So it must be used with `partition by tbname` when it's used on a STable.
### LAST
-```
+```sql
SELECT LAST(field_name) FROM { tb_name | stb_name } [WHERE clause];
```
-**Description**: The last non-NULL value of a specific column in a table or STable.
+**Description**: The last non-NULL value of a specific column in a table or STable
-**Return value type**: Same as the column being operated upon.
+**Return value type**:Same as the data type of the column being operated upon
-**Applicable data types**: All data types.
+**Applicable data types**: Numeric
-**Applicable table types**: table, STable.
+**Applicable table types**: standard tables and supertables
-**More explanations**:
+**More explanation**:
- LAST(\*) can be used to get the last non-NULL value of all columns
- If the values of a column in the result set are all NULL, NULL is returned for that column; if all columns in the result are all NULL, no result will be returned.
- When it's used on a STable, if there are multiple values with the timestamp in the result set, one of them will be returned randomly and it's not guaranteed that the same value is returned if the same query is run multiple times.
+
### LAST_ROW
-```
+```sql
SELECT LAST_ROW(field_name) FROM { tb_name | stb_name };
```
-**Description**: The last row of a table or STable.
+**Description**: The last row of a table or STable
-**Return value type**: Same as the column being operated upon.
+**Return value type**:Same as the data type of the column being operated upon
-**Applicable data types**: All data type.
+**Applicable data types**: Numeric
-**Applicable table types**: table, STable.
+**Applicable table types**: standard tables and supertables
**More explanations**:
-- When it's used against a STable, multiple rows with the same and largest timestamp may exist, in this case one of them is returned randomly and it's not guaranteed that the result is same if the query is run multiple times.
-- Cannot be used with `INTERVAL`.
+- When it's used on a STable, if there are multiple values with the timestamp in the result set, one of them will be returned randomly and it's not guaranteed that the same value is returned if the same query is run multiple times.
+- Can't be used with `INTERVAL`.
### MAX
-```
+```sql
SELECT MAX(field_name) FROM { tb_name | stb_name } [WHERE clause];
```
-**Description**: The maximum value of a specific column of a table or STable.
+**Description**: The maximum value of a specific column of a table or STable
-**Return value type**: Same as the data type of the column being operated upon.
+**Return value type**:Same as the data type of the column being operated upon
-**Applicable data types**: Numeric types.
+**Applicable data types**: Numeric
+
+**Applicable table types**: standard tables and supertables
-**Applicable table types**: table, STable.
### MIN
-```
+```sql
SELECT MIN(field_name) FROM {tb_name | stb_name} [WHERE clause];
```
-**Description**: The minimum value of a specific column in a table or STable.
+**Description**: The minimum value of a specific column in a table or STable
-**Return value type**: Same as the data type of the column being operated upon.
+**Return value type**:Same as the data type of the column being operated upon
-**Applicable data types**: Numeric types.
+**Applicable data types**: Numeric
+
+**Applicable table types**: standard tables and supertables
-**Applicable table types**: table, STable.
### MODE
-```
+```sql
SELECT MODE(field_name) FROM tb_name [WHERE clause];
```
**Description**:The value which has the highest frequency of occurrence. NULL is returned if there are multiple values which have highest frequency of occurrence.
-**Return value type**:Same as the data type of the column being operated upon.
+**Return value type**: Same as the input data
+
+**Applicable data types**: Numeric
-**Applicable data types**: All data types.
+**Applicable table types**: standard tables and supertables
-**More explanations**:Considering the number of returned result set is unpredictable, it's suggested to limit the number of unique values to 100,000, otherwise error will be returned.
### SAMPLE
```sql
- SELECT SAMPLE(field_name, K) FROM { tb_name | stb_name } [WHERE clause]
+SELECT SAMPLE(field_name, K) FROM { tb_name | stb_name } [WHERE clause]
```
**Description**: _k_ sampling values of a specific column. The applicable range of _k_ is [1,1000].
-**Return value type**: Same as the column being operated.
+**Return value type**: Same as the column being operated plus the associated timestamp
-**Applicable data types**: All data types.
+**Applicable data types**: Any data type except for tags of STable
-**Applicable table types**: table, STable.
+**Applicable nested query**: Inner query and Outer query
-**Applicable nested query**: Inner query and Outer query.
+**Applicable table types**: standard tables and supertables
-**More explanations**:
+**More explanations**:
+
+This function cannot be used in expression calculation.
+- Must be used with `PARTITION BY tbname` when it's used on a STable to force the result on each single timeline
-- Arithmetic operation cannot be operated on the result of `SAMPLE` function
-- Must be used with `Partition by tbname` when it's used on a STable to force the result on each single timeline.
### TAIL
-```
+```sql
SELECT TAIL(field_name, k, offset_val) FROM {tb_name | stb_name} [WHERE clause];
```
**Description**: The next _k_ rows are returned after skipping the last `offset_val` rows, NULL values are not ignored. `offset_val` is optional parameter. When it's not specified, the last _k_ rows are returned. When `offset_val` is used, the effect is same as `order by ts desc LIMIT k OFFSET offset_val`.
-**Parameter value range**: k: [1,100] offset_val: [0,100].
+**Parameter value range**: k: [1,100] offset_val: [0,100]
+
+**Return value type**:Same as the data type of the column being operated upon
+
+**Applicable data types**: Any data type except for timestamp, i.e. the primary key
-**Return value type**: Same as the column being operated upon.
+**Applicable table types**: standard tables and supertables
-**Applicable data types**: All data types.
### TOP
-```
+```sql
SELECT TOP(field_name, K) FROM { tb_name | stb_name } [WHERE clause];
```
**Description**: The greatest _k_ values of a specific column in a table or STable. If a value has multiple occurrences in the column but counting all of them in will exceed the upper limit _k_, then a part of them will be returned randomly.
-**Return value type**: Same as the column being operated upon.
+**Return value type**:Same as the data type of the column being operated upon
-**Applicable data types**: Numeric types.
+**Applicable data types**: Numeric
-**Applicable table types**: table, STable.
+**Applicable table types**: standard tables and supertables
-**More explanations**:
+**More explanation**:
-- _k_ must be in range [1,100].
-- The timestamp associated with the selected values are returned too.
-- Cannot be used with `FILL`.
+- _k_ must be in range [1,100]
+- The timestamp associated with the selected values are returned too
+- Can't be used with `FILL`
### UNIQUE
-```
+```sql
SELECT UNIQUE(field_name) FROM {tb_name | stb_name} [WHERE clause];
```
-**Description**: The values that occur the first time in the specified column. The effect is similar to `distinct` keyword, but it can also be used to match tags or timestamp.
+**Description**: The values that occur the first time in the specified column. The effect is similar to `distinct` keyword, but it can also be used to match tags or timestamp. The first occurrence of a timestamp or tag is used.
-**Return value type**: Same as the column or tag being operated upon.
+**Return value type**:Same as the data type of the column being operated upon
-**Applicable data types**: All data types.
+**Applicable column types**: Any data types except for timestamp
-**More explanations**:
+**Applicable table types**: table, STable
-- It can be used against table or STable, but can't be used together with time window, like `interval`, `state_window` or `session_window` .
-- Considering the number of result sets is unpredictable, it's suggested to limit the distinct values under 100,000 to control the memory usage, otherwise error will be returned.
-## Time-Series Specific Functions
+## Time-Series Extensions
-TDengine provides a set of time-series specific functions to better meet the requirements in querying time-series data. In general databases, similar functionalities can only be achieved with much more complex syntax and much worse performance. TDengine provides these functionalities in builtin functions so that the burden on user side is minimized.
+TDengine includes extensions to standard SQL that are intended specifically for time-series use cases. The functions enabled by these extensions require complex queries to implement in general-purpose databases. By offering them as built-in extensions, TDengine reduces user workload.
### CSUM
```sql
- SELECT CSUM(field_name) FROM { tb_name | stb_name } [WHERE clause]
+SELECT CSUM(field_name) FROM { tb_name | stb_name } [WHERE clause]
```
**Description**: The cumulative sum of each row for a specific column. The number of output rows is same as that of the input rows.
-**Return value type**: BIGINT for signed integer input types; UNSIGNED BIGINT for unsigned integer input types; DOUBLE for floating point input types.
+**Return value type**: Long integer for integers; Double for floating points. uint64_t for unsigned integers
-**Applicable data types**: Numeric types.
+**Applicable data types**: Numeric
-**Applicable table types**: table, STable.
+**Nested query**: It can be used in both the outer query and inner query in a nested query.
-**Applicable nested query**: Inner query and Outer query.
+**Applicable table types**: standard tables and supertables
+
+**More explanations**:
+
+- Arithmetic operation can't be performed on the result of `csum` function
+- Can only be used with aggregate functions This function can be used with supertables and standard tables.
+- Must be used with `PARTITION BY tbname` when it's used on a STable to force the result on each single timeline
-**More explanations**:
-- Arithmetic operation cannot be performed on the result of `csum` function.
-- Can only be used with aggregate functions.
-- `Partition by tbname` must be used together on a STable to force the result on a single timeline.
### DERIVATIVE
-```
+```sql
SELECT DERIVATIVE(field_name, time_interval, ignore_negative) FROM tb_name [WHERE clause];
```
**Description**: The derivative of a specific column. The time rage can be specified by parameter `time_interval`, the minimum allowed time range is 1 second (1s); the value of `ignore_negative` can be 0 or 1, 1 means negative values are ignored.
-**Return value type**: DOUBLE.
+**Return value type**: DOUBLE
-**Applicable data types**: Numeric types.
+**Applicable data types**: Numeric
-**Applicable table types**: table, STable.
+**Applicable table types**: standard tables and supertables
-**More explanations**:
-
-- The number of result rows is the number of total rows in the time range subtracted by one, no output for the first row.
+**More explanation**:
+
- It can be used together with `PARTITION BY tbname` against a STable.
-- Can be used together with selection of relative columns. E.g. select \_rowts, DERIVATIVE() from.
+- It can be used together with a selected column. For example: select \_rowts, DERIVATIVE() from。
### DIFF
@@ -1070,159 +1079,159 @@ SELECT {DIFF(field_name, ignore_negative) | DIFF(field_name)} FROM tb_name [WHER
**Description**: The different of each row with its previous row for a specific column. `ignore_negative` can be specified as 0 or 1, the default value is 1 if it's not specified. `1` means negative values are ignored.
-**Return value type**: Same as the column being operated upon.
+**Return value type**:Same as the data type of the column being operated upon
-**Applicable data types**: Numeric types.
+**Applicable data types**: Numeric
-**Applicable table types**: table, STable.
+**Applicable table types**: standard tables and supertables
-**More explanations**:
+**More explanation**:
+
+- The number of result rows is the number of rows subtracted by one, no output for the first row
+- It can be used together with a selected column. For example: select \_rowts, DIFF() from。
-- The number of result rows is the number of rows subtracted by one, no output for the first row.
-- It can be used on STable with `PARTITION by tbname`.
-- Can be used together with selection of relative columns. E.g. select \_rowts, DIFF() from.
### IRATE
-```
+```sql
SELECT IRATE(field_name) FROM tb_name WHERE clause;
```
**Description**: instantaneous rate on a specific column. The last two samples in the specified time range are used to calculate instantaneous rate. If the last sample value is smaller, then only the last sample value is used instead of the difference between the last two sample values.
-**Return value type**: DOUBLE.
+**Return value type**: DOUBLE
-**Applicable data types**: Numeric types.
+**Applicable data types**: Numeric
-**Applicable table types**: table, STable.
+**Applicable table types**: standard tables and supertables
-**More explanations**:
-
-- It can be used on stble with `PARTITION BY`, i.e. timelines generated by `PARTITION BY tbname` on a STable.
### MAVG
```sql
- SELECT MAVG(field_name, K) FROM { tb_name | stb_name } [WHERE clause]
+SELECT MAVG(field_name, K) FROM { tb_name | stb_name } [WHERE clause]
```
**Description**: The moving average of continuous _k_ values of a specific column. If the number of input rows is less than _k_, nothing is returned. The applicable range of _k_ is [1,1000].
-**Return value type**: DOUBLE.
+**Return value type**: DOUBLE
-**Applicable data types**: Numeric types.
+**Applicable data types**: Numeric
-**Applicable nested query**: Inner query and Outer query.
+**Nested query**: It can be used in both the outer query and inner query in a nested query.
-**Applicable table types**: table, STable.
+**Applicable table types**: standard tables and supertables
-**More explanations**:
+**More explanations**:
+
+- Arithmetic operation can't be performed on the result of `MAVG`.
+- Can only be used with data columns, can't be used with tags. - Can't be used with aggregate functions.
+- Must be used with `PARTITION BY tbname` when it's used on a STable to force the result on each single timeline
-- Arithmetic operation cannot be performed on the result of `MAVG`.
-- Cannot be used with aggregate functions.
-- Must be used with `PARTITION BY tbname` when it's used on a STable to force the result on each single timeline.
### STATECOUNT
-```
+```sql
SELECT STATECOUNT(field_name, oper, val) FROM { tb_name | stb_name } [WHERE clause];
```
-**Description**: The number of continuous rows satisfying the specified conditions for a specific column. If the specified condition is evaluated as true, the number is increased by 1; otherwise the number is reset to -1. If the input value is NULL, then the corresponding row is skipped.
+**Description**: The number of continuous rows satisfying the specified conditions for a specific column. The result is shown as an extra column for each row. If the specified condition is evaluated as true, the number is increased by 1; otherwise the number is reset to -1. If the input value is NULL, then the corresponding row is skipped.
**Applicable parameter values**:
-- oper : Can be one of "LT" (lower than), "GT" (greater than), "LE" (lower than or euqal to), "GE" (greater than or equal to), "NE" (not equal to), "EQ" (equal to).
-- val : Numeric types.
+- oper : Can be one of `'LT'` (lower than), `'GT'` (greater than), `'LE'` (lower than or equal to), `'GE'` (greater than or equal to), `'NE'` (not equal to), `'EQ'` (equal to), the value is case insensitive, the value must be in quotes.
+- val : Numeric types
-**Return value type**: INTEGER.
+**Return value type**: Integer
-**Applicable data types**: Numeric types.
+**Applicable data types**: Numeric
-**Applicable table types**: table, STable.
+**Applicable nested query**: Outer query only
-**Applicable nested query**: Outer query only.
+**Applicable table types**: standard tables and supertables
**More explanations**:
-- Must be used together with `PARTITION BY tbname` when it's used on a STable to force the result into each single timeline.
-- Cannot be used with window operation, like interval/state_window/session_window.
+- Must be used together with `PARTITION BY tbname` when it's used on a STable to force the result into each single timeline]
+- Can't be used with window operation, like interval/state_window/session_window
+
### STATEDURATION
-```
+```sql
SELECT stateDuration(field_name, oper, val, unit) FROM { tb_name | stb_name } [WHERE clause];
```
-**Description**: The length of time range in which all rows satisfy the specified condition for a specific column. The length for the first row that satisfies the condition is 0. Next, if the condition is evaluated as true for a row, the time interval between current row and its previous row is added up to the time range; otherwise the time range length is reset to -1. If the value of the column is NULL, the corresponding row is skipped.
+**Description**: The length of time range in which all rows satisfy the specified condition for a specific column. The result is shown as an extra column for each row. The length for the first row that satisfies the condition is 0. Next, if the condition is evaluated as true for a row, the time interval between current row and its previous row is added up to the time range; otherwise the time range length is reset to -1. If the value of the column is NULL, the corresponding row is skipped.
**Applicable parameter values**:
-- oper : Can be one of "LT" (lower than), "GT" (greater than), "LE" (lower than or euqal to), "GE" (greater than or equal to), "NE" (not equal to), "EQ" (equal to).
-- val : Numeric types.
-- unit : The unit of time interval, can be: 1b(nanosecond), 1u(microsecond),1a(millisecond),1s(second),1m(minute),1h(hour),1d(day),1w(week). If not specified, default is same as the current database time precision in use.
+- oper : Can be one of `'LT'` (lower than), `'GT'` (greater than), `'LE'` (lower than or equal to), `'GE'` (greater than or equal to), `'NE'` (not equal to), `'EQ'` (equal to), the value is case insensitive, the value must be in quotes.
+- val : Numeric types
+- unit: The unit of time interval. Enter one of the following options: 1b (nanoseconds), 1u (microseconds), 1a (milliseconds), 1s (seconds), 1m (minutes), 1h (hours), 1d (days), or 1w (weeks) If you do not enter a unit of time, the precision of the current database is used by default.
-**Return value type**: INTEGER.
+**Return value type**: Integer
-**Applicable data types**: Numeric types.
+**Applicable data types**: Numeric
-**Applicable table types**: table, STable.
+**Applicable nested query**: Outer query only
-**Applicable nested query**: Outer query only.
+**Applicable table types**: standard tables and supertables
**More explanations**:
-- Must be used together with `PARTITION BY tbname` when it's used on a STable to force the result into each single timeline.
-- Cannot be used with window operation, like interval/state_window/session_window.
+- Must be used together with `PARTITION BY tbname` when it's used on a STable to force the result into each single timeline]
+- Can't be used with window operation, like interval/state_window/session_window
+
### TWA
-```
+```sql
SELECT TWA(field_name) FROM tb_name WHERE clause;
```
-**Description**: Time weighted average on a specific column within a time range.
+**Description**: Time weighted average on a specific column within a time range
-**Return value type**: DOUBLE.
+**Return value type**: DOUBLE
-**Applicable data types**: Numeric types.
+**Applicable data types**: Numeric
-**Applicable table types**: table, STable.
+**Applicable table types**: standard tables and supertables
-**More explanations**:
+- Must be used together with `PARTITION BY tbname` to force the result into each single timeline.
-- It can be used on stable with `PARTITION BY`, i.e. timelines generated by `PARTITION BY tbname` on a STable.
## System Information Functions
### DATABASE
-```
+```sql
SELECT DATABASE();
```
-**Description**:Return the current database being used. If the user doesn't specify database when logon and doesn't use `USE` SQL command to switch the datbase, this function returns NULL.
+**Description**: The current database. If no database is specified upon logging in and no database is specified with `USE` after login, NULL will be returned by `select database()`.
+
### CLIENT_VERSION
-```
+```sql
SELECT CLIENT_VERSION();
```
-**Description**:Return the client version.
+**Description**: The client version.
### SERVER_VERSION
-```
+```sql
SELECT SERVER_VERSION();
```
-**Description**:Returns the server version.
+**Description**: The server version.
### SERVER_STATUS
-```
-SELECT SERVER_VERSION();
+```sql
+SELECT SERVER_STATUS();
```
-**Description**:Returns the server's status.
+**Description**: The server status.
diff --git a/docs/en/12-taos-sql/12-distinguished.md b/docs/en/12-taos-sql/12-distinguished.md
index d2f7cf66b63521d157a6e05f1dd8d93658d65549..707089abe54fc12bb09de47c1c51af1a32b8cbcd 100644
--- a/docs/en/12-taos-sql/12-distinguished.md
+++ b/docs/en/12-taos-sql/12-distinguished.md
@@ -1,60 +1,35 @@
---
-sidebar_label: Distinguished
-title: Distinguished Query for Time Series Database
+sidebar_label: Time-Series Extensions
+title: Time-Series Extensions
---
-Aggregation by time window is supported in TDengine. For example, in the case where temperature sensors report the temperature every seconds, the average temperature for every 10 minutes can be retrieved by performing a query with a time window.
-Window related clauses are used to divide the data set to be queried into subsets and then aggregation is performed across the subsets. There are three kinds of windows: time window, status window, and session window. There are two kinds of time windows: sliding window and flip time/tumbling window.
+As a purpose-built database for storing and processing time-series data, TDengine provides time-series-specific extensions to standard SQL.
-## Time Window
+These extensions include tag-partitioned queries and windowed queries.
-The `INTERVAL` clause is used to generate time windows of the same time interval. The `SLIDING` parameter is used to specify the time step for which the time window moves forward. The query is performed on one time window each time, and the time window moves forward with time. When defining a continuous query, both the size of the time window and the step of forward sliding time need to be specified. As shown in the figure blow, [t0s, t0e] ,[t1s , t1e], [t2s, t2e] are respectively the time ranges of three time windows on which continuous queries are executed. The time step for which time window moves forward is marked by `sliding time`. Query, filter and aggregate operations are executed on each time window respectively. When the time step specified by `SLIDING` is same as the time interval specified by `INTERVAL`, the sliding time window is actually a flip time/tumbling window.
-
-
+## Tag-Partitioned Queries
-`INTERVAL` and `SLIDING` should be used with aggregate functions and select functions. The SQL statement below is illegal because no aggregate or selection function is used with `INTERVAL`.
+When you query a supertable, you may need to partition the supertable by tag and perform additional operations on a specific partition. In this case, you can use the following SQL clause:
+```sql
+PARTITION BY part_list
```
-SELECT * FROM temp_tb_1 INTERVAL(1m);
-```
-
-The time step specified by `SLIDING` cannot exceed the time interval specified by `INTERVAL`. The SQL statement below is illegal because the time length specified by `SLIDING` exceeds that specified by `INTERVAL`.
-
-```
-SELECT COUNT(*) FROM temp_tb_1 INTERVAL(1m) SLIDING(2m);
-```
-
-When the time length specified by `SLIDING` is the same as that specified by `INTERVAL`, the sliding window is actually a flip/tumbling window. The minimum time range specified by `INTERVAL` is 10 milliseconds (10a) prior to version 2.1.5.0. Since version 2.1.5.0, the minimum time range by `INTERVAL` can be 1 microsecond (1u). However, if the DB precision is millisecond, the minimum time range is 1 millisecond (1a). Please note that the `timezone` parameter should be configured to be the same value in the `taos.cfg` configuration file on client side and server side.
-## Status Window
+part_list can be any scalar expression, such as a column, constant, scalar function, or a combination of the preceding items.
-In case of using integer, bool, or string to represent the status of a device at any given moment, continuous rows with the same status belong to a status window. Once the status changes, the status window closes. As shown in the following figure, there are two status windows according to status, [2019-04-28 14:22:07,2019-04-28 14:22:10] and [2019-04-28 14:22:11,2019-04-28 14:22:12]. Status window is not applicable to STable for now.
-
-
-
-`STATE_WINDOW` is used to specify the column on which the status window will be based. For example:
-
-```
-SELECT COUNT(*), FIRST(ts), status FROM temp_tb_1 STATE_WINDOW(status);
-```
+A PARTITION BY clause with a tag is processed as follows:
-## Session Window
+- The PARTITION BY clause must occur after the WHERE clause and cannot be used with a JOIN clause.
+- The PARTITION BY clause partitions the super table by the specified tag group, and the specified calculation is performed on each partition. The calculation performed is determined by the rest of the statement - a window clause, GROUP BY clause, or SELECT clause.
+- You can use PARTITION BY together with a window clause or GROUP BY clause. In this case, the window or GROUP BY clause takes effect on every partition. For example, the following statement partitions the table by the location tag, performs downsampling over a 10 minute window, and returns the maximum value:
```sql
-SELECT COUNT(*), FIRST(ts) FROM temp_tb_1 SESSION(ts, tol_val);
+select max(current) from meters partition by location interval(10m)
```
-The primary key, i.e. timestamp, is used to determine which session window a row belongs to. If the time interval between two adjacent rows is within the time range specified by `tol_val`, they belong to the same session window; otherwise they belong to two different session windows. As shown in the figure below, if the limit of time interval for the session window is specified as 12 seconds, then the 6 rows in the figure constitutes 2 time windows, [2019-04-28 14:22:10,2019-04-28 14:22:30] and [2019-04-28 14:23:10,2019-04-28 14:23:30], because the time difference between 2019-04-28 14:22:30 and 2019-04-28 14:23:10 is 40 seconds, which exceeds the time interval limit of 12 seconds.
-
-
-
-If the time interval between two continuous rows are within the time interval specified by `tol_value` they belong to the same session window; otherwise a new session window is started automatically. Session window is not supported on STable for now.
-
-## More On Window Aggregate
+## Windowed Queries
-### Syntax
-
-The full syntax of aggregate by window is as follows:
+Aggregation by time window is supported in TDengine. For example, in the case where temperature sensors report the temperature every seconds, the average temperature for every 10 minutes can be retrieved by performing a query with a time window. Window related clauses are used to divide the data set to be queried into subsets and then aggregation is performed across the subsets. There are three kinds of windows: time window, status window, and session window. There are two kinds of time windows: sliding window and flip time/tumbling window. The query syntax is as follows:
```sql
SELECT function_list FROM tb_name
@@ -63,27 +38,45 @@ SELECT function_list FROM tb_name
[STATE_WINDOW(col)]
[INTERVAL(interval [, offset]) [SLIDING sliding]]
[FILL({NONE | VALUE | PREV | NULL | LINEAR | NEXT})]
-
-SELECT function_list FROM stb_name
- [WHERE where_condition]
- [INTERVAL(interval [, offset]) [SLIDING sliding]]
- [FILL({NONE | VALUE | PREV | NULL | LINEAR | NEXT})]
- [GROUP BY tags]
```
-### Restrictions
+The following restrictions apply:
+
+### Restricted Functions
- Aggregate functions and select functions can be used in `function_list`, with each function having only one output. For example COUNT, AVG, SUM, STDDEV, LEASTSQUARES, PERCENTILE, MIN, MAX, FIRST, LAST. Functions having multiple outputs, such as DIFF or arithmetic operations can't be used.
- `LAST_ROW` can't be used together with window aggregate.
- Scalar functions, like CEIL/FLOOR, can't be used with window aggregate.
+
+### Other Rules
+
+- The window clause must occur after the PARTITION BY clause and before the GROUP BY clause. It cannot be used with a GROUP BY clause.
+- SELECT clauses on windows can contain only the following expressions:
+ - Constants
+ - Aggregate functions
+ - Expressions that include the preceding expressions.
+- The window clause cannot be used with a GROUP BY clause.
- `WHERE` clause can be used to specify the starting and ending time and other filter conditions
-- `FILL` clause is used to specify how to fill when there is data missing in any window, including:
- 1. NONE: No fill (the default fill mode)
- 2. VALUE:Fill with a fixed value, which should be specified together, for example `FILL(VALUE, 1.23)`
- 3. PREV:Fill with the previous non-NULL value, `FILL(PREV)`
- 4. NULL:Fill with NULL, `FILL(NULL)`
- 5. LINEAR:Fill with the closest non-NULL value, `FILL(LINEAR)`
- 6. NEXT:Fill with the next non-NULL value, `FILL(NEXT)`
+
+
+### Window Pseudocolumns
+
+**\_WSTART, \_WEND, and \_WDURATION**
+
+The \_WSTART, \_WEND, and \_WDURATION pseudocolumns indicate the beginning, end, and duration of a window.
+
+These pseudocolumns occur after the aggregation clause.
+
+### FILL Clause
+
+`FILL` clause is used to specify how to fill when there is data missing in any window, including:
+
+1. NONE: No fill (the default fill mode)
+2. VALUE:Fill with a fixed value, which should be specified together, for example `FILL(VALUE, 1.23)` Note: The value filled depends on the data type. For example, if you run FILL(VALUE 1.23) on an integer column, the value 1 is filled.
+3. PREV:Fill with the previous non-NULL value, `FILL(PREV)`
+4. NULL:Fill with NULL, `FILL(NULL)`
+5. LINEAR:Fill with the closest non-NULL value, `FILL(LINEAR)`
+6. NEXT:Fill with the next non-NULL value, `FILL(NEXT)`
:::info
@@ -93,17 +86,66 @@ SELECT function_list FROM stb_name
:::
-Aggregate by time window is also used in continuous query, please refer to [Continuous Query](/develop/continuous-query).
+### Time Window
+
+There are two kinds of time windows: sliding window and flip time/tumbling window.
+
+The `INTERVAL` clause is used to generate time windows of the same time interval. The `SLIDING` parameter is used to specify the time step for which the time window moves forward. The query is performed on one time window each time, and the time window moves forward with time. When defining a continuous query, both the size of the time window and the step of forward sliding time need to be specified. As shown in the figure blow, [t0s, t0e] ,[t1s , t1e], [t2s, t2e] are respectively the time ranges of three time windows on which continuous queries are executed. The time step for which time window moves forward is marked by `sliding time`. Query, filter and aggregate operations are executed on each time window respectively. When the time step specified by `SLIDING` is same as the time interval specified by `INTERVAL`, the sliding time window is actually a flip time/tumbling window.
+
+
+
+`INTERVAL` and `SLIDING` should be used with aggregate functions and select functions. The SQL statement below is illegal because no aggregate or selection function is used with `INTERVAL`.
+
+```
+SELECT * FROM temp_tb_1 INTERVAL(1m);
+```
+
+The time step specified by `SLIDING` cannot exceed the time interval specified by `INTERVAL`. The SQL statement below is illegal because the time length specified by `SLIDING` exceeds that specified by `INTERVAL`.
-## Examples
+```
+SELECT COUNT(*) FROM temp_tb_1 INTERVAL(1m) SLIDING(2m);
+```
+
+When using time windows, note the following:
+
+- The window length for aggregation depends on the value of INTERVAL. The minimum interval is 10 ms. You can configure a window as an offset from UTC 0:00. The offset cannot be smaler than the interval. You can use SLIDING to specify the length of time that the window moves forward.
+Please note that the `timezone` parameter should be configured to be the same value in the `taos.cfg` configuration file on client side and server side.
+- The result set is in ascending order of timestamp when you aggregate by time window.
+
+### Status Window
+
+In case of using integer, bool, or string to represent the status of a device at any given moment, continuous rows with the same status belong to a status window. Once the status changes, the status window closes. As shown in the following figure, there are two status windows according to status, [2019-04-28 14:22:07,2019-04-28 14:22:10] and [2019-04-28 14:22:11,2019-04-28 14:22:12]. Status window is not applicable to STable for now.
+
+
+
+`STATE_WINDOW` is used to specify the column on which the status window will be based. For example:
+
+```
+SELECT COUNT(*), FIRST(ts), status FROM temp_tb_1 STATE_WINDOW(status);
+```
+
+### Session Window
+
+The primary key, i.e. timestamp, is used to determine which session window a row belongs to. As shown in the figure below, if the limit of time interval for the session window is specified as 12 seconds, then the 6 rows in the figure constitutes 2 time windows, [2019-04-28 14:22:10,2019-04-28 14:22:30] and [2019-04-28 14:23:10,2019-04-28 14:23:30] because the time difference between 2019-04-28 14:22:30 and 2019-04-28 14:23:10 is 40 seconds, which exceeds the time interval limit of 12 seconds.
+
+
+
+If the time interval between two continuous rows are within the time interval specified by `tol_value` they belong to the same session window; otherwise a new session window is started automatically. Session window is not supported on STable for now.
+
+```
+
+SELECT COUNT(*), FIRST(ts) FROM temp_tb_1 SESSION(ts, tol_val);
+```
+
+### Examples
A table of intelligent meters can be created by the SQL statement below:
-```sql
+```
CREATE TABLE meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT);
```
-The average current, maximum current and median of current in every 10 minutes for the past 24 hours can be calculated using the SQL statement below, with missing values filled with the previous non-NULL values.
+The average current, maximum current and median of current in every 10 minutes for the past 24 hours can be calculated using the SQL statement below, with missing values filled with the previous non-NULL values. The query statement is as follows:
```
SELECT AVG(current), MAX(current), APERCENTILE(current, 50) FROM meters
diff --git a/docs/en/12-taos-sql/13-tmq.md b/docs/en/12-taos-sql/13-tmq.md
index 4d9c475a3829456916175d8a0518c47d67bc18ee..befab4f4f01e595564e93ffcfbb0723e13294af0 100644
--- a/docs/en/12-taos-sql/13-tmq.md
+++ b/docs/en/12-taos-sql/13-tmq.md
@@ -1,41 +1,34 @@
---
-sidebar_label: 消息队列
-title: 消息队列
+sidebar_label: Data Subscription
+title: Data Subscription
---
-TDengine 3.0.0.0 开始对消息队列做了大幅的优化和增强以简化用户的解决方案。
+The information in this document is related to the TDengine data subscription feature.
-## 创建订阅主题
+## Create a Topic
```sql
-CREATE TOPIC [IF NOT EXISTS] topic_name AS {subquery | DATABASE db_name | STABLE stb_name };
+CREATE TOPIC [IF NOT EXISTS] topic_name AS subquery;
```
-订阅主题包括三种:列订阅、超级表订阅和数据库订阅。
-**列订阅是**用 subquery 描述,支持过滤和标量函数和 UDF 标量函数,不支持 JOIN、GROUP BY、窗口切分子句、聚合函数和 UDF 聚合函数。列订阅规则如下:
+You can use filtering, scalar functions, and user-defined scalar functions with a topic. JOIN, GROUP BY, windows, aggregate functions, and user-defined aggregate functions are not supported. The following rules apply to subscribing to a column:
-1. TOPIC 一旦创建则返回结果的字段确定
-2. 被订阅或用于计算的列不可被删除、修改
-3. 列可以新增,但新增的列不出现在订阅结果字段中
-4. 对于 select \*,则订阅展开为创建时所有的列(子表、普通表为数据列,超级表为数据列加标签列)
+1. The returned field is determined when the topic is created.
+2. Columns to which a consumer is subscribed or that are involved in calculations cannot be deleted or modified.
+3. If you add a column, the new column will not appear in the results for the subscription.
+4. If you run `SELECT \*`, all columns in the subscription at the time of its creation are displayed. This includes columns in supertables, standard tables, and subtables. Supertables are shown as data columns plus tag columns.
-**超级表订阅和数据库订阅**规则如下:
-1. 被订阅主体的 schema 变更不受限
-2. 返回消息中 schema 是块级别的,每块的 schema 可能不一样
-3. 列变更后写入的数据若未落盘,将以写入时的 schema 返回
-4. 列变更后写入的数据若未已落盘,将以落盘时的 schema 返回
-
-## 删除订阅主题
+## Delete a Topic
```sql
DROP TOPIC [IF EXISTS] topic_name;
```
-此时如果该订阅主题上存在 consumer,则此 consumer 会收到一个错误。
+If a consumer is subscribed to the topic that you delete, the consumer will receive an error.
-## 查看订阅主题
+## View Topics
## SHOW TOPICS
@@ -43,24 +36,24 @@ DROP TOPIC [IF EXISTS] topic_name;
SHOW TOPICS;
```
-显示当前数据库下的所有主题的信息。
+The preceding command displays all topics in the current database.
-## 创建消费组
+## Create Consumer Group
-消费组的创建只能通过 TDengine 客户端驱动或者连接器所提供的 API 创建。
+You can create consumer groups only through the TDengine Client driver or the API provided by a connector.
-## 删除消费组
+## Delete Consumer Group
```sql
DROP CONSUMER GROUP [IF EXISTS] cgroup_name ON topic_name;
```
-删除主题 topic_name 上的消费组 cgroup_name。
+This deletes the cgroup_name in the topic_name.
-## 查看消费组
+## View Consumer Groups
```sql
SHOW CONSUMERS;
```
-显示当前数据库下所有活跃的消费者的信息。
+The preceding command displays all consumer groups in the current database.
diff --git a/docs/en/12-taos-sql/14-stream.md b/docs/en/12-taos-sql/14-stream.md
index 7ff7da2bfb82e282cefb1a554283860d0e683de2..fcd78765104af17285b43749969821ceb98da33b 100644
--- a/docs/en/12-taos-sql/14-stream.md
+++ b/docs/en/12-taos-sql/14-stream.md
@@ -1,13 +1,13 @@
---
-sidebar_label: 流式计算
-title: 流式计算
+sidebar_label: Stream Processing
+title: Stream Processing
---
-在时序数据的处理中,经常要对原始数据进行清洗、预处理,再使用时序数据库进行长久的储存。用户通常需要在时序数据库之外再搭建 Kafka、Flink、Spark 等流计算处理引擎,增加了用户的开发成本和维护成本。
+Raw time-series data is often cleaned and preprocessed before being permanently stored in a database. Stream processing components like Kafka, Flink, and Spark are often deployed alongside a time-series database to handle these operations, increasing system complexity and maintenance costs.
-使用 TDengine 3.0 的流式计算引擎能够最大限度的减少对这些额外中间件的依赖,真正将数据的写入、预处理、长期存储、复杂分析、实时计算、实时报警触发等功能融为一体,并且,所有这些任务只需要使用 SQL 完成,极大降低了用户的学习成本、使用成本。
+Because stream processing is built in to TDengine, you are no longer reliant on middleware. TDengine offers a unified platform for writing, preprocessing, permanent storage, complex analysis, and real-time computation and alerting. Additionally, you can use SQL to perform all these tasks.
-## 创建流式计算
+## Create a Stream
```sql
CREATE STREAM [IF NOT EXISTS] stream_name [stream_options] INTO stb_name AS subquery
@@ -18,7 +18,7 @@ stream_options: {
```
-其中 subquery 是 select 普通查询语法的子集:
+The subquery is a subset of standard SELECT query syntax:
```sql
subquery: SELECT [DISTINCT] select_list
@@ -26,97 +26,74 @@ subquery: SELECT [DISTINCT] select_list
[WHERE condition]
[PARTITION BY tag_list]
[window_clause]
- [group_by_clause]
```
-不支持 order_by,limit,slimit,fill 语句
+Session windows, state windows, and sliding windows are supported. When you configure a session or state window for a supertable, you must use PARTITION BY TBNAME.
-例如,如下语句创建流式计算,同时自动创建名为 avg_vol 的超级表,此流计算以一分钟为时间窗口、30 秒为前向增量统计这些电表的平均电压,并将来自 meters 表的数据的计算结果写入 avg_vol 表,不同 partition 的数据会分别创建子表并写入不同子表。
+```sql
+window_clause: {
+ SESSION(ts_col, tol_val)
+ | STATE_WINDOW(col)
+ | INTERVAL(interval_val [, interval_offset]) [SLIDING (sliding_val)]
+}
+```
+
+`SESSION` indicates a session window, and `tol_val` indicates the maximum range of the time interval. If the time interval between two continuous rows are within the time interval specified by `tol_val` they belong to the same session window; otherwise a new session window is started automatically.
+
+For example, the following SQL statement creates a stream and automatically creates a supertable named `avg_vol`. The stream has a 1 minute time window that slides forward in 30 second intervals to calculate the average voltage of the meters supertable.
```sql
CREATE STREAM avg_vol_s INTO avg_vol AS
SELECT _wstartts, count(*), avg(voltage) FROM meters PARTITION BY tbname INTERVAL(1m) SLIDING(30s);
```
-## 删除流式计算
+## Delete a Stream
```sql
DROP STREAM [IF NOT EXISTS] stream_name
```
-仅删除流式计算任务,由流式计算写入的数据不会被删除。
+This statement deletes the stream processing service only. The data generated by the stream is retained.
-## 展示流式计算
+## View Streams
```sql
SHOW STREAMS;
```
-## 流式计算的触发模式
-
-在创建流时,可以通过 TRIGGER 指令指定流式计算的触发模式。
-
-对于非窗口计算,流式计算的触发是实时的;对于窗口计算,目前提供 3 种触发模式:
-
-1. AT_ONCE:写入立即触发
-
-2. WINDOW_CLOSE:窗口关闭时触发(窗口关闭由事件时间决定,可配合 watermark 使用,详见《流式计算的乱序数据容忍策略》)
-
-3. MAX_DELAY time:若窗口关闭,则触发计算。若窗口未关闭,且未关闭时长超过 max delay 指定的时间,则触发计算。
-
-由于窗口关闭是由事件时间决定的,如事件流中断、或持续延迟,则事件时间无法更新,可能导致无法得到最新的计算结果。
+## Trigger Stream Processing
-因此,流式计算提供了以事件时间结合处理时间计算的 MAX_DELAY 触发模式。
+When you create a stream, you can use the TRIGGER parameter to specify triggering conditions for it.
-MAX_DELAY 模式在窗口关闭时会立即触发计算。此外,当数据写入后,计算触发的时间超过 max delay 指定的时间,则立即触发计算
+For non-windowed processing, triggering occurs in real time. For windowed processing, there are three methods of triggering:
-## 流式计算的乱序数据容忍策略
+1. AT_ONCE: triggers on write
-在创建流时,可以在 stream_option 中指定 watermark。
+2. WINDOW_CLOSE: triggers when the window closes. This is determined by the event time. You can use WINDOW_CLOSE together with `watermark`. For more information, see Stream Processing Strategy for Out-of-Order Data.
-流式计算通过 watermark 来度量对乱序数据的容忍程度,watermark 默认为 0。
+3. MAX_DELAY: triggers when the window closes. If the window has not closed but the time elapsed exceeds MAX_DELAY, stream processing is also triggered.
-T = 最新事件时间 - watermark
+Because the window closing is determined by the event time, a delay or termination of an event stream will prevent the event time from being updated. This may result in an inability to obtain the latest results.
-每批到来的数据都会以上述公式更新窗口关闭时间,并将窗口结束时间 < T 的所有打开的窗口关闭,若触发模式为 WINDOW_CLOSE 或 MAX_DELAY,则推送窗口聚合结果。
+For this reason, MAX_DELAY is provided as a way to ensure that processing occurs even if the window does not close.
-流式计算的过期数据处理策略
-对于已关闭的窗口,再次落入该窗口中的数据被标记为过期数据,对于过期数据,流式计算提供两种处理方式:
+MAX_DELAY also triggers when the window closes. Additionally, if a write occurs but the processing is not triggered before MAX_DELAY expires, processing is also triggered.
-1. 直接丢弃:这是常见流式计算引擎提供的默认(甚至是唯一)计算模式
+## Stream Processing Strategy for Out-of-Order Data
-2. 重新计算:从 TSDB 中重新查找对应窗口的所有数据并重新计算得到最新结果
+When you create a stream, you can specify a watermark in the `stream_option` parameter.
-无论在哪种模式下,watermark 都应该被妥善设置,来得到正确结果(直接丢弃模式)或避免频繁触发重算带来的性能开销(重新计算模式)。
+The watermark is used to specify the tolerance for out-of-order data. The default value is 0.
-## 流式计算的数据填充策略
+T = latest event time - watermark
-TODO
+The window closing time for each batch of data that arrives at the system is updated using the preceding formula, and all windows are closed whose closing time is less than T. If the triggering method is WINDOW_CLOSE or MAX_DELAY, the aggregate result for the window is pushed.
-## 流式计算与会话窗口(session window)
+Stream processing strategy for expired data
+The data in expired windows is tagged as expired. TDengine stream processing provides two methods for handling such data:
-```sql
-window_clause: {
- SESSION(ts_col, tol_val)
- | STATE_WINDOW(col)
- | INTERVAL(interval_val [, interval_offset]) [SLIDING (sliding_val)] [FILL(fill_mod_and_val)]
-}
-```
-
-其中,SESSION 是会话窗口,tol_val 是时间间隔的最大范围。在 tol_val 时间间隔范围内的数据都属于同一个窗口,如果连续的两条数据的时间超过 tol_val,则自动开启下一个窗口。
+1. Drop the data. This is the default and often only handling method for most stream processing engines.
-## 流式计算的监控与流任务分布查询
+2. Recalculate the data. In this method, all data in the window is reobtained from the database and recalculated. The latest results are then returned.
-TODO
-
-## 流式计算的内存控制与存算分离
-
-TODO
-
-## 流式计算的暂停与恢复
-
-```sql
-STOP STREAM stream_name;
-
-RESUME STREAM stream_name;
-```
+In both of these methods, configuring the watermark is essential for obtaining accurate results (if expired data is dropped) and avoiding repeated triggers that affect system performance (if expired data is recalculated).
diff --git a/docs/en/12-taos-sql/16-operators.md b/docs/en/12-taos-sql/16-operators.md
index 0ca9ec49430a66384400bc41cd08562b3d5d28c7..c426e2879342e430c61c4f8133aa9f8186888941 100644
--- a/docs/en/12-taos-sql/16-operators.md
+++ b/docs/en/12-taos-sql/16-operators.md
@@ -5,62 +5,62 @@ title: Operators
## Arithmetic Operators
-| # | **Operator** | **Data Types** | **Description** |
-| --- | :----------: | -------------- | --------------------------------------------------------- |
-| 1 | +, - | Numeric Types | Representing positive or negative numbers, unary operator |
-| 2 | +, - | Numeric Types | Addition and substraction, binary operator |
-| 3 | \*, / | Numeric Types | Multiplication and division, binary oeprator |
-| 4 | % | Numeric Types | Taking the remainder, binary operator |
+| # | **Operator** | **Supported Data Types** | **Description** |
+| --- | :--------: | -------------- | -------------------------- |
+| 1 | +, - | Numeric | Expresses sign. Unary operators. |
+| 2 | +, - | Numeric | Expresses addition and subtraction. Binary operators. |
+| 3 | \*, / | Numeric | Expresses multiplication and division. Binary operators. |
+| 4 | % | Numeric | Expresses modulo. Binary operator. |
## Bitwise Operators
-| # | **Operator** | **Data Types** | **Description** |
-| --- | :----------: | -------------- | ----------------------------- |
-| 1 | & | Numeric Types | Bitewise AND, binary operator |
-| 2 | \| | Numeric Types | Bitewise OR, binary operator |
+| # | **Operator** | **Supported Data Types** | **Description** |
+| --- | :--------: | -------------- | ------------------ |
+| 1 | & | Numeric | Bitwise AND. Binary operator. |
+| 2 | \| | Numeric | Bitwise OR. Binary operator. |
-## JSON Operator
+## JSON Operators
-`->` operator can be used to get the value of a key in a column of JSON type, the left oeprand is the column name, the right operand is a string constant. For example, `col->'name'` returns the value of key `'name'`.
+The `->` operator returns the value for a key in JSON column. Specify the column indicator on the left of the operator and the key name on the right of the operator. For example, `col->name` returns the value of the name key.
-## Set Operator
+## Set Operators
-Set operators are used to combine the results of two queries into single result. A query including set operators is called a combined query. The number of rows in each result in a combined query must be same, and the type is determined by the first query's result, the type of the following queriess result must be able to be converted to the type of the first query's result, the conversion rule is same as `CAST` function.
+Set operators combine the results of two queries. Queries that include set operators are known as compound queries. The expressions corresponding to each query in the select list in a compound query must match in number. The results returned take the data type of the first query, and the data type returned by subsequent queries must be convertible into the data type of the first query. The conditions of the `CAST` function apply to this conversion.
-TDengine provides 2 set operators: `UNION ALL` and `UNION`. `UNION ALL` combines the results without removing duplicate data. `UNION` combines the results and remove duplicate data rows. In single SQL statement, at most 100 set operators can be used.
+TDengine supports the `UNION` and `UNION ALL` operations. UNION ALL collects all query results and returns them as a composite result without deduplication. UNION collects all query results and returns them as a deduplicated composite result. In a single SQL statement, at most 100 set operators can be supported.
-## Comparsion Operator
+## Comparison Operators
-| # | **Operator** | **Data Types** | **Description** |
-| --- | :---------------: | ------------------------------------------------------------------- | ----------------------------------------------- |
-| 1 | = | Except for BLOB, MEDIUMBLOB and JSON | Equal |
-| 2 | <\>, != | Except for BLOB, MEDIUMBLOB, JSON and primary key of timestamp type | Not equal |
-| 3 | \>, < | Except for BLOB, MEDIUMBLOB and JSON | Greater than, less than |
-| 4 | \>=, <= | Except for BLOB, MEDIUMBLOB and JSON | Greater than or equal to, less than or equal to |
-| 5 | IS [NOT] NULL | Any types | Is NULL or NOT |
-| 6 | [NOT] BETWEEN AND | Except for BLOB, MEDIUMBLOB and JSON | In a value range or not |
-| 7 | IN | Except for BLOB, MEDIUMBLOB, JSON and primary key of timestamp type | In a list of values or not |
-| 8 | LIKE | BINARY, NCHAR and VARCHAR | Wildcard matching |
-| 9 | MATCH, NMATCH | BINARY, NCHAR and VARCHAR | Regular expression matching |
-| 10 | CONTAINS | JSON | If A key exists in JSON |
+| # | **Operator** | **Supported Data Types** | **Description** |
+| --- | :---------------: | -------------------------------------------------------------------- | -------------------- |
+| 1 | = | All types except BLOB, MEDIUMBLOB, and JSON | Equal to |
+| 2 | <\>, != | All types except BLOB, MEDIUMBLOB, and JSON; the primary key (timestamp) is also not supported | Not equal to |
+| 3 | \>, < | All types except BLOB, MEDIUMBLOB, and JSON | Greater than and less than |
+| 4 | \>=, <= | All types except BLOB, MEDIUMBLOB, and JSON | Greater than or equal to and less than or equal to |
+| 5 | IS [NOT] NULL | All types | Indicates whether the value is null |
+| 6 | [NOT] BETWEEN AND | All types except BLOB, MEDIUMBLOB, and JSON | Closed interval comparison |
+| 7 | IN | All types except BLOB, MEDIUMBLOB, and JSON; the primary key (timestamp) is also not supported | Equal to any value in the list |
+| 8 | LIKE | BINARY, NCHAR, and VARCHAR | Wildcard match |
+| 9 | MATCH, NMATCH | BINARY, NCHAR, and VARCHAR | Regular expression match |
+| 10 | CONTAINS | JSON | Indicates whether the key exists |
-`LIKE` operator uses wildcard to match a string, the rules are:
+LIKE is used together with wildcards to match strings. Its usage is described as follows:
-- '%' matches 0 to any number of characters; '\_' matches any single ASCII character.
-- \_ can be used to match a `_` in the string, i.e. using escape character backslash `\`
-- Wildcard string is 100 bytes at most. Longer a wildcard string is, worse the performance of LIKE operator is.
+- '%' matches 0 or any number of characters, '\_' matches any single ASCII character.
+- `\_` is used to match the \_ in the string.
+- The maximum length of wildcard string is 100 bytes. A very long wildcard string may slowdown the execution performance of `LIKE` operator.
-`MATCH` and `NMATCH` operators use regular expressions to match a string, the rules are:
+MATCH and NMATCH are used together with regular expressions to match strings. Their usage is described as follows:
-- Regular expressions of POSIX standard are supported.
-- Only `tbname`, i.e. table name of sub tables, and tag columns of string types can be matched with regular expression, data columns are not supported.
-- Regular expression string is 128 bytes at most, and can be adjusted by setting parameter `maxRegexStringLen`, which is a client side configuration and needs to restart the client to take effect.
+- Use POSIX regular expression syntax. For more information, see Regular Expressions.
+- Regular expression can be used against only table names, i.e. `tbname`, and tags of binary/nchar types, but can't be used against data columns.
+- The maximum length of regular expression string is 128 bytes. Configuration parameter `maxRegexStringLen` can be used to set the maximum allowed regular expression. It's a configuration parameter on the client side, and will take effect after restarting the client.
## Logical Operators
-| # | **Operator** | **Data Types** | **Description** |
-| --- | :----------: | -------------- | ---------------------------------------------------------------------------------------- |
-| 1 | AND | BOOL | Logical AND, return TRUE if both conditions are TRUE; return FALSE if any one is FALSE. |
-| 2 | OR | BOOL | Logical OR, return TRUE if any condition is TRUE; return FALSE if both are FALSE |
+| # | **Operator** | **Supported Data Types** | **Description** |
+| --- | :--------: | -------------- | --------------------------------------------------------------------------- |
+| 1 | AND | BOOL | Logical AND; if both conditions are true, TRUE is returned; If either condition is false, FALSE is returned.
+| 2 | OR | BOOL | Logical OR; if either condition is true, TRUE is returned; If both conditions are false, FALSE is returned.
-TDengine uses shortcircut optimization when performing logical operations. For AND operator, if the first condition is evaluated to FALSE, then the second one is not evaluated. For OR operator, if the first condition is evaluated to TRUE, then the second one is not evaluated.
+TDengine performs short-path optimization when calculating logical conditions. If the first condition for AND is false, FALSE is returned without calculating the second condition. If the first condition for OR is true, TRUE is returned without calculating the second condition
diff --git a/docs/en/12-taos-sql/17-json.md b/docs/en/12-taos-sql/17-json.md
index 7460a5e0ba3ce78ee7744569cda460c477cac19c..77f774303316b466a15226f548f84da69be8f92d 100644
--- a/docs/en/12-taos-sql/17-json.md
+++ b/docs/en/12-taos-sql/17-json.md
@@ -1,60 +1,64 @@
---
+sidebar_label: JSON Type
title: JSON Type
---
+
## Syntax
1. Tag of type JSON
- ```sql
- create STable s1 (ts timestamp, v1 int) tags (info json);
+ ```
+ create stable s1 (ts timestamp, v1 int) tags (info json)
- create table s1_1 using s1 tags ('{"k1": "v1"}');
+ create table s1_1 using s1 tags ('{"k1": "v1"}')
```
2. "->" Operator of JSON
- ```sql
- select * from s1 where info->'k1' = 'v1';
+ ```
+ select * from s1 where info->'k1' = 'v1'
- select info->'k1' from s1;
+ select info->'k1' from s1
```
3. "contains" Operator of JSON
- ```sql
- select * from s1 where info contains 'k2';
+ ```
+ select * from s1 where info contains 'k2'
- select * from s1 where info contains 'k1';
+ select * from s1 where info contains 'k1'
```
## Applicable Operations
1. When a JSON data type is used in `where`, `match/nmatch/between and/like/and/or/is null/is no null` can be used but `in` can't be used.
- ```sql
+ ```
select * from s1 where info->'k1' match 'v*';
select * from s1 where info->'k1' like 'v%' and info contains 'k2';
select * from s1 where info is null;
- select * from s1 where info->'k1' is not null;
+ select * from s1 where info->'k1' is not null
```
2. A tag of JSON type can be used in `group by`, `order by`, `join`, `union all` and sub query; for example `group by json->'key'`
3. `Distinct` can be used with a tag of type JSON
- ```sql
- select distinct info->'k1' from s1;
+ ```
+ select distinct info->'k1' from s1
```
4. Tag Operations
The value of a JSON tag can be altered. Please note that the full JSON will be overriden when doing this.
- The name of a JSON tag can be altered. A tag of JSON type can't be added or removed. The column length of a JSON tag can't be changed.
+ The name of a JSON tag can be altered.
+
+ A tag of JSON type can't be added or removed. The column length of a JSON tag can't be changed.
## Other Restrictions
@@ -64,19 +68,24 @@ title: JSON Type
- JSON format:
- - The input string for JSON can be empty, i.e. "", "\t", or NULL, but it can't be non-NULL string, bool or array.
- - object can be {}, and the entire JSON is empty if so. Key can be "", and it's ignored if so.
- - value can be int, double, string, bool or NULL, and it can't be an array. Nesting is not allowed which means that the value of a key can't be JSON.
- - If one key occurs twice in JSON, only the first one is valid.
- - Escape characters are not allowed in JSON.
+ - The input string for JSON can be empty, i.e. "", "\t", or NULL, but it can't be non-NULL string, bool or array.
+ - object can be {}, and the entire JSON is empty if so. Key can be "", and it's ignored if so.
+ - value can be int, double, string, bool or NULL, and it can't be an array. Nesting is not allowed which means that the value of a key can't be JSON.
+ - If one key occurs twice in JSON, only the first one is valid.
+ - Escape characters are not allowed in JSON.
- NULL is returned when querying a key that doesn't exist in JSON.
- If a tag of JSON is the result of inner query, it can't be parsed and queried in the outer query.
-For example, the SQL statements below are not supported.
+ For example, the SQL statements below are not supported.
-```sql;
-select jtag->'key' from (select jtag from STable);
-select jtag->'key' from (select jtag from STable) where jtag->'key'>0;
-```
+ ```
+ select jtag->'key' from (select jtag from stable)
+ ```
+
+ and
+
+ ```
+ select jtag->'key' from (select jtag from stable) where jtag->'key'>0
+ ```
diff --git a/docs/en/12-taos-sql/18-escape.md b/docs/en/12-taos-sql/18-escape.md
index 34ce9f7848a9d60811a23286a6675e8afa4f04fe..a2ae40de98be677e599e83a634952a39faeaafbf 100644
--- a/docs/en/12-taos-sql/18-escape.md
+++ b/docs/en/12-taos-sql/18-escape.md
@@ -2,7 +2,7 @@
title: Escape Characters
---
-Below table is the list of escape characters used in TDengine.
+## Escape Characters
| Escape Character | **Actual Meaning** |
| :--------------: | ------------------------ |
@@ -15,11 +15,6 @@ Below table is the list of escape characters used in TDengine.
| `\%` | % see below for details |
| `\_` | \_ see below for details |
-:::note
-Escape characters are available from version 2.4.0.4 .
-
-:::
-
## Restrictions
1. If there are escape characters in identifiers (database name, table name, column name)
diff --git a/docs/en/12-taos-sql/19-limit.md b/docs/en/12-taos-sql/19-limit.md
index ff552fc9771f5b428554acc62e9aeac03a305ecc..678c38a22ea763187cd0c87dceae3bf6ca03957c 100644
--- a/docs/en/12-taos-sql/19-limit.md
+++ b/docs/en/12-taos-sql/19-limit.md
@@ -1,59 +1,59 @@
---
-sidebar_label: 命名与边界限制
-title: 命名与边界限制
+sidebar_label: Name and Size Limits
+title: Name and Size Limits
---
-## 名称命名规则
+## Naming Rules
-1. 合法字符:英文字符、数字和下划线
-2. 允许英文字符或下划线开头,不允许以数字开头
-3. 不区分大小写
-4. 转义后表(列)名规则:
- 为了兼容支持更多形式的表(列)名,TDengine 引入新的转义符 "`"。可用让表名与关键词不冲突,同时不受限于上述表名称合法性约束检查
- 转义后的表(列)名同样受到长度限制要求,且长度计算的时候不计算转义符。使用转义字符以后,不再对转义字符中的内容进行大小写统一
+1. Names can include letters, digits, and underscores (_).
+2. Names can begin with letters or underscores (_) but not with digits.
+3. Names are not case-sensitive.
+4. Rules for names with escape characters are as follows:
+ You can escape a name by enclosing it in backticks (`). In this way, you can reuse keyword names for table names. However, the first three naming rules no longer apply.
+ Table and column names that are enclosed in escape characters are still subject to length limits. When the length of such a name is calculated, the escape characters are not included. Names specified using escape character are case-sensitive.
- 例如:\`aBc\` 和 \`abc\` 是不同的表(列)名,但是 abc 和 aBc 是相同的表(列)名。
- 需要注意的是转义字符中的内容必须是可打印字符。
+ For example, \`aBc\` and \`abc\` are different table or column names, but "abc" and "aBc" are same names because internally they are all "abc".
+ Only ASCII visible characters can be used with escape character.
-## 密码合法字符集
+## Password Rules
`[a-zA-Z0-9!?$%^&*()_–+={[}]:;@~#|<,>.?/]`
-去掉了 `` ‘“`\ `` (单双引号、撇号、反斜杠、空格)
+The following characters cannot occur in a password: single quotation marks ('), double quotation marks ("), backticks (`), backslashes (\\), and spaces.
-## 一般限制
+## General Limits
-- 数据库名最大长度为 32
-- 表名最大长度为 192,不包括数据库名前缀和分隔符
-- 每行数据最大长度 48KB (注意:数据行内每个 BINARY/NCHAR 类型的列还会额外占用 2 个字节的存储位置)
-- 列名最大长度为 64
-- 最多允许 4096 列,最少需要 2 列,第一列必须是时间戳。
-- 标签名最大长度为 64
-- 最多允许 128 个,至少要有 1 个标签,一个表中标签值的总长度不超过 16KB
-- SQL 语句最大长度 1048576 个字符,也可通过客户端配置参数 maxSQLLength 修改,取值范围 65480 ~ 1048576
-- SELECT 语句的查询结果,最多允许返回 4096 列(语句中的函数调用可能也会占用一些列空间),超限时需要显式指定较少的返回数据列,以避免语句执行报错
-- 库的数目,超级表的数目、表的数目,系统不做限制,仅受系统资源限制
-- 数据库的副本数只能设置为 1 或 3
-- 用户名的最大长度是 23 个字节
-- 用户密码的最大长度是 15 个字节
-- 总数据行数取决于可用资源
-- 单个数据库的虚拟结点数上限为 1024
+- Maximum length of database name is 32 bytes
+- Maximum length of table name is 192 bytes, excluding the database name prefix and the separator.
+- Maximum length of each data row is 48K bytes. Note that the upper limit includes the extra 2 bytes consumed by each column of BINARY/NCHAR type.
+- The maximum length of a column name is 64 bytes.
+- Maximum number of columns is 4096. There must be at least 2 columns, and the first column must be timestamp.
+- The maximum length of a tag name is 64 bytes
+- Maximum number of tags is 128. There must be at least 1 tag. The total length of tag values cannot exceed 16 KB.
+- Maximum length of single SQL statement is 1 MB (1048576 bytes).
+- At most 4096 columns can be returned by `SELECT`. Functions in the query statement constitute columns. An error is returned if the limit is exceeded.
+- Maximum numbers of databases, STables, tables are dependent only on the system resources.
+- The number of replicas can only be 1 or 3.
+- The maximum length of a username is 23 bytes.
+- The maximum length of a password is 15 bytes.
+- The maximum number of rows depends on system resources.
+- The maximum number of vnodes in a database is 1024.
-## 表(列)名合法性说明
+## Restrictions of Table/Column Names
-### TDengine 中的表(列)名命名规则如下:
+### Name Restrictions of Table/Column
-只能由字母、数字、下划线构成,数字不能在首位,长度不能超过 192 字节,不区分大小写。这里表名称不包括数据库名的前缀和分隔符。
+The name of a table or column can only be composed of ASCII characters, digits and underscore and it cannot start with a digit. The maximum length is 192 bytes. Names are case insensitive. The name mentioned in this rule doesn't include the database name prefix and the separator.
-### 转义后表(列)名规则:
+### Name Restrictions After Escaping
-为了兼容支持更多形式的表(列)名,TDengine 引入新的转义符 "`",可以避免表名与关键词的冲突,同时不受限于上述表名合法性约束检查,转义符不计入表名的长度。
-转义后的表(列)名同样受到长度限制要求,且长度计算的时候不计算转义符。使用转义字符以后,不再对转义字符中的内容进行大小写统一。
+To support more flexible table or column names, new escape character "\`" is introduced in TDengine to avoid the conflict between table name and keywords and break the above restrictions for table names. The escape character is not counted in the length of table name.
+With escaping, the string inside escape characters are case sensitive, i.e. will not be converted to lower case internally. The table names specified using escape character are case sensitive.
-例如:
-\`aBc\` 和 \`abc\` 是不同的表(列)名,但是 abc 和 aBc 是相同的表(列)名。
+For example:
+\`aBc\` and \`abc\` are different table or column names, but "abc" and "aBc" are same names because internally they are all "abc".
:::note
-转义字符中的内容必须是可打印字符。
+The characters inside escape characters must be printable characters.
:::
diff --git a/docs/en/12-taos-sql/20-keywords.md b/docs/en/12-taos-sql/20-keywords.md
index 6d40deb5a696141cbd7bf8dd01bba6a251ef8908..6f166c8034382b0613845d18470556622106e673 100644
--- a/docs/en/12-taos-sql/20-keywords.md
+++ b/docs/en/12-taos-sql/20-keywords.md
@@ -1,10 +1,11 @@
---
-title: Keywords
+sidebar_label: Reserved Keywords
+title: Reserved Keywords
---
-There are about 200 keywords reserved by TDengine, they can't be used as the name of database, STable or table with either upper case, lower case or mixed case.
+## Keyword List
-## Keywords List
+There are about 200 keywords reserved by TDengine, they can't be used as the name of database, STable or table with either upper case, lower case or mixed case. The following list shows all reserved keywords:
### A
@@ -57,70 +58,70 @@ There are about 200 keywords reserved by TDengine, they can't be used as the nam
### D
-- DATABASE
-- DATABASES
-- DAYS
-- DBS
-- DEFERRED
+- DATABASE
+- DATABASES
+- DAYS
+- DBS
+- DEFERRED
- DELETE
- DELIMITERS
-- DESC
-- DESCRIBE
-- DETACH
-- DISTINCT
-- DIVIDE
-- DNODE
-- DNODES
-- DOT
-- DOUBLE
-- DROP
+- DESC
+- DESCRIBE
+- DETACH
+- DISTINCT
+- DIVIDE
+- DNODE
+- DNODES
+- DOT
+- DOUBLE
+- DROP
### E
-- END
-- EQ
-- EXISTS
-- EXPLAIN
+- END
+- EQ
+- EXISTS
+- EXPLAIN
### F
-- FAIL
-- FILE
-- FILL
-- FLOAT
-- FOR
-- FROM
-- FSYNC
+- FAIL
+- FILE
+- FILL
+- FLOAT
+- FOR
+- FROM
+- FSYNC
### G
-- GE
-- GLOB
+- GE
+- GLOB
- GRANTS
-- GROUP
-- GT
+- GROUP
+- GT
### H
-- HAVING
+- HAVING
### I
- ID
- IF
-- IGNORE
+- IGNORE
- IMMEDIA
-- IMPORT
-- IN
+- IMPORT
+- IN
- INITIAL
-- INSERT
+- INSERT
- INSTEAD
-- INT
+- INT
- INTEGER
- INTERVA
-- INTO
-- IS
-- ISNULL
+- INTO
+- IS
+- ISNULL
### J
@@ -129,187 +130,147 @@ There are about 200 keywords reserved by TDengine, they can't be used as the nam
### K
- KEEP
-- KEY
+- KEY
- KILL
### L
-- LE
-- LIKE
-- LIMIT
+- LE
+- LIKE
+- LIMIT
- LINEAR
-- LOCAL
-- LP
+- LOCAL
+- LP
- LSHIFT
-- LT
+- LT
### M
-- MATCH
-- MAXROWS
-- MINROWS
-- MINUS
-- MNODES
-- MODIFY
-- MODULES
+- MATCH
+- MAXROWS
+- MINROWS
+- MINUS
+- MNODES
+- MODIFY
+- MODULES
### N
-- NE
-- NONE
-- NOT
+- NE
+- NONE
+- NOT
- NOTNULL
-- NOW
+- NOW
- NULL
### O
-- OF
+- OF
- OFFSET
-- OR
-- ORDER
+- OR
+- ORDER
### P
- PARTITION
-- PASS
-- PLUS
-- PPS
+- PASS
+- PLUS
+- PPS
- PRECISION
-- PREV
+- PREV
- PRIVILEGE
### Q
-- QTIME
+- QTIME
- QUERIE
-- QUERY
+- QUERY
- QUORUM
### R
-- RAISE
-- REM
+- RAISE
+- REM
- REPLACE
- REPLICA
-- RESET
+- RESET
- RESTRIC
-- ROW
-- RP
+- ROW
+- RP
- RSHIFT
### S
-- SCORES
-- SELECT
-- SEMI
+- SCORES
+- SELECT
+- SEMI
- SESSION
-- SET
-- SHOW
-- SLASH
+- SET
+- SHOW
+- SLASH
- SLIDING
-- SLIMIT
+- SLIMIT
- SMALLIN
- SOFFSET
-- STable
+- STable
- STableS
-- STAR
-- STATE
+- STAR
+- STATE
- STATEMEN
- STATE_WI
-- STORAGE
-- STREAM
-- STREAMS
-- STRING
-- SYNCDB
+- STORAGE
+- STREAM
+- STREAMS
+- STRING
+- SYNCDB
### T
-- TABLE
-- TABLES
-- TAG
-- TAGS
-- TBNAME
-- TIMES
-- TIMESTAMP
-- TINYINT
-- TOPIC
-- TOPICS
-- TRIGGER
-- TSERIES
+- TABLE
+- TABLES
+- TAG
+- TAGS
+- TBNAME
+- TIMES
+- TIMESTAMP
+- TINYINT
+- TOPIC
+- TOPICS
+- TRIGGER
+- TSERIES
### U
-- UMINUS
-- UNION
-- UNSIGNED
-- UPDATE
-- UPLUS
-- USE
-- USER
-- USERS
-- USING
+- UMINUS
+- UNION
+- UNSIGNED
+- UPDATE
+- UPLUS
+- USE
+- USER
+- USERS
+- USING
### V
-- VALUES
-- VARIABLE
+- VALUES
+- VARIABLE
- VARIABLES
-- VGROUPS
-- VIEW
-- VNODES
+- VGROUPS
+- VIEW
+- VNODES
### W
- WAL
- WHERE
-### _
-
-- _C0
-- _QSTART
-- _QSTOP
-- _QDURATION
-- _WSTART
-- _WSTOP
-- _WDURATION
-
-## Explanations
-### TBNAME
-`TBNAME` can be considered as a special tag, which represents the name of the subtable, in a STable.
-
-Get the table name and tag values of all subtables in a STable.
-```mysql
-SELECT TBNAME, location FROM meters;
-```
-
-Count the number of subtables in a STable.
-```mysql
-SELECT COUNT(TBNAME) FROM meters;
-```
-
-Only filter on TAGS can be used in WHERE clause in the above two query statements.
-```mysql
-taos> SELECT TBNAME, location FROM meters;
- tbname | location |
-==================================================================
- d1004 | California.SanFrancisco |
- d1003 | California.SanFrancisco |
- d1002 | California.LosAngeles |
- d1001 | California.LosAngeles |
-Query OK, 4 row(s) in set (0.000881s)
-
-taos> SELECT COUNT(tbname) FROM meters WHERE groupId > 2;
- count(tbname) |
-========================
- 2 |
-Query OK, 1 row(s) in set (0.001091s)
-```
-### _QSTART/_QSTOP/_QDURATION
-The start, stop and duration of a query time window.
-
-### _WSTART/_WSTOP/_WDURATION
-The start, stop and duration of aggegate query by time window, like interval, session window, state window.
-
-### _c0/_ROWTS
-_c0 is equal to _ROWTS, it means the first column of a table or STable.
+### \_
+
+- \_C0
+- \_QSTART
+- \_QSTOP
+- \_QDURATION
+- \_WSTART
+- \_WSTOP
+- \_WDURATION
diff --git a/docs/en/12-taos-sql/21-node.md b/docs/en/12-taos-sql/21-node.md
index 4816daf42042c0607aebf37c8b57961e5b1927fe..8bb895f73cd26edd1ec2ddabf08b842ceecf76fe 100644
--- a/docs/en/12-taos-sql/21-node.md
+++ b/docs/en/12-taos-sql/21-node.md
@@ -1,37 +1,37 @@
---
-sidebar_label: 集群管理
-title: 集群管理
+sidebar_label: Cluster
+title: Cluster
---
-组成 TDengine 集群的物理实体是 dnode (data node 的缩写),它是一个运行在操作系统之上的进程。在 dnode 中可以建立负责时序数据存储的 vnode (virtual node),在多节点集群环境下当某个数据库的 replica 为 3 时,该数据库中的每个 vgroup 由 3 个 vnode 组成;当数据库的 replica 为 1 时,该数据库中的每个 vgroup 由 1 个 vnode 组成。如果要想配置某个数据库为多副本,则集群中的 dnode 数量至少为 3。在 dnode 还可以创建 mnode (management node),单个集群中最多可以创建三个 mnode。在 TDengine 3.0.0.0 中为了支持存算分离,引入了一种新的逻辑节点 qnode (query node),qnode 和 vnode 既可以共存在一个 dnode 中,也可以完全分离在不同的 dnode 上。
+The physical entities that form TDengine clusters are known as data nodes (dnodes). Each dnode is a process running on the operating system of the physical machine. Dnodes can contain virtual nodes (vnodes), which store time-series data. Virtual nodes are formed into vgroups, which have 1 or 3 vnodes depending on the replica setting. If you want to enable replication on your cluster, it must contain at least three nodes. Dnodes can also contain management nodes (mnodes). Each cluster has up to three mnodes. Finally, dnodes can contain query nodes (qnodes), which compute time-series data, thus separating compute from storage. A single dnode can contain a vnode, qnode, and mnode.
-## 创建数据节点
+## Create a Dnode
```sql
CREATE DNODE {dnode_endpoint | dnode_host_name PORT port_val}
```
-其中 `dnode_endpoint` 是形成 `hostname:port`的格式。也可以分开指定 hostname 和 port。
+Enter the dnode_endpoint in hostname:port format. You can also specify the hostname and port as separate parameters.
-实际操作中推荐先创建 dnode,再启动相应的 dnode 进程,这样该 dnode 就可以立即根据其配置文件中的 firstEP 加入集群。每个 dnode 在加入成功后都会被分配一个 ID。
+Create the dnode before starting the corresponding dnode process. The dnode can then join the cluster based on the value of the firstEp parameter. Each dnode is assigned an ID after it joins a cluster.
-## 查看数据节点
+## View Dnodes
```sql
SHOW DNODES;
```
-可以列出集群中所有的数据节点,所列出的字段有 dnode 的 ID, endpoint, status。
+The preceding SQL command shows all dnodes in the cluster with the ID, endpoint, and status.
-## 删除数据节点
+## Delete a DNODE
```sql
DROP DNODE {dnode_id | dnode_endpoint}
```
-可以用 dnoe_id 或 endpoint 两种方式从集群中删除一个 dnode。注意删除 dnode 不等于停止相应的进程。实际中推荐先将一个 dnode 删除之后再停止其所对应的进程。
+You can delete a dnode by its ID or by its endpoint. Note that deleting a dnode does not stop its process. You must stop the process after the dnode is deleted.
-## 修改数据节点配置
+## Modify Dnode Configuration
```sql
ALTER DNODE dnode_id dnode_option
@@ -62,59 +62,59 @@ dnode_option: {
}
```
-上面语法中的这些可修改配置项其配置方式与 dnode 配置文件中的配置方式相同,区别是修改是动态的立即生效,且不需要重启 dnode。
+The parameters that you can modify through this statement are the same as those located in the dnode configuration file. Modifications that you make through this statement take effect immediately, while modifications to the configuration file take effect when the dnode restarts.
-## 添加管理节点
+## Add an Mnode
```sql
CREATE MNODE ON DNODE dnode_id
```
-系统启动默认在 firstEP 节点上创建一个 MNODE,用户可以使用此语句创建更多的 MNODE 来提高系统可用性。一个集群最多存在三个 MNODE,一个 DNODE 上只能创建一个 MNODE。
+TDengine automatically creates an mnode on the firstEp node. You can use this statement to create more mnodes for higher system availability. A cluster can have a maximum of three mnodes. Each dnode can contain only one mnode.
-## 查看管理节点
+## View Mnodes
```sql
SHOW MNODES;
```
-列出集群中所有的管理节点,包括其 ID,所在 DNODE 以及状态。
+This statement shows all mnodes in the cluster with the ID, dnode, and status.
-## 删除管理节点
+## Delete an Mnode
```sql
DROP MNODE ON DNODE dnode_id;
```
-删除 dnode_id 所指定的 DNODE 上的 MNODE。
+This statement deletes the mnode located on the specified dnode.
-## 创建查询节点
+## Create a Qnode
```sql
CREATE QNODE ON DNODE dnode_id;
```
-系统启动默认没有 QNODE,用户可以创建 QNODE 来实现计算和存储的分离。一个 DNODE 上只能创建一个 QNODE。一个 DNODE 的 `supportVnodes` 参数如果不为 0,同时又在其上创建上 QNODE,则在该 dnode 中既有负责存储管理的 vnode 又有负责查询计算的 qnode,如果还在该 dnode 上创建了 mnode,则一个 dnode 上最多三种逻辑节点都可以存在。但通过配置也可以使其彻底分离。将一个 dnode 的`supportVnodes`配置为 0,可以选择在其上创建 mnode 或者 qnode 中的一种,这样可以实现三种逻辑节点在物理上的彻底分离。
+TDengine does not automatically create qnodes on startup. You can create qnodes as necessary for compute/storage separation. Each dnode can contain only one qnode. If a qnode is created on a dnode whose supportVnodes parameter is not 0, a vnode and qnode may coexist on the dnode. Each dnode can have a maximum of one vnode, one qnode, and one mnode. However, you can configure your cluster so that vnodes, qnodes, and mnodes are located on separate dnodes. If you set supportVnodes to 0 for a dnode, you can then decide whether to deploy an mnode or a qnode on it. In this way you can physically separate virtual node types.
-## 查看查询节点
+## View Qnodes
```sql
SHOW QNODES;
```
-列出集群中所有查询节点,包括 ID,及所在 DNODE。
+This statement shows all qnodes in the cluster with the ID and dnode.
-## 删除查询节点
+## Delete a Qnode
```sql
DROP QNODE ON DNODE dnode_id;
```
-删除 ID 为 dnode_id 的 DNODE 上的 QNODE,但并不会影响该 dnode 的状态。
+This statement deletes the mnode located on the specified dnode. This does not affect the status of the dnode.
-## 修改客户端配置
+## Modify Client Configuration
-如果将客户端也看作广义的集群的一部分,可以通过如下命令动态修改客户端配置参数。
+The client configuration can also be modified in a similar way to other cluster components.
```sql
ALTER LOCAL local_option
@@ -129,26 +129,26 @@ local_option: {
}
```
-上面语法中的参数与在配置文件中配置客户端的用法相同,但不需要重启客户端,修改后立即生效。
+The parameters that you can modify through this statement are the same as those located in the client configuration file. Modifications that you make through this statement take effect immediately, while modifications to the configuration file take effect when the client restarts.
-## 查看客户端配置
+## View Client Configuration
```sql
SHOW LOCAL VARIABLES;
```
-## 合并 vgroup
+## Combine Vgroups
```sql
MERGE VGROUP vgroup_no1 vgroup_no2;
```
-如果在系统实际运行一段时间后,因为不同时间线的数据特征不同导致在 vgroups 之间的数据和负载分布不均衡,可以通过合并或拆分 vgroups 的方式逐步实现负载均衡。
+If load and data are not properly balanced among vgroups due to the data in different tim lines having different characteristics, you can combine or separate vgroups.
-## 拆分 vgroup
+## Separate Vgroups
```sql
SPLIT VGROUP vgroup_no;
```
-会创建一个新的 vgroup,并将指定 vgroup 中的数据按照一致性 HASH 迁移一部分到新的 vgroup 中。此过程中,原 vgroup 可以正常提供读写服务。
+This statement creates a new vgroup and migrates part of the data from the original vgroup to the new vgroup with consistent hashing. During this process, the original vgroup can continue to provide services normally.
diff --git a/docs/en/12-taos-sql/22-meta.md b/docs/en/12-taos-sql/22-meta.md
index 1e178706859a3e5fa5dbabc00777b92639d76617..9bda5a0a1027243ea5f50c55e303fdb7155c853b 100644
--- a/docs/en/12-taos-sql/22-meta.md
+++ b/docs/en/12-taos-sql/22-meta.md
@@ -1,247 +1,279 @@
---
-sidebar_label: 元数据库
-title: 元数据库
+sidebar_label: Metadata
+title: Information_Schema Database
---
-TDengine 内置了一个名为 `INFORMATION_SCHEMA` 的数据库,提供对数据库元数据、数据库系统信息和状态的访问,例如数据库或表的名称,当前执行的 SQL 语句等。该数据库存储有关 TDengine 维护的所有其他数据库的信息。它包含多个只读表。实际上,这些表都是视图,而不是基表,因此没有与它们关联的文件。所以对这些表只能查询,不能进行 INSERT 等写入操作。`INFORMATION_SCHEMA` 数据库旨在以一种更一致的方式来提供对 TDengine 支持的各种 SHOW 语句(如 SHOW TABLES、SHOW DATABASES)所提供的信息的访问。与 SHOW 语句相比,使用 SELECT ... FROM INFORMATION_SCHEMA.tablename 具有以下优点:
+TDengine includes a built-in database named `INFORMATION_SCHEMA` to provide access to database metadata, system information, and status information. This information includes database names, table names, and currently running SQL statements. All information related to TDengine maintenance is stored in this database. It contains several read-only tables. These tables are more accurately described as views, and they do not correspond to specific files. You can query these tables but cannot write data to them. The INFORMATION_SCHEMA database is intended to provide a unified method for SHOW commands to access data. However, using SELECT ... FROM INFORMATION_SCHEMA.tablename offers several advantages over SHOW commands:
-1. 可以使用 USE 语句将 INFORMATION_SCHEMA 设为默认数据库
-2. 可以使用 SELECT 语句熟悉的语法,只需要学习一些表名和列名
-3. 可以对查询结果进行筛选、排序等操作。事实上,可以使用任意 TDengine 支持的 SELECT 语句对 INFORMATION_SCHEMA 中的表进行查询
-4. TDengine 在后续演进中可以灵活的添加已有 INFORMATION_SCHEMA 中表的列,而不用担心对既有业务系统造成影响
-5. 与其他数据库系统更具互操作性。例如,Oracle 数据库用户熟悉查询 Oracle 数据字典中的表
+1. You can use a USE statement to specify the INFORMATION_SCHEMA database as the current database.
+2. You can use the familiar SELECT syntax to access information, provided that you know the table and column names.
+3. You can filter and order the query results. More generally, you can use any SELECT syntax that TDengine supports to query the INFORMATION_SCHEMA database.
+4. Future versions of TDengine can add new columns to INFORMATION_SCHEMA tables without affecting existing business systems.
+5. It is easier for users coming from other database management systems. For example, Oracle users can query data dictionary tables.
-Note: 由于 SHOW 语句已经被开发者熟悉和广泛使用,所以它们仍然被保留。
+Note: SHOW statements are still supported for the convenience of existing users.
-本章将详细介绍 `INFORMATION_SCHEMA` 这个内置元数据库中的表和表结构。
+This document introduces the tables of INFORMATION_SCHEMA and their structure.
## INS_DNODES
-提供 dnode 的相关信息。也可以使用 SHOW DNODES 来查询这些信息。
+Provides information about dnodes. Similar to SHOW DNODES.
-| # | **列名** | **数据类型** | **说明** |
+| # | **Column** | **Data Type** | **Description** |
| --- | :------------: | ------------ | ------------------------- |
-| 1 | vnodes | SMALLINT | dnode 中的实际 vnode 个数 |
-| 2 | support_vnodes | SMALLINT | 最多支持的 vnode 个数 |
-| 3 | status | BINARY(10) | 当前状态 |
-| 4 | note | BINARY(256) | 离线原因等信息 |
-| 5 | id | SMALLINT | dnode id |
-| 6 | endpoint | BINARY(134) | dnode 的地址 |
-| 7 | create | TIMESTAMP | 创建时间 |
+| 1 | vnodes | SMALLINT | Current number of vnodes on the dnode |
+| 2 | vnodes | SMALLINT | Maximum number of vnodes on the dnode |
+| 3 | status | BINARY(10) | Current status |
+| 4 | note | BINARY(256) | Reason for going offline or other information |
+| 5 | id | SMALLINT | Dnode ID |
+| 6 | endpoint | BINARY(134) | Dnode endpoint |
+| 7 | create | TIMESTAMP | Creation time |
## INS_MNODES
-提供 mnode 的相关信息。也可以使用 SHOW MNODES 来查询这些信息。
+Provides information about mnodes. Similar to SHOW MNODES.
-| # | **列名** | **数据类型** | **说明** |
+| # | **Column** | **Data Type** | **Description** |
| --- | :---------: | ------------ | ------------------ |
-| 1 | id | SMALLINT | mnode id |
-| 2 | endpoint | BINARY(134) | mnode 的地址 |
-| 3 | role | BINARY(10) | 当前角色 |
-| 4 | role_time | TIMESTAMP | 成为当前角色的时间 |
-| 5 | create_time | TIMESTAMP | 创建时间 |
+| 1 | id | SMALLINT | Mnode ID |
+| 2 | endpoint | BINARY(134) | Mnode endpoint |
+| 3 | role | BINARY(10) | Current role |
+| 4 | role_time | TIMESTAMP | Time at which the current role was assumed |
+| 5 | create_time | TIMESTAMP | Creation time |
## INS_MODULES
-提供组件的相关信息。也可以使用 SHOW MODULES 来查询这些信息
+Provides information about modules. Similar to SHOW MODULES.
-| # | **列名** | **数据类型** | **说明** |
+| # | **Column** | **Data Type** | **Description** |
| --- | :------: | ------------ | ---------- |
-| 1 | id | SMALLINT | module id |
-| 2 | endpoint | BINARY(134) | 组件的地址 |
-| 3 | module | BINARY(10) | 组件状态 |
+| 1 | id | SMALLINT | Module ID |
+| 2 | endpoint | BINARY(134) | Module endpoint |
+| 3 | module | BINARY(10) | Module status |
## INS_QNODES
-当前系统中 QNODE 的信息。也可以使用 SHOW QNODES 来查询这些信息。
+Provides information about qnodes. Similar to SHOW QNODES.
-| # | **列名** | **数据类型** | **说明** |
+| # | **Column** | **Data Type** | **Description** |
| --- | :---------: | ------------ | ------------ |
-| 1 | id | SMALLINT | qnode id |
-| 2 | endpoint | BINARY(134) | qnode 的地址 |
-| 3 | create_time | TIMESTAMP | 创建时间 |
+| 1 | id | SMALLINT | Qnode ID |
+| 2 | endpoint | BINARY(134) | Qnode endpoint |
+| 3 | create_time | TIMESTAMP | Creation time |
## INS_CLUSTER
-存储集群相关信息。
+Provides information about the cluster.
-| # | **列名** | **数据类型** | **说明** |
+| # | **Column** | **Data Type** | **Description** |
| --- | :---------: | ------------ | ---------- |
-| 1 | id | BIGINT | cluster id |
-| 2 | name | BINARY(134) | 集群名称 |
-| 3 | create_time | TIMESTAMP | 创建时间 |
+| 1 | id | BIGINT | Cluster ID |
+| 2 | name | BINARY(134) | Cluster name |
+| 3 | create_time | TIMESTAMP | Creation time |
## INS_DATABASES
-提供用户创建的数据库对象的相关信息。也可以使用 SHOW DATABASES 来查询这些信息。
+Provides information about user-created databases. Similar to SHOW DATABASES.
-| # | **列名** | **数据类型** | **说明** |
+| # | **Column** | **Data Type** | **Description** |
| --- | :------------------: | ---------------- | ------------------------------------------------ |
-| 1 | name | BINARY(32) | 数据库名 |
-| 2 | create_time | TIMESTAMP | 创建时间 |
-| 3 | ntables | INT | 数据库中表的数量,包含子表和普通表但不包含超级表 |
-| 4 | vgroups | INT | 数据库中有多少个 vgroup |
-| 6 | replica | INT | 副本数 |
-| 7 | quorum | BINARY(3) | 强一致性 |
-| 8 | duration | INT | 单文件存储数据的时间跨度 |
-| 9 | keep | INT | 数据保留时长 |
-| 10 | buffer | INT | 每个 vnode 写缓存的内存块大小,单位 MB |
-| 11 | pagesize | INT | 每个 VNODE 中元数据存储引擎的页大小,单位为 KB |
-| 12 | pages | INT | 每个 vnode 元数据存储引擎的缓存页个数 |
-| 13 | minrows | INT | 文件块中记录的最大条数 |
-| 14 | maxrows | INT | 文件块中记录的最小条数 |
-| 15 | comp | INT | 数据压缩方式 |
-| 16 | precision | BINARY(2) | 时间分辨率 |
-| 17 | status | BINARY(10) | 数据库状态 |
-| 18 | retention | BINARY (60) | 数据的聚合周期和保存时长 |
-| 19 | single_stable | BOOL | 表示此数据库中是否只可以创建一个超级表 |
-| 20 | cachemodel | BINARY(60) | 表示是否在内存中缓存子表的最近数据 |
-| 21 | cachesize | INT | 表示每个 vnode 中用于缓存子表最近数据的内存大小 |
-| 22 | wal_level | INT | WAL 级别 |
-| 23 | wal_fsync_period | INT | 数据落盘周期 |
-| 24 | wal_retention_period | INT | WAL 的保存时长 |
-| 25 | wal_retention_size | INT | WAL 的保存上限 |
-| 26 | wal_roll_period | INT | wal 文件切换时长 |
-| 27 | wal_segment_size | wal 单个文件大小 |
+| 1| name| BINARY(32)| Database name |
+| 2 | create_time | TIMESTAMP | Creation time |
+| 3 | ntables | INT | Number of standard tables and subtables (not including supertables) |
+| 4 | vgroups | INT | Number of vgroups |
+| 6 | replica | INT | Number of replicas |
+| 7 | quorum | BINARY(3) | Strong consistency |
+| 8 | duration | INT | Duration for storage of single files |
+| 9 | keep | INT | Data retention period |
+| 10 | buffer | INT | Write cache size per vnode, in MB |
+| 11 | pagesize | INT | Page size for vnode metadata storage engine, in KB |
+| 12 | pages | INT | Number of pages per vnode metadata storage engine |
+| 13 | minrows | INT | Maximum number of records per file block |
+| 14 | maxrows | INT | Minimum number of records per file block |
+| 15 | comp | INT | Compression method |
+| 16 | precision | BINARY(2) | Time precision |
+| 17 | status | BINARY(10) | Current database status |
+| 18 | retention | BINARY (60) | Aggregation interval and retention period |
+| 19 | single_stable | BOOL | Whether the database can contain multiple supertables |
+| 20 | cachemodel | BINARY(60) | Caching method for the newest data |
+| 21 | cachesize | INT | Memory per vnode used for caching the newest data |
+| 22 | wal_level | INT | WAL level |
+| 23 | wal_fsync_period | INT | Interval at which WAL is written to disk |
+| 24 | wal_retention_period | INT | WAL retention period |
+| 25 | wal_retention_size | INT | Maximum WAL size |
+| 26 | wal_roll_period | INT | WAL rotation period |
+| 27 | wal_segment_size | WAL file size |
## INS_FUNCTIONS
-用户创建的自定义函数的信息。
+Provides information about user-defined functions.
-| # | **列名** | **数据类型** | **说明** |
+| # | **Column** | **Data Type** | **Description** |
| --- | :---------: | ------------ | -------------- |
-| 1 | name | BINARY(64) | 函数名 |
-| 2 | comment | BINARY(255) | 补充说明 |
-| 3 | aggregate | INT | 是否为聚合函数 |
-| 4 | output_type | BINARY(31) | 输出类型 |
-| 5 | create_time | TIMESTAMP | 创建时间 |
-| 6 | code_len | INT | 代码长度 |
-| 7 | bufsize | INT | buffer 大小 |
+| 1 | name | BINARY(64) | Function name |
+| 2 | comment | BINARY(255) | Function description |
+| 3 | aggregate | INT | Whether the UDF is an aggregate function |
+| 4 | output_type | BINARY(31) | Output data type |
+| 5 | create_time | TIMESTAMP | Creation time |
+| 6 | code_len | INT | Length of the source code |
+| 7 | bufsize | INT | Buffer size |
## INS_INDEXES
-提供用户创建的索引的相关信息。也可以使用 SHOW INDEX 来查询这些信息。
+Provides information about user-created indices. Similar to SHOW INDEX.
-| # | **列名** | **数据类型** | **说明** |
+| # | **Column** | **Data Type** | **Description** |
| --- | :--------------: | ------------ | ---------------------------------------------------------------------------------- |
-| 1 | db_name | BINARY(32) | 包含此索引的表所在的数据库名 |
-| 2 | table_name | BINARY(192) | 包含此索引的表的名称 |
-| 3 | index_name | BINARY(192) | 索引名 |
-| 4 | column_name | BINARY(64) | 建索引的列的列名 |
-| 5 | index_type | BINARY(10) | 目前有 SMA 和 FULLTEXT |
-| 6 | index_extensions | BINARY(256) | 索引的额外信息。对 SMA 类型的索引,是函数名的列表。对 FULLTEXT 类型的索引为 NULL。 |
+| 1 | db_name | BINARY(32) | Database containing the table with the specified index |
+| 2 | table_name | BINARY(192) | Table containing the specified index |
+| 3 | index_name | BINARY(192) | Index name |
+| 4 | db_name | BINARY(64) | Index column |
+| 5 | index_type | BINARY(10) | SMA or FULLTEXT index |
+| 6 | index_extensions | BINARY(256) | Other information For SMA indices, this shows a list of functions. For FULLTEXT indices, this is null. |
## INS_STABLES
-提供用户创建的超级表的相关信息。
+Provides information about supertables.
-| # | **列名** | **数据类型** | **说明** |
+| # | **Column** | **Data Type** | **Description** |
| --- | :-----------: | ------------ | ------------------------ |
-| 1 | stable_name | BINARY(192) | 超级表表名 |
-| 2 | db_name | BINARY(64) | 超级表所在的数据库的名称 |
-| 3 | create_time | TIMESTAMP | 创建时间 |
-| 4 | columns | INT | 列数目 |
-| 5 | tags | INT | 标签数目 |
-| 6 | last_update | TIMESTAMP | 最后更新时间 |
-| 7 | table_comment | BINARY(1024) | 表注释 |
-| 8 | watermark | BINARY(64) | 窗口的关闭时间 |
-| 9 | max_delay | BINARY(64) | 推送计算结果的最大延迟 |
-| 10 | rollup | BINARY(128) | rollup 聚合函数 |
+| 1 | stable_name | BINARY(192) | Supertable name |
+| 2 | db_name | BINARY(64) | All databases in the supertable |
+| 3 | create_time | TIMESTAMP | Creation time |
+| 4 | columns | INT | Number of columns |
+| 5 | tags | INT | Number of tags |
+| 6 | last_update | TIMESTAMP | Last updated time |
+| 7 | table_comment | BINARY(1024) | Table description |
+| 8 | watermark | BINARY(64) | Window closing time |
+| 9 | max_delay | BINARY(64) | Maximum delay for pushing stream processing results |
+| 10 | rollup | BINARY(128) | Rollup aggregate function |
## INS_TABLES
-提供用户创建的普通表和子表的相关信息
+Provides information about standard tables and subtables.
-| # | **列名** | **数据类型** | **说明** |
+| # | **Column** | **Data Type** | **Description** |
| --- | :-----------: | ------------ | ---------------- |
-| 1 | table_name | BINARY(192) | 表名 |
-| 2 | db_name | BINARY(64) | 数据库名 |
-| 3 | create_time | TIMESTAMP | 创建时间 |
-| 4 | columns | INT | 列数目 |
-| 5 | stable_name | BINARY(192) | 所属的超级表表名 |
-| 6 | uid | BIGINT | 表 id |
-| 7 | vgroup_id | INT | vgroup id |
-| 8 | ttl | INT | 表的生命周期 |
-| 9 | table_comment | BINARY(1024) | 表注释 |
-| 10 | type | BINARY(20) | 表类型 |
+| 1 | table_name | BINARY(192) | Table name |
+| 2 | db_name | BINARY(64) | Database name |
+| 3 | create_time | TIMESTAMP | Creation time |
+| 4 | columns | INT | Number of columns |
+| 5 | stable_name | BINARY(192) | Supertable name |
+| 6 | uid | BIGINT | Table ID |
+| 7 | vgroup_id | INT | Vgroup ID |
+| 8 | ttl | INT | Table time-to-live |
+| 9 | table_comment | BINARY(1024) | Table description |
+| 10 | type | BINARY(20) | Table type |
## INS_TAGS
-| # | **列名** | **数据类型** | **说明** |
+| # | **Column** | **Data Type** | **Description** |
| --- | :---------: | ------------- | ---------------------- |
-| 1 | table_name | BINARY(192) | 表名 |
-| 2 | db_name | BINARY(64) | 该表所在的数据库的名称 |
-| 3 | stable_name | BINARY(192) | 所属的超级表表名 |
-| 4 | tag_name | BINARY(64) | tag 的名称 |
-| 5 | tag_type | BINARY(64) | tag 的类型 |
-| 6 | tag_value | BINARY(16384) | tag 的值 |
+| 1 | table_name | BINARY(192) | Table name |
+| 2 | db_name | BINARY(64) | Database name |
+| 3 | stable_name | BINARY(192) | Supertable name |
+| 4 | tag_name | BINARY(64) | Tag name |
+| 5 | tag_type | BINARY(64) | Tag type |
+| 6 | tag_value | BINARY(16384) | Tag value |
## INS_USERS
-提供系统中创建的用户的相关信息。
+Provides information about TDengine users.
-| # | **列名** | **数据类型** | **说明** |
+| # | **Column** | **Data Type** | **Description** |
| --- | :---------: | ------------ | -------- |
-| 1 | user_name | BINARY(23) | 用户名 |
-| 2 | privilege | BINARY(256) | 权限 |
-| 3 | create_time | TIMESTAMP | 创建时间 |
+| 1 | user_name | BINARY(23) | User name |
+| 2 | privilege | BINARY(256) | User permissions |
+| 3 | create_time | TIMESTAMP | Creation time |
## INS_GRANTS
-提供企业版授权的相关信息。
+Provides information about TDengine Enterprise Edition permissions.
-| # | **列名** | **数据类型** | **说明** |
+| # | **Column** | **Data Type** | **Description** |
| --- | :---------: | ------------ | -------------------------------------------------- |
-| 1 | version | BINARY(9) | 企业版授权说明:official(官方授权的)/trial(试用的) |
-| 2 | cpu_cores | BINARY(9) | 授权使用的 CPU 核心数量 |
-| 3 | dnodes | BINARY(10) | 授权使用的 dnode 节点数量 |
-| 4 | streams | BINARY(10) | 授权创建的流数量 |
-| 5 | users | BINARY(10) | 授权创建的用户数量 |
-| 6 | accounts | BINARY(10) | 授权创建的帐户数量 |
-| 7 | storage | BINARY(21) | 授权使用的存储空间大小 |
-| 8 | connections | BINARY(21) | 授权使用的客户端连接数量 |
-| 9 | databases | BINARY(11) | 授权使用的数据库数量 |
-| 10 | speed | BINARY(9) | 授权使用的数据点每秒写入数量 |
-| 11 | querytime | BINARY(9) | 授权使用的查询总时长 |
-| 12 | timeseries | BINARY(21) | 授权使用的测点数量 |
-| 13 | expired | BINARY(5) | 是否到期,true:到期,false:未到期 |
-| 14 | expire_time | BINARY(19) | 试用期到期时间 |
+| 1 | version | BINARY(9) | Whether the deployment is a licensed or trial version |
+| 2 | cpu_cores | BINARY(9) | CPU cores included in license |
+| 3 | dnodes | BINARY(10) | Dnodes included in license |
+| 4 | streams | BINARY(10) | Streams included in license |
+| 5 | users | BINARY(10) | Users included in license |
+| 6 | streams | BINARY(10) | Accounts included in license |
+| 7 | storage | BINARY(21) | Storage space included in license |
+| 8 | connections | BINARY(21) | Client connections included in license |
+| 9 | databases | BINARY(11) | Databases included in license |
+| 10 | speed | BINARY(9) | Write speed specified in license (data points per second) |
+| 11 | querytime | BINARY(9) | Total query time specified in license |
+| 12 | timeseries | BINARY(21) | Number of metrics included in license |
+| 13 | expired | BINARY(5) | Whether the license has expired |
+| 14 | expire_time | BINARY(19) | When the trial period expires |
## INS_VGROUPS
-系统中所有 vgroups 的信息。
+Provides information about vgroups.
-| # | **列名** | **数据类型** | **说明** |
+| # | **Column** | **Data Type** | **Description** |
| --- | :-------: | ------------ | ------------------------------------------------------ |
-| 1 | vgroup_id | INT | vgroup id |
-| 2 | db_name | BINARY(32) | 数据库名 |
-| 3 | tables | INT | 此 vgroup 内有多少表 |
-| 4 | status | BINARY(10) | 此 vgroup 的状态 |
-| 5 | v1_dnode | INT | 第一个成员所在的 dnode 的 id |
-| 6 | v1_status | BINARY(10) | 第一个成员的状态 |
-| 7 | v2_dnode | INT | 第二个成员所在的 dnode 的 id |
-| 8 | v2_status | BINARY(10) | 第二个成员的状态 |
-| 9 | v3_dnode | INT | 第三个成员所在的 dnode 的 id |
-| 10 | v3_status | BINARY(10) | 第三个成员的状态 |
-| 11 | nfiles | INT | 此 vgroup 中数据/元数据文件的数量 |
-| 12 | file_size | INT | 此 vgroup 中数据/元数据文件的大小 |
-| 13 | tsma | TINYINT | 此 vgroup 是否专用于 Time-range-wise SMA,1: 是, 0: 否 |
+| 1 | vgroup_id | INT | Vgroup ID |
+| 2 | db_name | BINARY(32) | Database name |
+| 3 | tables | INT | Tables in vgroup |
+| 4 | status | BINARY(10) | Vgroup status |
+| 5 | v1_dnode | INT | Dnode ID of first vgroup member |
+| 6 | v1_status | BINARY(10) | Status of first vgroup member |
+| 7 | v2_dnode | INT | Dnode ID of second vgroup member |
+| 8 | v2_status | BINARY(10) | Status of second vgroup member |
+| 9 | v3_dnode | INT | Dnode ID of third vgroup member |
+| 10 | v3_status | BINARY(10) | Status of third vgroup member |
+| 11 | nfiles | INT | Number of data and metadata files in the vgroup |
+| 12 | file_size | INT | Size of the data and metadata files in the vgroup |
+| 13 | tsma | TINYINT | Whether time-range-wise SMA is enabled. 1 means enabled; 0 means disabled. |
## INS_CONFIGS
-系统配置参数。
+Provides system configuration information.
-| # | **列名** | **数据类型** | **说明** |
+| # | **Column** | **Data Type** | **Description** |
| --- | :------: | ------------ | ------------ |
-| 1 | name | BINARY(32) | 配置项名称 |
-| 2 | value | BINARY(64) | 该配置项的值 |
+| 1 | name | BINARY(32) | Parameter |
+| 2 | value | BINARY(64) | Value |
## INS_DNODE_VARIABLES
-系统中每个 dnode 的配置参数。
+Provides dnode configuration information.
-| # | **列名** | **数据类型** | **说明** |
+| # | **Column** | **Data Type** | **Description** |
| --- | :------: | ------------ | ------------ |
-| 1 | dnode_id | INT | dnode 的 ID |
-| 2 | name | BINARY(32) | 配置项名称 |
-| 3 | value | BINARY(64) | 该配置项的值 |
+| 1 | dnode_id | INT | Dnode ID |
+| 2 | name | BINARY(32) | Parameter |
+| 3 | value | BINARY(64) | Value |
+
+## INS_TOPICS
+
+| # | **Column** | **Data Type** | **Description** |
+| --- | :---------: | ------------ | ------------------------------ |
+| 1 | topic_name | BINARY(192) | Topic name |
+| 2 | db_name | BINARY(64) | Database for the topic |
+| 3 | create_time | TIMESTAMP | Creation time |
+| 4 | sql | BINARY(1024) | SQL statement used to create the topic |
+
+## INS_SUBSCRIPTIONS
+
+| # | **Column** | **Data Type** | **Description** |
+| --- | :------------: | ------------ | ------------------------ |
+| 1 | topic_name | BINARY(204) | Subscribed topic |
+| 2 | consumer_group | BINARY(193) | Subscribed consumer group |
+| 3 | vgroup_id | INT | Vgroup ID for the consumer |
+| 4 | consumer_id | BIGINT | Consumer ID |
+
+## INS_STREAMS
+
+| # | **Column** | **Data Type** | **Description** |
+| --- | :----------: | ------------ | --------------------------------------- |
+| 1 | stream_name | BINARY(64) | Stream name |
+| 2 | create_time | TIMESTAMP | Creation time |
+| 3 | sql | BINARY(1024) | SQL statement used to create the stream |
+| 4 | status | BIANRY(20) | Current status |
+| 5 | source_db | BINARY(64) | Source database |
+| 6 | target_db | BIANRY(64) | Target database |
+| 7 | target_table | BINARY(192) | Target table |
+| 8 | watermark | BIGINT | Watermark (see stream processing documentation) |
+| 9 | trigger | INT | Method of triggering the result push (see stream processing documentation) |
diff --git a/docs/en/12-taos-sql/23-perf.md b/docs/en/12-taos-sql/23-perf.md
new file mode 100644
index 0000000000000000000000000000000000000000..29cf3af6abfbbc06e42ae99c78f35f33a3c7c30a
--- /dev/null
+++ b/docs/en/12-taos-sql/23-perf.md
@@ -0,0 +1,97 @@
+---
+sidebar_label: Statistics
+title: Performance_Schema Database
+---
+
+TDengine includes a built-in database named `PERFORMANCE_SCHEMA` to provide access to database performance statistics. This document introduces the tables of PERFORMANCE_SCHEMA and their structure.
+
+## PERF_APP
+
+Provides information about clients (such as applications) that connect to the cluster. Similar to SHOW APPS.
+
+| # | **Column** | **Data Type** | **Description** |
+| --- | :----------: | ------------ | ------------------------------- |
+| 1 | app_id | UBIGINT | Client ID |
+| 2 | ip | BINARY(16) | Client IP address |
+| 3 | pid | INT | Client process |
+| 4 | name | BINARY(24) | Client name |
+| 5 | start_time | TIMESTAMP | Time when client was started |
+| 6 | insert_req | UBIGINT | Insert requests |
+| 7 | insert_row | UBIGINT | Rows inserted |
+| 8 | insert_time | UBIGINT | Time spent processing insert requests in microseconds |
+| 9 | insert_bytes | UBIGINT | Size of data inserted in byted |
+| 10 | fetch_bytes | UBIGINT | Size of query results in bytes |
+| 11 | query_time | UBIGINT | Time spend processing query requests |
+| 12 | slow_query | UBIGINT | Number of slow queries (greater than or equal to 3 seconds) |
+| 13 | total_req | UBIGINT | Total requests |
+| 14 | current_req | UBIGINT | Requests currently being processed |
+| 15 | last_access | TIMESTAMP | Last update time |
+
+## PERF_CONNECTIONS
+
+Provides information about connections to the database. Similar to SHOW CONNECTIONS.
+
+| # | **Column** | **Data Type** | **Description** |
+| --- | :---------: | ------------ | -------------------------------------------------- |
+| 1 | conn_id | INT | Connection ID |
+| 2 | user | BINARY(24) | User name |
+| 3 | app | BINARY(24) | Client name |
+| 4 | pid | UINT | Client process ID on client device that initiated the connection |
+| 5 | end_point | BINARY(128) | Client endpoint |
+| 6 | login_time | TIMESTAMP | Login time |
+| 7 | last_access | TIMESTAMP | Last update time |
+
+## PERF_QUERIES
+
+Provides information about SQL queries currently running. Similar to SHOW QUERIES.
+
+| # | **Column** | **Data Type** | **Description** |
+| --- | :----------: | ------------ | ---------------------------- |
+| 1 | kill_id | UBIGINT | ID used to stop the query |
+| 2 | query_id | INT | Query ID |
+| 3 | conn_id | UINT | Connection ID |
+| 4 | app | BINARY(24) | Client name |
+| 5 | pid | INT | Client process ID on client device |
+| 6 | user | BINARY(24) | User name |
+| 7 | end_point | BINARY(16) | Client endpoint |
+| 8 | create_time | TIMESTAMP | Creation time |
+| 9 | exec_usec | BIGINT | Elapsed time |
+| 10 | stable_query | BOOL | Whether the query is on a supertable |
+| 11 | sub_num | INT | Number of subqueries |
+| 12 | sub_status | BINARY(1000) | Subquery status |
+| 13 | sql | BINARY(1024) | SQL statement |
+
+## PERF_CONSUMERS
+
+| # | **Column** | **Data Type** | **Description** |
+| --- | :------------: | ------------ | ----------------------------------------------------------- |
+| 1 | consumer_id | BIGINT | Consumer ID |
+| 2 | consumer_group | BINARY(192) | Consumer group |
+| 3 | client_id | BINARY(192) | Client ID (user-defined) |
+| 4 | status | BINARY(20) | Consumer status |
+| 5 | topics | BINARY(204) | Subscribed topic. Returns one row for each topic. |
+| 6 | up_time | TIMESTAMP | Time of first connection to TDengine Server |
+| 7 | subscribe_time | TIMESTAMP | Time of first subscription |
+| 8 | rebalance_time | TIMESTAMP | Time of first rebalance triggering |
+
+## PERF_TRANS
+
+| # | **Column** | **Data Type** | **Description** |
+| --- | :--------------: | ------------ | -------------------------------------------------------------- |
+| 1 | id | INT | ID of the transaction currently running |
+| 2 | create_time | TIMESTAMP | Creation time |
+| 3 | stage | BINARY(12) | Transaction stage (redoAction, undoAction, or commit) |
+| 4 | db1 | BINARY(64) | First database having a conflict with the transaction |
+| 5 | db2 | BINARY(64) | Second database having a conflict with the transaction |
+| 6 | failed_times | INT | Times the transaction has failed |
+| 7 | last_exec_time | TIMESTAMP | Previous time the transaction was run |
+| 8 | last_action_info | BINARY(511) | Reason for failure on previous run |
+
+## PERF_SMAS
+
+| # | **Column** | **Data Type** | **Description** |
+| --- | :---------: | ------------ | ------------------------------------------- |
+| 1 | sma_name | BINARY(192) | Time-range-wise SMA name |
+| 2 | create_time | TIMESTAMP | Creation time |
+| 3 | stable_name | BINARY(192) | Supertable name |
+| 4 | vgroup_id | INT | Dedicated vgroup name |
diff --git a/docs/en/12-taos-sql/24-show.md b/docs/en/12-taos-sql/24-show.md
index 781f94324c78e7975abde33803cffdb914da020c..c9adb0cf782d1da63a8f9654f6c89b02a60a7cb7 100644
--- a/docs/en/12-taos-sql/24-show.md
+++ b/docs/en/12-taos-sql/24-show.md
@@ -1,9 +1,9 @@
---
-sidebar_label: SHOW 命令
-title: 使用 SHOW 命令查看系统元数据
+sidebar_label: SHOW Statement
+title: SHOW Statement for Metadata
---
-除了使用 `select` 语句查询 `INFORMATION_SCHEMA` 数据库中的表获得系统中的各种元数据、系统信息和状态之外,也可以用 `SHOW` 命令来实现同样的目的。
+`SHOW` command can be used to get brief system information. To get details about metatadata, information, and status in the system, please use `select` to query the tables in database `INFORMATION_SCHEMA`.
## SHOW ACCOUNTS
@@ -11,9 +11,9 @@ title: 使用 SHOW 命令查看系统元数据
SHOW ACCOUNTS;
```
-显示当前系统中所有租户的信息。
+Shows information about tenants on the system.
-注:企业版独有
+Note: TDengine Enterprise Edition only.
## SHOW APPS
@@ -21,7 +21,7 @@ SHOW ACCOUNTS;
SHOW APPS;
```
-显示接入集群的应用(客户端)信息。
+Shows all clients (such as applications) that connect to the cluster.
## SHOW BNODES
@@ -29,7 +29,7 @@ SHOW APPS;
SHOW BNODES;
```
-显示当前系统中存在的 BNODE (backup node, 即备份节点)的信息。
+Shows information about backup nodes (bnodes) in the system.
## SHOW CLUSTER
@@ -37,7 +37,7 @@ SHOW BNODES;
SHOW CLUSTER;
```
-显示当前集群的信息
+Shows information about the current cluster.
## SHOW CONNECTIONS
@@ -45,7 +45,7 @@ SHOW CLUSTER;
SHOW CONNECTIONS;
```
-显示当前系统中存在的连接的信息。
+Shows information about connections to the system.
## SHOW CONSUMERS
@@ -53,7 +53,7 @@ SHOW CONNECTIONS;
SHOW CONSUMERS;
```
-显示当前数据库下所有活跃的消费者的信息。
+Shows information about all active consumers in the system.
## SHOW CREATE DATABASE
@@ -61,7 +61,7 @@ SHOW CONSUMERS;
SHOW CREATE DATABASE db_name;
```
-显示 db_name 指定的数据库的创建语句。
+Shows the SQL statement used to create the specified database.
## SHOW CREATE STABLE
@@ -69,7 +69,7 @@ SHOW CREATE DATABASE db_name;
SHOW CREATE STABLE [db_name.]stb_name;
```
-显示 tb_name 指定的超级表的创建语句
+Shows the SQL statement used to create the specified supertable.
## SHOW CREATE TABLE
@@ -77,7 +77,7 @@ SHOW CREATE STABLE [db_name.]stb_name;
SHOW CREATE TABLE [db_name.]tb_name
```
-显示 tb_name 指定的表的创建语句。支持普通表、超级表和子表。
+Shows the SQL statement used to create the specified table. This statement can be used on supertables, standard tables, and subtables.
## SHOW DATABASES
@@ -85,7 +85,7 @@ SHOW CREATE TABLE [db_name.]tb_name
SHOW DATABASES;
```
-显示用户定义的所有数据库。
+Shows all user-created databases.
## SHOW DNODES
@@ -93,7 +93,7 @@ SHOW DATABASES;
SHOW DNODES;
```
-显示当前系统中 DNODE 的信息。
+Shows all dnodes in the system.
## SHOW FUNCTIONS
@@ -101,7 +101,7 @@ SHOW DNODES;
SHOW FUNCTIONS;
```
-显示用户定义的自定义函数。
+Shows all user-defined functions in the system.
## SHOW LICENSE
@@ -110,9 +110,9 @@ SHOW LICENSE;
SHOW GRANTS;
```
-显示企业版许可授权的信息。
+Shows information about the TDengine Enterprise Edition license.
-注:企业版独有
+Note: TDengine Enterprise Edition only.
## SHOW INDEXES
@@ -120,7 +120,7 @@ SHOW GRANTS;
SHOW INDEXES FROM tbl_name [FROM db_name];
```
-显示已创建的索引。
+Shows indices that have been created.
## SHOW LOCAL VARIABLES
@@ -128,7 +128,7 @@ SHOW INDEXES FROM tbl_name [FROM db_name];
SHOW LOCAL VARIABLES;
```
-显示当前客户端配置参数的运行值。
+Shows the working configuration of the client.
## SHOW MNODES
@@ -136,7 +136,7 @@ SHOW LOCAL VARIABLES;
SHOW MNODES;
```
-显示当前系统中 MNODE 的信息。
+Shows information about mnodes in the system.
## SHOW MODULES
@@ -144,7 +144,7 @@ SHOW MNODES;
SHOW MODULES;
```
-显示当前系统中所安装的组件的信息。
+Shows information about modules installed in the system.
## SHOW QNODES
@@ -152,7 +152,7 @@ SHOW MODULES;
SHOW QNODES;
```
-显示当前系统中 QNODE (查询节点)的信息。
+Shows information about qnodes in the system.
## SHOW SCORES
@@ -160,9 +160,9 @@ SHOW QNODES;
SHOW SCORES;
```
-显示系统被许可授权的容量的信息。
+Shows information about the storage space allowed by the license.
-注:企业版独有
+Note: TDengine Enterprise Edition only.
## SHOW SNODES
@@ -170,7 +170,7 @@ SHOW SCORES;
SHOW SNODES;
```
-显示当前系统中 SNODE (流计算节点)的信息。
+Shows information about stream processing nodes (snodes) in the system.
## SHOW STABLES
@@ -178,7 +178,7 @@ SHOW SNODES;
SHOW [db_name.]STABLES [LIKE 'pattern'];
```
-显示当前数据库下的所有超级表的信息。可以使用 LIKE 对表名进行模糊匹配。
+Shows all supertables in the current database. You can use LIKE for fuzzy matching.
## SHOW STREAMS
@@ -186,7 +186,7 @@ SHOW [db_name.]STABLES [LIKE 'pattern'];
SHOW STREAMS;
```
-显示当前系统内所有流计算的信息。
+Shows information about streams in the system.
## SHOW SUBSCRIPTIONS
@@ -194,7 +194,7 @@ SHOW STREAMS;
SHOW SUBSCRIPTIONS;
```
-显示当前数据库下的所有的订阅关系
+Shows all subscriptions in the system.
## SHOW TABLES
@@ -202,7 +202,7 @@ SHOW SUBSCRIPTIONS;
SHOW [db_name.]TABLES [LIKE 'pattern'];
```
-显示当前数据库下的所有普通表和子表的信息。可以使用 LIKE 对表名进行模糊匹配。
+Shows all standard tables and subtables in the current database. You can use LIKE for fuzzy matching.
## SHOW TABLE DISTRIBUTED
@@ -210,7 +210,7 @@ SHOW [db_name.]TABLES [LIKE 'pattern'];
SHOW TABLE DISTRIBUTED table_name;
```
-显示表的数据分布信息。
+Shows how table data is distributed.
## SHOW TAGS
@@ -218,7 +218,7 @@ SHOW TABLE DISTRIBUTED table_name;
SHOW TAGS FROM child_table_name [FROM db_name];
```
-显示子表的标签信息。
+Shows all tag information in a subtable.
## SHOW TOPICS
@@ -226,7 +226,7 @@ SHOW TAGS FROM child_table_name [FROM db_name];
SHOW TOPICS;
```
-显示当前数据库下的所有主题的信息。
+Shows all topics in the current database.
## SHOW TRANSACTIONS
@@ -234,7 +234,7 @@ SHOW TOPICS;
SHOW TRANSACTIONS;
```
-显示当前系统中正在执行的事务的信息
+Shows all running transactions in the system.
## SHOW USERS
@@ -242,7 +242,7 @@ SHOW TRANSACTIONS;
SHOW USERS;
```
-显示当前系统中所有用户的信息。包括用户自定义的用户和系统默认用户。
+Shows information about users on the system. This includes user-created users and system-defined users.
## SHOW VARIABLES
@@ -251,7 +251,7 @@ SHOW VARIABLES;
SHOW DNODE dnode_id VARIABLES;
```
-显示当前系统中各节点需要相同的配置参数的运行值,也可以指定 DNODE 来查看其的配置参数。
+Shows the working configuration of the parameters that must be the same on each node. You can also specify a dnode to show the working configuration for that node.
## SHOW VGROUPS
@@ -259,7 +259,7 @@ SHOW DNODE dnode_id VARIABLES;
SHOW [db_name.]VGROUPS;
```
-显示当前系统中所有 VGROUP 或某个 db 的 VGROUPS 的信息。
+Shows information about all vgroups in the system or about the vgroups for a specified database.
## SHOW VNODES
@@ -267,4 +267,4 @@ SHOW [db_name.]VGROUPS;
SHOW VNODES [dnode_name];
```
-显示当前系统中所有 VNODE 或某个 DNODE 的 VNODE 的信息。
+Shows information about all vnodes in the system or about the vnodes for a specified dnode.
diff --git a/docs/en/12-taos-sql/25-grant.md b/docs/en/12-taos-sql/25-grant.md
index 0c290350cc155e975e5a817c991bebc74944cd04..b9a3fa2321c8d073845d0cf9157ce335c930e06f 100644
--- a/docs/en/12-taos-sql/25-grant.md
+++ b/docs/en/12-taos-sql/25-grant.md
@@ -1,29 +1,30 @@
---
-sidebar_label: 权限管理
-title: 权限管理
+sidebar_label: Access Control
+title: User and Access Control
+description: Manage user and user's permission
---
-本节讲述如何在 TDengine 中进行权限管理的相关操作。
+This document describes how to manage permissions in TDengine.
-## 创建用户
+## Create a User
```sql
-CREATE USER use_name PASS password;
+CREATE USER use_name PASS 'password';
```
-创建用户。
+This statement creates a user account.
-use_name最长为23字节。
+The maximum length of use_name is 23 bytes.
-password最长为128字节,合法字符包括"a-zA-Z0-9!?$%^&*()_–+={[}]:;@~#|<,>.?/",不可以出现单双引号、撇号、反斜杠和空格,且不可以为空。
+The maximum length of password is 128 bytes. The password can include leters, digits, and special characters excluding single quotation marks, double quotation marks, backticks, backslashes, and spaces. The password cannot be empty.
-## 删除用户
+## Delete a User
```sql
DROP USER user_name;
```
-## 修改用户信息
+## Modify User Information
```sql
ALTER USER user_name alter_user_clause
@@ -35,12 +36,12 @@ alter_user_clause: {
}
```
-- PASS:修改用户密码。
-- ENABLE:修改用户是否启用。1表示启用此用户,0表示禁用此用户。
-- SYSINFO:修改用户是否可查看系统信息。1表示可以查看系统信息,0表示不可以查看系统信息。
+- PASS: Modify the user password.
+- ENABLE: Specify whether the user is enabled or disabled. 1 indicates enabled and 0 indicates disabled.
+- SYSINFO: Specify whether the user can query system information. 1 indicates that the user can query system information and 0 indicates that the user cannot query system information.
-## 授权
+## Grant Permissions
```sql
GRANT privileges ON priv_level TO user_name
@@ -61,15 +62,15 @@ priv_level : {
}
```
-对用户授权。
+Grant permissions to a user.
-授权级别支持到DATABASE,权限有READ和WRITE两种。
+Permissions are granted on the database level. You can grant read or write permissions.
-TDengine 有超级用户和普通用户两类用户。超级用户缺省创建为root,拥有所有权限。使用超级用户创建出来的用户为普通用户。在未授权的情况下,普通用户可以创建DATABASE,并拥有自己创建的DATABASE的所有权限,包括删除数据库、修改数据库、查询时序数据和写入时序数据。超级用户可以给普通用户授予其他DATABASE的读写权限,使其可以在此DATABASE上读写数据,但不能对其进行删除和修改数据库的操作。
+TDengine has superusers and standard users. The default superuser name is root. This account has all permissions. You can use the superuser account to create standard users. With no permissions, standard users can create databases and have permissions on the databases that they create. These include deleting, modifying, querying, and writing to their own databases. Superusers can grant users permission to read and write other databases. However, standard users cannot delete or modify databases created by other users.
-对于非DATABASE的对象,如USER、DNODE、UDF、QNODE等,普通用户只有读权限(一般为SHOW命令),不能创建和修改。
+For non-database objects such as users, dnodes, and user-defined functions, standard users have read permissions only, generally by means of the SHOW statement. Standard users cannot create or modify these objects.
-## 撤销授权
+## Revoke Permissions
```sql
REVOKE privileges ON priv_level FROM user_name
@@ -91,4 +92,4 @@ priv_level : {
```
-收回对用户的授权。
\ No newline at end of file
+Revoke permissions from a user.
diff --git a/docs/en/12-taos-sql/26-udf.md b/docs/en/12-taos-sql/26-udf.md
index bd8d61a5844241efae9eee99a73c65afd3d0926f..e6199e8b315c2311be509a3eb819f33ac9a8b8bc 100644
--- a/docs/en/12-taos-sql/26-udf.md
+++ b/docs/en/12-taos-sql/26-udf.md
@@ -1,28 +1,68 @@
---
-sidebar_label: 自定义函数
-title: 用户自定义函数
+sidebar_label: User-Defined Functions
+title: User-Defined Functions (UDF)
---
-除了 TDengine 的内置函数以外,用户还可以编写自己的函数逻辑并加入TDengine系统中。
+You can create user-defined functions and import them into TDengine.
+## Create UDF
-## 创建函数
+SQL command can be executed on the host where the generated UDF DLL resides to load the UDF DLL into TDengine. This operation cannot be done through REST interface or web console. Once created, any client of the current TDengine can use these UDF functions in their SQL commands. UDF are stored in the management node of TDengine. The UDFs loaded in TDengine would be still available after TDengine is restarted.
+When creating UDF, the type of UDF, i.e. a scalar function or aggregate function must be specified. If the specified type is wrong, the SQL statements using the function would fail with errors. The input data type and output data type must be consistent with the UDF definition.
+
+- Create Scalar Function
```sql
-CREATE [AGGREGATE] FUNCTION func_name AS library_path OUTPUTTYPE type_name [BUFSIZE value]
+CREATE FUNCTION function_name AS library_path OUTPUTTYPE output_type;
```
-语法说明:
+ - function_name: The scalar function name to be used in SQL statement which must be consistent with the UDF name and is also the name of the compiled DLL (.so file).
+ - library_path: The absolute path of the DLL file including the name of the shared object file (.so). The path must be quoted with single or double quotes.
+ - output_type: The data type of the results of the UDF.
+
+ For example, the following SQL statement can be used to create a UDF from `libbitand.so`.
+
+ ```sql
+ CREATE FUNCTION bit_and AS "/home/taos/udf_example/libbitand.so" OUTPUTTYPE INT;
+ ```
+
+- Create Aggregate Function
+```sql
+CREATE AGGREGATE FUNCTION function_name AS library_path OUTPUTTYPE output_type [ BUFSIZE buffer_size ];
+```
+
+ - function_name: The aggregate function name to be used in SQL statement which must be consistent with the udfNormalFunc name and is also the name of the compiled DLL (.so file).
+ - library_path: The absolute path of the DLL file including the name of the shared object file (.so). The path must be quoted with single or double quotes.
+ - output_type: The output data type, the value is the literal string of the supported TDengine data type.
+ - buffer_size: The size of the intermediate buffer in bytes. This parameter is optional.
+
+ For example, the following SQL statement can be used to create a UDF from `libl2norm.so`.
+
+ ```sql
+ CREATE AGGREGATE FUNCTION l2norm AS "/home/taos/udf_example/libl2norm.so" OUTPUTTYPE DOUBLE bufsize 8;
+ ```
+For more information about user-defined functions, see [User-Defined Functions](../../develop/udf).
-AGGREGATE:标识此函数是标量函数还是聚集函数。
-func_name:函数名,必须与函数实现中udfNormalFunc的实际名称一致。
-library_path:包含UDF函数实现的动态链接库的绝对路径,是在客户端侧主机上的绝对路径。
-OUTPUTTYPE:标识此函数的返回类型。
-BUFSIZE:中间结果的缓冲区大小,单位是字节。不设置则默认为0。最大不可超过512字节。
+## Manage UDF
-关于如何开发自定义函数,请参考 [UDF使用说明](../../develop/udf)。
+- The following statement deleted the specified user-defined function.
+```
+DROP FUNCTION function_name;
+```
-## 删除自定义函数
+- function_name: The value of function_name in the CREATE statement used to import the UDF for example `bit_and` or `l2norm`.
+```sql
+DROP FUNCTION bit_and;
+```
+- Show Available UDF
+```sql
+SHOW FUNCTIONS;
+```
+
+## Call UDF
+The function name specified when creating UDF can be used directly in SQL statements, just like builtin functions. For example:
```sql
-DROP FUNCTION func_name
-```
\ No newline at end of file
+SELECT X(c1,c2) FROM table/stable;
+```
+
+The above SQL statement invokes function X for column c1 and c2. You can use query keywords like WHERE with user-defined functions.
diff --git a/docs/en/12-taos-sql/27-index.md b/docs/en/12-taos-sql/27-index.md
index 2c0907723e76f304566e6a19bdef2d63225f903f..7d09bc43ab06932b82019923d4a8fda48cd99c97 100644
--- a/docs/en/12-taos-sql/27-index.md
+++ b/docs/en/12-taos-sql/27-index.md
@@ -1,11 +1,11 @@
---
-sidebar_label: 索引
-title: 使用索引
+sidebar_label: Index
+title: Using Indices
---
-TDengine 从 3.0.0.0 版本开始引入了索引功能,支持 SMA 索引和 FULLTEXT 索引。
+TDengine supports SMA and FULLTEXT indexing.
-## 创建索引
+## Create an Index
```sql
CREATE FULLTEXT INDEX index_name ON tb_name (col_name [, col_name] ...)
@@ -19,29 +19,29 @@ functions:
function [, function] ...
```
-### SMA 索引
+### SMA Indexing
-对指定列按 INTERVAL 子句定义的时间窗口创建进行预聚合计算,预聚合计算类型由 functions_string 指定。SMA 索引能提升指定时间段的聚合查询的性能。目前,限制一个超级表只能创建一个 SMA INDEX。
+Performs pre-aggregation on the specified column over the time window defined by the INTERVAL clause. The type is specified in functions_string. SMA indexing improves aggregate query performance for the specified time period. One supertable can only contain one SMA index.
-- 支持的函数包括 MAX、MIN 和 SUM。
-- WATERMARK: 最小单位毫秒,取值范围 [0ms, 900000ms],默认值为 5 秒,只可用于超级表。
-- MAX_DELAY: 最小单位毫秒,取值范围 [1ms, 900000ms],默认值为 interval 的值(但不能超过最大值),只可用于超级表。注:不建议 MAX_DELAY 设置太小,否则会过于频繁的推送结果,影响存储和查询性能,如无特殊需求,取默认值即可。
+- The max, min, and sum functions are supported.
+- WATERMARK: Enter a value between 0ms and 900000ms. The most precise unit supported is milliseconds. The default value is 5 seconds. This option can be used only on supertables.
+- MAX_DELAY: Enter a value between 1ms and 900000ms. The most precise unit supported is milliseconds. The default value is the value of interval provided that it does not exceed 900000ms. This option can be used only on supertables. Note: Retain the default value if possible. Configuring a small MAX_DELAY may cause results to be frequently pushed, affecting storage and query performance.
-### FULLTEXT 索引
+### FULLTEXT Indexing
-对指定列建立文本索引,可以提升含有文本过滤的查询的性能。FULLTEXT 索引不支持 index_option 语法。现阶段只支持对 JSON 类型的标签列创建 FULLTEXT 索引。不支持多列联合索引,但可以为每个列分布创建 FULLTEXT 索引。
+Creates a text index for the specified column. FULLTEXT indexing improves performance for queries with text filtering. The index_option syntax is not supported for FULLTEXT indexing. FULLTEXT indexing is supported for JSON tag columns only. Multiple columns cannot be indexed together. However, separate indices can be created for each column.
-## 删除索引
+## Delete an Index
```sql
DROP INDEX index_name;
```
-## 查看索引
+## View Indices
````sql
```sql
SHOW INDEXES FROM tbl_name [FROM db_name];
````
-显示在所指定的数据库或表上已创建的索引。
+Shows indices that have been created for the specified database or table.
diff --git a/docs/en/12-taos-sql/28-recovery.md b/docs/en/12-taos-sql/28-recovery.md
index 72b220b8ff44917831ac16301237702c991b9b15..14ac14f8673fba05fee09317de927df00effed0f 100644
--- a/docs/en/12-taos-sql/28-recovery.md
+++ b/docs/en/12-taos-sql/28-recovery.md
@@ -1,38 +1,38 @@
---
-sidebar_label: 异常恢复
-title: 异常恢复
+sidebar_label: Error Recovery
+title: Error Recovery
---
-在一个复杂的应用场景中,连接和查询任务等有可能进入一种错误状态或者耗时过长迟迟无法结束,此时需要有能够终止这些连接或任务的方法。
+In a complex environment, connections and query tasks may encounter errors or fail to return in a reasonable time. If this occurs, you can terminate the connection or task.
-## 终止连接
+## Terminate a Connection
```sql
KILL CONNECTION conn_id;
```
-conn_id 可以通过 `SHOW CONNECTIONS` 获取。
+You can use the SHOW CONNECTIONS statement to find the conn_id.
-## 终止查询
+## Terminate a Query
```sql
SHOW QUERY query_id;
```
-query_id 可以通过 `SHOW QUERIES` 获取。
+You can use the SHOW QUERIES statement to find the query_id.
-## 终止事务
+## Terminate a Transaction
```sql
KILL TRANSACTION trans_id
```
-trans_id 可以通过 `SHOW TRANSACTIONS` 获取。
+You can use the SHOW TRANSACTIONS statement to find the trans_id.
-## 重置客户端缓存
+## Reset Client Cache
```sql
RESET QUERY CACHE;
```
-如果在多客户端情况下出现元数据不同步的情况,可以用这条命令强制清空客户端缓存,随后客户端会从服务端拉取最新的元数据。
+If metadata becomes desynchronized among multiple clients, you can use this command to clear the client-side cache. Clients then obtain the latest metadata from the server.
diff --git a/docs/en/12-taos-sql/29-changes.md b/docs/en/12-taos-sql/29-changes.md
new file mode 100644
index 0000000000000000000000000000000000000000..8532eeac5d599ca2739393c9e38eec52631e407a
--- /dev/null
+++ b/docs/en/12-taos-sql/29-changes.md
@@ -0,0 +1,95 @@
+---
+sidebar_label: Changes in TDengine 3.0
+title: Changes in TDengine 3.0
+description: "This document explains how TDengine SQL has changed in version 3.0."
+---
+
+## Basic SQL Elements
+
+| # | **Element** | **
Change
** | **Description** |
+| - | :------- | :-------- | :------- |
+| 1 | VARCHAR | Added | Alias of BINARY.
+| 2 | TIMESTAMP literal | Added | TIMESTAMP 'timestamp format' syntax now supported.
+| 3 | _ROWTS pseudocolumn | Added | Indicates the primary key. Alias of _C0.
+| 4 | INFORMATION_SCHEMA | Added | Database for system metadata containing all schema definitions
+| 5 | PERFORMANCE_SCHEMA | Added | Database for system performance information.
+| 6 | Connection queries | Deprecated | Connection queries are no longer supported. The syntax and interfaces are deprecated.
+| 7 | Mixed operations | Enhanced | Mixing scalar and vector operations in queries has been enhanced and is supported in all SELECT clauses.
+| 8 | Tag operations | Added | Tag columns can be used in queries and clauses like data columns.
+| 9 | Timeline clauses and time functions in supertables | Enhanced | When PARTITION BY is not used, data in supertables is merged into a single timeline.
+
+## SQL Syntax
+
+The following data types can be used in the schema for standard tables.
+
+| # | **Statement** | **
Change
** | **Description** |
+| - | :------- | :-------- | :------- |
+| 1 | ALTER ACCOUNT | Deprecated| This Enterprise Edition-only statement has been removed. It returns the error "This statement is no longer supported."
+| 2 | ALTER ALL DNODES | Added | Modifies the configuration of all dnodes.
+| 3 | ALTER DATABASE | Modified | Deprecated
QUORUM: Specified the required number of confirmations. STRICT is now used to specify strong or weak consistency. The STRICT parameter cannot be modified.
BLOCKS: Specified the memory blocks used by each vnode. BUFFER is now used to specify the size of the write cache pool for each vnode.
UPDATE: Specified whether update operations were supported. All databases now support updating data in certain columns.
CACHELAST: Specified how to cache the newest row of data. CACHEMODEL now replaces CACHELAST.
COMP: Cannot be modified. Added
CACHEMODEL: Specifies whether to cache the latest subtable data.
CACHESIZE: Specifies the size of the cache for the newest subtable data.
WAL_FSYNC_PERIOD: Replaces the FSYNC parameter.
WAL_LEVEL: Replaces the WAL parameter. Modified
REPLICA: Cannot be modified.
KEEP: Now supports units.
+| 4 | ALTER STABLE | Modified | Deprecated
CHANGE TAG: Modified the name of a tag. Replaced by RENAME TAG. Added
RENAME TAG: Replaces CHANGE TAG.
COMMENT: Specifies comments for a supertable.
+| 5 | ALTER TABLE | Modified | Deprecated
CHANGE TAG: Modified the name of a tag. Replaced by RENAME TAG. Added
RENAME TAG: Replaces CHANGE TAG.
COMMENT: Specifies comments for a standard table.
TTL: Specifies the time-to-live for a standard table.
+| 6 | ALTER USER | Modified | Deprecated
PRIVILEGE: Specified user permissions. Replaced by GRANT and REVOKE. Added
ENABLE: Enables or disables a user.
SYSINFO: Specifies whether a user can query system information.
+| 7 | COMPACT VNODES | Not supported | Compacted the data on a vnode. Not supported.
+| 8 | CREATE ACCOUNT | Deprecated| This Enterprise Edition-only statement has been removed. It returns the error "This statement is no longer supported."
+| 9 | CREATE DATABASE | Modified | Deprecated
BLOCKS: Specified the number of blocks for each vnode. BUFFER is now used to specify the size of the write cache pool for each vnode.
CACHE: Specified the size of the memory blocks used by each vnode. BUFFER is now used to specify the size of the write cache pool for each vnode.
CACHELAST: Specified how to cache the newest row of data. CACHEMODEL now replaces CACHELAST.
DAYS: The length of time to store in a single file. Replaced by DURATION.
FSYNC: Specified the fsync interval when WAL was set to 2. Replaced by WAL_FSYNC_PERIOD.
QUORUM: Specified the number of confirmations required. STRICT is now used to specify strong or weak consistency.
UPDATE: Specified whether update operations were supported. All databases now support updating data in certain columns.
WAL: Specified the WAL level. Replaced by WAL_LEVEL. Added
BUFFER: Specifies the size of the write cache pool for each vnode.
CACHEMODEL: Specifies whether to cache the latest subtable data.
CACHESIZE: Specifies the size of the cache for the newest subtable data.
DURATION: Replaces DAYS. Now supports units.
PAGES: Specifies the number of pages in the metadata storage engine cache on each vnode.
PAGESIZE: specifies the size (in KB) of each page in the metadata storage engine cache on each vnode.
RETENTIONS: Specifies the aggregation interval and retention period
STRICT: Specifies whether strong data consistency is enabled.
SINGLE_STABLE: Specifies whether a database can contain multiple supertables.
VGROUPS: Specifies the initial number of vgroups when a database is created.
WAL_FSYNC_PERIOD: Replaces the FSYNC parameter.
WAL_LEVEL: Replaces the WAL parameter.
WAL_RETENTION_PERIOD: specifies the time after which WAL files are deleted. This parameter is used for data subscription.
WAL_RETENTION_SIZE: specifies the size at which WAL files are deleted. This parameter is used for data subscription.
WAL_ROLL_PERIOD: Specifies the WAL rotation period.
WAL_SEGMENT_SIZE: specifies the maximum size of a WAL file. Modified
KEEP: Now supports units.
+| 10 | CREATE DNODE | Modified | Now supports specifying hostname and port separately
CREATE DNODE dnode_host_name PORT port_val
+| 11 | CREATE INDEX | Added | Creates an SMA index.
+| 12 | CREATE MNODE | Added | Creates an mnode.
+| 13 | CREATE QNODE | Added | Creates a qnode.
+| 14 | CREATE STABLE | Modified | New parameter added
MAX_DELAY: Specifies the maximum delay for pushing stream processing results.
ROLLUP: Specifies aggregate functions to roll up. Rolling up a function provides downsampled results based on multiple axes.
SMA: Provides user-defined precomputation of aggregates based on data blocks.
TTL: Specifies the time-to-live for a standard table.
+| 17 | CREATE TOPIC | Added | Creates a topic.
+| 18 | DROP ACCOUNT | Deprecated| This Enterprise Edition-only statement has been removed. It returns the error "This statement is no longer supported."
+| 19 | DROP CONSUMER GROUP | Added | Deletes a consumer group.
+| 20 | DROP INDEX | Added | Deletes an index.
+| 21 | DROP MNODE | Added | Creates an mnode.
+| 22 | DROP QNODE | Added | Creates a qnode.
+| 23 | DROP STREAM | Added | Deletes a stream.
+| 24 | DROP TABLE | Modified | Added batch deletion syntax.
+| 25 | DROP TOPIC | Added | Deletes a topic.
+| 26 | EXPLAIN | Added | Query the execution plan of a query statement.
+| 27 | GRANT | Added | Grants permissions to a user.
+| 28 | KILL TRANSACTION | Added | Terminates an mnode transaction.
+| 29 | KILL STREAM | Deprecated | Terminated a continuous query. The continuous query feature has been replaced with the stream processing feature.
+| 30 | MERGE VGROUP | Added | Merges vgroups.
+| 31 | REVOKE | Added | Revokes permissions from a user.
+| 32 | SELECT | Modified |
SELECT does not use the implicit results column. Output columns must be specified in the SELECT clause.
DISTINCT support is enhanced. In previous versions, DISTINCT only worked on the tag column and could not be used with JOIN or GROUP BY.
JOIN support is enhanced. The following are now supported after JOIN: a WHERE clause with OR, operations on multiple tables, and GROUP BY on multiple tables.
Subqueries after FROM are enhanced. Levels of nesting are no longer restricted. Subqueries can be used with UNION ALL. Other syntax restrictions are eliminated.
All scalar functions can be used after WHERE.
GROUP BY is enhanced. You can group by any scalar expression or combination thereof.
SESSION can be used on supertables. When PARTITION BY is not used, data in supertables is merged into a single timeline.
STATE_WINDOW can be used on supertables. When PARTITION BY is not used, data in supertables is merged into a single timeline.
ORDER BY is enhanced. It is no longer required to use ORDER BY and GROUP BY together. There is no longer a restriction on the number of order expressions. NULLS FIRST and NULLS LAST syntax has been added. Any expression that conforms to the ORDER BY semantics can be used.
Added PARTITION BY syntax. PARTITION BY replaces GROUP BY tags.
+| 33 | SHOW ACCOUNTS | Deprecated | This Enterprise Edition-only statement has been removed. It returns the error "This statement is no longer supported."
+| 34 | SHOW APPS | Added | Shows all clients (such as applications) that connect to the cluster.
+| 35 | SHOW CONSUMERS | Added | Shows information about all active consumers in the system.
+| 36 | SHOW DATABASES | Modified | Only shows database names.
+| 37 | SHOW FUNCTIONS | Modified | Only shows UDF names.
+| 38 | SHOW LICENCE | Added | Alias of SHOW GRANTS.
+| 39 | SHOW INDEXES | Added | Shows indices that have been created.
+| 40 | SHOW LOCAL VARIABLES | Added | Shows the working configuration of the client.
+| 41 | SHOW MODULES | Deprecated | Shows information about modules installed in the system.
+| 42 | SHOW QNODES | Added | Shows information about qnodes in the system.
+| 43 | SHOW STABLES | Modified | Only shows supertable names.
+| 44 | SHOW STREAMS | Modified | This statement previously showed continuous queries. The continuous query feature has been replaced with the stream processing feature. This statement now shows streams that have been created.
+| 45 | SHOW SUBSCRIPTIONS | Added | Shows all subscriptions in the current database.
+| 46 | SHOW TABLES | Modified | Only shows table names.
+| 47 | SHOW TABLE DISTRIBUTED | Added | Shows how table data is distributed. This replaces the `SELECT _block_dist() FROM { tb_name | stb_name }` command.
+| 48 | SHOW TOPICS | Added | Shows all subscribed topics in the current database.
+| 49 | SHOW TRANSACTIONS | Added | Shows all running transactions in the system.
+| 50 | SHOW DNODE VARIABLES | Added | Shows the configuration of the specified dnode.
+| 51 | SHOW VNODES | Not supported | Shows information about vnodes in the system. Not supported.
+| 52 | SPLIT VGROUP | Added | Splits a vgroup into two vgroups.
+| 53 | TRIM DATABASE | Added | Deletes data that has expired and orders the remaining data in accordance with the storage configuration.
+
+## SQL Functions
+
+| # | **Function** | **
Change
** | **Description** |
+| - | :------- | :-------- | :------- |
+| 1 | TWA | Added | Can be used on supertables. When PARTITION BY is not used, data in supertables is merged into a single timeline.
+| 2 | IRATE | Enhanced | Can be used on supertables. When PARTITION BY is not used, data in supertables is merged into a single timeline.
+| 3 | LEASTSQUARES | Enhanced | Can be used on supertables.
+| 4 | ELAPSED | Enhanced | Can be used on supertables. When PARTITION BY is not used, data in supertables is merged into a single timeline.
+| 5 | DIFF | Enhanced | Can be used on supertables. When PARTITION BY is not used, data in supertables is merged into a single timeline.
+| 6 | DERIVATIVE | Enhanced | Can be used on supertables. When PARTITION BY is not used, data in supertables is merged into a single timeline.
+| 7 | CSUM | Enhanced | Can be used on supertables. When PARTITION BY is not used, data in supertables is merged into a single timeline.
+| 8 | MAVG | Enhanced | Can be used on supertables. When PARTITION BY is not used, data in supertables is merged into a single timeline.
+| 9 | SAMPLE | Enhanced | Can be used on supertables. When PARTITION BY is not used, data in supertables is merged into a single timeline.
+| 10 | STATECOUNT | Enhanced | Can be used on supertables. When PARTITION BY is not used, data in supertables is merged into a single timeline.
+| 11 | STATEDURATION | Enhanced | Can be used on supertables. When PARTITION BY is not used, data in supertables is merged into a single timeline.
diff --git a/docs/en/12-taos-sql/index.md b/docs/en/12-taos-sql/index.md
index 33656338a7bba38dc55cf536bdba8e95309c5acf..a5ffc9dc8dce158eccc0fa0519f09ba346710c31 100644
--- a/docs/en/12-taos-sql/index.md
+++ b/docs/en/12-taos-sql/index.md
@@ -1,22 +1,23 @@
---
title: TDengine SQL
-description: "The syntax supported by TDengine SQL "
+description: 'The syntax supported by TDengine SQL '
---
-This section explains the syntax of SQL to perform operations on databases, tables and STables, insert data, select data and use functions. We also provide some tips that can be used in TDengine SQL. If you have previous experience with SQL this section will be fairly easy to understand. If you do not have previous experience with SQL, you'll come to appreciate the simplicity and power of SQL.
+This section explains the syntax of SQL to perform operations on databases, tables and STables, insert data, select data and use functions. We also provide some tips that can be used in TDengine SQL. If you have previous experience with SQL this section will be fairly easy to understand. If you do not have previous experience with SQL, you'll come to appreciate the simplicity and power of SQL. TDengine SQL has been enhanced in version 3.0, and the query engine has been rearchitected. For information about how TDengine SQL has changed, see [Changes in TDengine 3.0](../taos-sql/changes).
-TDengine SQL is the major interface for users to write data into or query from TDengine. For ease of use, the syntax is similar to that of standard SQL. However, please note that TDengine SQL is not standard SQL. For instance, TDengine doesn't provide a delete function for time series data and so corresponding statements are not provided in TDengine SQL.
+TDengine SQL is the major interface for users to write data into or query from TDengine. It uses standard SQL syntax and includes extensions and optimizations for time-series data and services. The maximum length of a TDengine SQL statement is 1 MB. Note that keyword abbreviations are not supported. For example, DELETE cannot be entered as DEL.
Syntax Specifications used in this chapter:
-- The content inside <\> needs to be input by the user, excluding <\> itself.
+- Keywords are given in uppercase, although SQL is not case-sensitive.
+- Information that you input is given in lowercase.
- \[ \] means optional input, excluding [] itself.
- | means one of a few options, excluding | itself.
- … means the item prior to it can be repeated multiple times.
-To better demonstrate the syntax, usage and rules of TAOS SQL, hereinafter it's assumed that there is a data set of data from electric meters. Each meter collects 3 data measurements: current, voltage, phase. The data model is shown below:
+To better demonstrate the syntax, usage and rules of TDengine SQL, hereinafter it's assumed that there is a data set of data from electric meters. Each meter collects 3 data measurements: current, voltage, phase. The data model is shown below:
-```sql
+```
taos> DESCRIBE meters;
Field | Type | Length | Note |
=================================================================================
@@ -29,3 +30,10 @@ taos> DESCRIBE meters;
```
The data set includes the data collected by 4 meters, the corresponding table name is d1001, d1002, d1003 and d1004 based on the data model of TDengine.
+
+```mdx-code-block
+import DocCardList from '@theme/DocCardList';
+import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
+
+
+```
diff --git a/docs/en/13-operation/01-pkg-install.md b/docs/en/13-operation/01-pkg-install.md
index c098002962d62aa0acc7a94462c052303cb2ed90..d7713b943f5fe8fbd5e685b8ba03ff8cc8ed4e53 100644
--- a/docs/en/13-operation/01-pkg-install.md
+++ b/docs/en/13-operation/01-pkg-install.md
@@ -1,156 +1,77 @@
---
-title: Install & Uninstall
+title: Install and Uninstall
description: Install, Uninstall, Start, Stop and Upgrade
---
import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";
-TDengine community version provides deb and rpm packages for users to choose from, based on their system environment. The deb package supports Debian, Ubuntu and derivative systems. The rpm package supports CentOS, RHEL, SUSE and derivative systems. Furthermore, a tar.gz package is provided for TDengine Enterprise customers.
+This document gives more information about installing, uninstalling, and upgrading TDengine.
## Install
+About details of installing TDenine, please refer to [Installation Guide](../../get-started/package/).
+
+## Uninstall
+
-
+
-1. Download deb package from official website, for example TDengine-server-2.4.0.7-Linux-x64.deb
-2. In the directory where the package is located, execute the command below
+Apt-get package of TDengine can be uninstalled as below:
```bash
-$ sudo dpkg -i TDengine-server-2.4.0.7-Linux-x64.deb
-(Reading database ... 137504 files and directories currently installed.)
-Preparing to unpack TDengine-server-2.4.0.7-Linux-x64.deb ...
+$ sudo apt-get remove tdengine
+Reading package lists... Done
+Building dependency tree
+Reading state information... Done
+The following packages will be REMOVED:
+ tdengine
+0 upgraded, 0 newly installed, 1 to remove and 18 not upgraded.
+After this operation, 68.3 MB disk space will be freed.
+Do you want to continue? [Y/n] y
+(Reading database ... 135625 files and directories currently installed.)
+Removing tdengine (3.0.0.0) ...
TDengine is removed successfully!
-Unpacking tdengine (2.4.0.7) over (2.4.0.7) ...
-Setting up tdengine (2.4.0.7) ...
-Start to install TDengine...
-
-System hostname is: ubuntu-1804
-
-Enter FQDN:port (like h1.taosdata.com:6030) of an existing TDengine cluster node to join
-OR leave it blank to build one:
-Enter your email address for priority support or enter empty to skip:
-Created symlink /etc/systemd/system/multi-user.target.wants/taosd.service → /etc/systemd/system/taosd.service.
-
-To configure TDengine : edit /etc/taos/taos.cfg
-To start TDengine : sudo systemctl start taosd
-To access TDengine : taos -h ubuntu-1804 to login into TDengine server
-
-
-TDengine is installed successfully!
```
-
-
-
-
-1. Download rpm package from official website, for example TDengine-server-2.4.0.7-Linux-x64.rpm;
-2. In the directory where the package is located, execute the command below
+Apt-get package of taosTools can be uninstalled as below:
```
-$ sudo rpm -ivh TDengine-server-2.4.0.7-Linux-x64.rpm
-Preparing... ################################# [100%]
-Updating / installing...
- 1:tdengine-2.4.0.7-3 ################################# [100%]
-Start to install TDengine...
-
-System hostname is: centos7
-
-Enter FQDN:port (like h1.taosdata.com:6030) of an existing TDengine cluster node to join
-OR leave it blank to build one:
-
-Enter your email address for priority support or enter empty to skip:
-
-Created symlink from /etc/systemd/system/multi-user.target.wants/taosd.service to /etc/systemd/system/taosd.service.
-
-To configure TDengine : edit /etc/taos/taos.cfg
-To start TDengine : sudo systemctl start taosd
-To access TDengine : taos -h centos7 to login into TDengine server
-
-
-TDengine is installed successfully!
+$ sudo apt remove taostools
+Reading package lists... Done
+Building dependency tree
+Reading state information... Done
+The following packages will be REMOVED:
+ taostools
+0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
+After this operation, 68.3 MB disk space will be freed.
+Do you want to continue? [Y/n]
+(Reading database ... 147973 files and directories currently installed.)
+Removing taostools (2.1.2) ...
```
-
-
-
-1. Download the tar.gz package, for example TDengine-server-2.4.0.7-Linux-x64.tar.gz;
-2. In the directory where the package is located, first decompress the file, then switch to the sub-directory generated in decompressing, i.e. "TDengine-enterprise-server-2.4.0.7/" in this example, and execute the `install.sh` script.
-
-```bash
-$ tar xvzf TDengine-enterprise-server-2.4.0.7-Linux-x64.tar.gz
-TDengine-enterprise-server-2.4.0.7/
-TDengine-enterprise-server-2.4.0.7/driver/
-TDengine-enterprise-server-2.4.0.7/driver/vercomp.txt
-TDengine-enterprise-server-2.4.0.7/driver/libtaos.so.2.4.0.7
-TDengine-enterprise-server-2.4.0.7/install.sh
-TDengine-enterprise-server-2.4.0.7/examples/
-...
-
-$ ll
-total 43816
-drwxrwxr-x 3 ubuntu ubuntu 4096 Feb 22 09:31 ./
-drwxr-xr-x 20 ubuntu ubuntu 4096 Feb 22 09:30 ../
-drwxrwxr-x 4 ubuntu ubuntu 4096 Feb 22 09:30 TDengine-enterprise-server-2.4.0.7/
--rw-rw-r-- 1 ubuntu ubuntu 44852544 Feb 22 09:31 TDengine-enterprise-server-2.4.0.7-Linux-x64.tar.gz
-
-$ cd TDengine-enterprise-server-2.4.0.7/
-
- $ ll
-total 40784
-drwxrwxr-x 4 ubuntu ubuntu 4096 Feb 22 09:30 ./
-drwxrwxr-x 3 ubuntu ubuntu 4096 Feb 22 09:31 ../
-drwxrwxr-x 2 ubuntu ubuntu 4096 Feb 22 09:30 driver/
-drwxrwxr-x 10 ubuntu ubuntu 4096 Feb 22 09:30 examples/
--rwxrwxr-x 1 ubuntu ubuntu 33294 Feb 22 09:30 install.sh*
--rw-rw-r-- 1 ubuntu ubuntu 41704288 Feb 22 09:30 taos.tar.gz
-
-$ sudo ./install.sh
-
-Start to update TDengine...
-Created symlink /etc/systemd/system/multi-user.target.wants/taosd.service → /etc/systemd/system/taosd.service.
-Nginx for TDengine is updated successfully!
-
-To configure TDengine : edit /etc/taos/taos.cfg
-To configure Taos Adapter (if has) : edit /etc/taos/taosadapter.toml
-To start TDengine : sudo systemctl start taosd
-To access TDengine : use taos -h ubuntu-1804 in shell OR from http://127.0.0.1:6060
-
-TDengine is updated successfully!
-Install taoskeeper as a standalone service
-taoskeeper is installed, enable it by `systemctl enable taoskeeper`
-```
-
-:::info
-Users will be prompted to enter some configuration information when install.sh is executing. The interactive mode can be disabled by executing `./install.sh -e no`. `./install.sh -h` can show all parameters with detailed explanation.
-
-:::
-
-
-
-
-:::note
-When installing on the first node in the cluster, at the "Enter FQDN:" prompt, nothing needs to be provided. When installing on subsequent nodes, at the "Enter FQDN:" prompt, you must enter the end point of the first dnode in the cluster if it is already up. You can also just ignore it and configure it later after installation is finished.
-
-:::
-
-## Uninstall
-
-
Deb package of TDengine can be uninstalled as below:
-```bash
+```
$ sudo dpkg -r tdengine
(Reading database ... 137504 files and directories currently installed.)
-Removing tdengine (2.4.0.7) ...
+Removing tdengine (3.0.0.0) ...
TDengine is removed successfully!
```
+Deb package of taosTools can be uninstalled as below:
+
+```
+$ sudo dpkg -r taostools
+(Reading database ... 147973 files and directories currently installed.)
+Removing taostools (2.1.2) ...
+```
+
@@ -162,6 +83,13 @@ $ sudo rpm -e tdengine
TDengine is removed successfully!
```
+RPM package of taosTools can be uninstalled as below:
+
+```
+sudo rpm -e taostools
+taosToole is removed successfully!
+```
+
@@ -170,115 +98,69 @@ tar.gz package of TDengine can be uninstalled as below:
```
$ rmtaos
-Nginx for TDengine is running, stopping it...
TDengine is removed successfully!
-
-taosKeeper is removed successfully!
-```
-
-
-
-
-:::note
-
-- We strongly recommend not to use multiple kinds of installation packages on a single host TDengine.
-- After deb package is installed, if the installation directory is removed manually, uninstall or reinstall will not work. This issue can be resolved by using the command below which cleans up TDengine package information. You can then reinstall if needed.
-
-```bash
- $ sudo rm -f /var/lib/dpkg/info/tdengine*
```
-- After rpm package is installed, if the installation directory is removed manually, uninstall or reinstall will not work. This issue can be resolved by using the command below which cleans up TDengine package information. You can then reinstall if needed.
+tar.gz package of taosTools can be uninstalled as below:
-```bash
- $ sudo rpm -e --noscripts tdengine
```
+$ rmtaostools
+Start to uninstall taos tools ...
-:::
-
-## Installation Directory
-
-TDengine is installed at /usr/local/taos if successful.
-
-```bash
-$ cd /usr/local/taos
-$ ll
-$ ll
-total 28
-drwxr-xr-x 7 root root 4096 Feb 22 09:34 ./
-drwxr-xr-x 12 root root 4096 Feb 22 09:34 ../
-drwxr-xr-x 2 root root 4096 Feb 22 09:34 bin/
-drwxr-xr-x 2 root root 4096 Feb 22 09:34 cfg/
-lrwxrwxrwx 1 root root 13 Feb 22 09:34 data -> /var/lib/taos/
-drwxr-xr-x 2 root root 4096 Feb 22 09:34 driver/
-drwxr-xr-x 10 root root 4096 Feb 22 09:34 examples/
-drwxr-xr-x 2 root root 4096 Feb 22 09:34 include/
-lrwxrwxrwx 1 root root 13 Feb 22 09:34 log -> /var/log/taos/
+taos tools is uninstalled successfully!
```
-During the installation process:
-
-- Configuration directory, data directory, and log directory are created automatically if they don't exist
-- The default configuration file is located at /etc/taos/taos.cfg, which is a copy of /usr/local/taos/cfg/taos.cfg
-- The default data directory is /var/lib/taos, which is a soft link to /usr/local/taos/data
-- The default log directory is /var/log/taos, which is a soft link to /usr/local/taos/log
-- The executables at /usr/local/taos/bin are linked to /usr/bin
-- The DLL files at /usr/local/taos/driver are linked to /usr/lib
-- The header files at /usr/local/taos/include are linked to /usr/include
-
-:::note
+
+
+Run C:\TDengine\unins000.exe to uninstall TDengine on a Windows system.
+
+
-- When TDengine is uninstalled, the configuration /etc/taos/taos.cfg, data directory /var/lib/taos, log directory /var/log/taos are kept. They can be deleted manually with caution, because data can't be recovered. Please follow data integrity, security, backup or relevant SOPs before deleting any data.
-- When reinstalling TDengine, if the default configuration file /etc/taos/taos.cfg exists, it will be kept and the configuration file in the installation package will be renamed to taos.cfg.orig and stored at /usr/local/taos/cfg to be used as configuration sample. Otherwise the configuration file in the installation package will be installed to /etc/taos/taos.cfg and used.
+:::info
-## Start and Stop
+- We strongly recommend not to use multiple kinds of installation packages on a single host TDengine. The packages may affect each other and cause errors.
-Linux system services `systemd`, `systemctl` or `service` are used to start, stop and restart TDengine. The server process of TDengine is `taosd`, which is started automatically after the Linux system is started. System operators can use `systemd`, `systemctl` or `service` to start, stop or restart TDengine server.
+- After deb package is installed, if the installation directory is removed manually, uninstall or reinstall will not work. This issue can be resolved by using the command below which cleans up TDengine package information.
-For example, if using `systemctl` , the commands to start, stop, restart and check TDengine server are below:
+ ```
+ $ sudo rm -f /var/lib/dpkg/info/tdengine*
+ ```
-- Start server:`systemctl start taosd`
+You can then reinstall if needed.
-- Stop server:`systemctl stop taosd`
+- After rpm package is installed, if the installation directory is removed manually, uninstall or reinstall will not work. This issue can be resolved by using the command below which cleans up TDengine package information.
-- Restart server:`systemctl restart taosd`
+ ```
+ $ sudo rpm -e --noscripts tdengine
+ ```
-- Check server status:`systemctl status taosd`
+You can then reinstall if needed.
-From version 2.4.0.0, a new independent component named as `taosAdapter` has been included in TDengine. `taosAdapter` should be started and stopped using `systemctl`.
+:::
-If the server process is OK, the output of `systemctl status` is like below:
+Uninstalling and Modifying Files
-```
-Active: active (running)
-```
+- When TDengine is uninstalled, the configuration /etc/taos/taos.cfg, data directory /var/lib/taos, log directory /var/log/taos are kept. They can be deleted manually with caution, because data can't be recovered. Please follow data integrity, security, backup or relevant SOPs before deleting any data.
-Otherwise, the output is as below:
+- When reinstalling TDengine, if the default configuration file /etc/taos/taos.cfg exists, it will be kept and the configuration file in the installation package will be renamed to taos.cfg.orig and stored at /usr/local/taos/cfg to be used as configuration sample. Otherwise the configuration file in the installation package will be installed to /etc/taos/taos.cfg and used.
-```
-Active: inactive (dead)
-```
## Upgrade
-
There are two aspects in upgrade operation: upgrade installation package and upgrade a running server.
To upgrade a package, follow the steps mentioned previously to first uninstall the old version then install the new version.
Upgrading a running server is much more complex. First please check the version number of the old version and the new version. The version number of TDengine consists of 4 sections, only if the first 3 sections match can the old version be upgraded to the new version. The steps of upgrading a running server are as below:
-
- Stop inserting data
- Make sure all data is persisted to disk
-- Make some simple queries (Such as total rows in stables, tables and so on. Note down the values. Follow best practices and relevant SOPs.)
- Stop the cluster of TDengine
- Uninstall old version and install new version
- Start the cluster of TDengine
-- Execute simple queries, such as the ones executed prior to installing the new package, to make sure there is no data loss
+- Execute simple queries, such as the ones executed prior to installing the new package, to make sure there is no data loss
- Run some simple data insertion statements to make sure the cluster works well
- Restore business services
:::warning
-
TDengine doesn't guarantee any lower version is compatible with the data generated by a higher version, so it's never recommended to downgrade the version.
:::
diff --git a/docs/en/13-operation/02-planning.mdx b/docs/en/13-operation/02-planning.mdx
index c1baf92dbfa8d93f83174c05c2ea631d1a469739..2dffa7bb8747e21e4754740208eafed65d341217 100644
--- a/docs/en/13-operation/02-planning.mdx
+++ b/docs/en/13-operation/02-planning.mdx
@@ -1,40 +1,32 @@
---
+sidebar_label: Resource Planning
title: Resource Planning
---
It is important to plan computing and storage resources if using TDengine to build an IoT, time-series or Big Data platform. How to plan the CPU, memory and disk resources required, will be described in this chapter.
-## Memory Requirement of Server Side
+## Server Memory Requirements
-By default, the number of vgroups created for each database is the same as the number of CPU cores. This can be configured by the parameter `maxVgroupsPerDb`. Each vnode in a vgroup stores one replica. Each vnode consumes a fixed amount of memory, i.e. `blocks` \* `cache`. In addition, some memory is required for tag values associated with each table. A fixed amount of memory is required for each cluster. So, the memory required for each DB can be calculated using the formula below:
+Each database creates a fixed number of vgroups. This number is 2 by default and can be configured with the `vgroups` parameter. The number of replicas can be controlled with the `replica` parameter. Each replica requires one vnode per vgroup. Altogether, the memory required by each database depends on the following configuration options:
-```
-Database Memory Size = maxVgroupsPerDb * replica * (blocks * cache + 10MB) + numOfTables * (tagSizePerTable + 0.5KB)
-```
+- vgroups
+- replica
+- buffer
+- pages
+- pagesize
+- cachesize
-For example, assuming the default value of `maxVgroupPerDB` is 64, the default value of `cache` is 16M, the default value of `blocks` is 6, there are 100,000 tables in a DB, the replica number is 1, total length of tag values is 256 bytes, the total memory required for this DB is: 64 \* 1 \* (16 \* 6 + 10) + 100000 \* (0.25 + 0.5) / 1000 = 6792M.
+For more information, see [Database](../../taos-sql/database).
-In the real operation of TDengine, we are more concerned about the memory used by each TDengine server process `taosd`.
+The memory required by a database is therefore greater than or equal to:
```
- taosd_memory = vnode_memory + mnode_memory + query_memory
+vgroups * replica * (buffer + pages * pagesize + cachesize)
```
-In the above formula:
-
-1. "vnode_memory" of a `taosd` process is the memory used by all vnodes hosted by this `taosd` process. It can be roughly calculated by firstly adding up the total memory of all DBs whose memory usage can be derived according to the formula for Database Memory Size, mentioned above, then dividing by number of dnodes and multiplying the number of replicas.
-
-```
- vnode_memory = (sum(Database Memory Size) / number_of_dnodes) * replica
-```
-
-2. "mnode_memory" of a `taosd` process is the memory consumed by a mnode. If there is one (and only one) mnode hosted in a `taosd` process, the memory consumed by "mnode" is "0.2KB \* the total number of tables in the cluster".
-
-3. "query_memory" is the memory used when processing query requests. Each ongoing query consumes at least "0.2 KB \* total number of involved tables".
-
-Please note that the above formulas can only be used to estimate the minimum memory requirement, instead of maximum memory usage. In a real production environment, it's better to reserve some redundance beyond the estimated minimum memory requirement. If memory is abundant, it's suggested to increase the value of parameter `blocks` to speed up data insertion and data query.
+However, note that this requirement is spread over all dnodes in the cluster, not on a single physical machine. The physical servers that run dnodes meet the requirement together. If a cluster has multiple databases, the memory required increases accordingly. In complex environments where dnodes were added after initial deployment in response to increasing resource requirements, load may not be balanced among the original dnodes and newer dnodes. In this situation, the actual status of your dnodes is more important than theoretical calculations.
-## Memory Requirement of Client Side
+## Client Memory Requirements
For the client programs using TDengine client driver `taosc` to connect to the server side there is a memory requirement as well.
@@ -56,10 +48,10 @@ So, at least 3GB needs to be reserved for such a client.
The CPU resources required depend on two aspects:
-- **Data Insertion** Each dnode of TDengine can process at least 10,000 insertion requests in one second, while each insertion request can have multiple rows. The difference in computing resource consumed, between inserting 1 row at a time, and inserting 10 rows at a time is very small. So, the more the number of rows that can be inserted one time, the higher the efficiency. Inserting in batch also imposes requirements on the client side which needs to cache rows to insert in batch once the number of cached rows reaches a threshold.
+- **Data Insertion** Each dnode of TDengine can process at least 10,000 insertion requests in one second, while each insertion request can have multiple rows. The difference in computing resource consumed, between inserting 1 row at a time, and inserting 10 rows at a time is very small. So, the more the number of rows that can be inserted one time, the higher the efficiency. If each insert request contains more than 200 records, a single core can process more than 1 million records per second. Inserting in batch also imposes requirements on the client side which needs to cache rows to insert in batch once the number of cached rows reaches a threshold.
- **Data Query** High efficiency query is provided in TDengine, but it's hard to estimate the CPU resource required because the queries used in different use cases and the frequency of queries vary significantly. It can only be verified with the query statements, query frequency, data size to be queried, and other requirements provided by users.
-In short, the CPU resource required for data insertion can be estimated but it's hard to do so for query use cases. In real operation, it's suggested to control CPU usage below 50%. If this threshold is exceeded, it's a reminder for system operator to add more nodes in the cluster to expand resources.
+In short, the CPU resource required for data insertion can be estimated but it's hard to do so for query use cases. If possible, ensure that CPU usage remains below 50%. If this threshold is exceeded, it's a reminder for system operator to add more nodes in the cluster to expand resources.
## Disk Requirement
@@ -77,6 +69,6 @@ To increase performance, multiple disks can be setup for parallel data reading o
## Number of Hosts
-A host can be either physical or virtual. The total memory, total CPU, total disk required can be estimated according to the formulae mentioned previously. Then, according to the system resources that a single host can provide, assuming all hosts have the same resources, the number of hosts can be derived easily.
+A host can be either physical or virtual. The total memory, total CPU, total disk required can be estimated according to the formulae mentioned previously. If the number of data replicas is not 1, the required resources are multiplied by the number of replicas.
-**Quick Estimation for CPU, Memory and Disk** Please refer to [Resource Estimate](https://www.taosdata.com/config/config.html).
+Then, according to the system resources that a single host can provide, assuming all hosts have the same resources, the number of hosts can be derived easily.
diff --git a/docs/en/13-operation/03-tolerance.md b/docs/en/13-operation/03-tolerance.md
index d4d48d7fcdc2c990b6ea0821e2347c70a809ed79..21a5a902822d7b85f555114a112686d4e35c64aa 100644
--- a/docs/en/13-operation/03-tolerance.md
+++ b/docs/en/13-operation/03-tolerance.md
@@ -1,6 +1,5 @@
---
-sidebar_label: Fault Tolerance
-title: Fault Tolerance & Disaster Recovery
+title: Fault Tolerance and Disaster Recovery
---
## Fault Tolerance
@@ -11,22 +10,21 @@ When a data block is received by TDengine, the original data block is first writ
There are 2 configuration parameters related to WAL:
-- walLevel:
- - 0:wal is disabled
- - 1:wal is enabled without fsync
- - 2:wal is enabled with fsync
-- fsync:This parameter is only valid when walLevel is set to 2. It specifies the interval, in milliseconds, of invoking fsync. If set to 0, it means fsync is invoked immediately once WAL is written.
+- wal_level: Specifies the WAL level. 1 indicates that WAL is enabled but fsync is disabled. 2 indicates that WAL and fsync are both enabled. The default value is 1.
+- wal_fsync_period: This parameter is only valid when wal_level is set to 2. It specifies the interval, in milliseconds, of invoking fsync. If set to 0, it means fsync is invoked immediately once WAL is written.
-To achieve absolutely no data loss, walLevel should be set to 2 and fsync should be set to 1. There is a performance penalty to the data ingestion rate. However, if the concurrent data insertion threads on the client side can reach a big enough number, for example 50, the data ingestion performance will be still good enough. Our verification shows that the drop is only 30% when fsync is set to 3,000 milliseconds.
+To achieve absolutely no data loss, set wal_level to 2 and wal_fsync_period to 0. There is a performance penalty to the data ingestion rate. However, if the concurrent data insertion threads on the client side can reach a big enough number, for example 50, the data ingestion performance will be still good enough. Our verification shows that the drop is only 30% when wal_fsync_period is set to 3000 milliseconds.
## Disaster Recovery
-TDengine uses replication to provide high availability and disaster recovery capability.
+TDengine uses replication to provide high availability.
-A TDengine cluster is managed by mnode. To ensure the high availability of mnode, multiple replicas can be configured by the system parameter `numOfMnodes`. The data replication between mnode replicas is performed in a synchronous way to guarantee metadata consistency.
+A TDengine cluster is managed by mnodes. You can configure up to three mnodes to ensure high availability. The data replication between mnode replicas is performed in a synchronous way to guarantee metadata consistency.
-The number of replicas for time series data in TDengine is associated with each database. There can be many databases in a cluster and each database can be configured with a different number of replicas. When creating a database, parameter `replica` is used to configure the number of replications. To achieve high availability, `replica` needs to be higher than 1.
+The number of replicas for time series data in TDengine is associated with each database. There can be many databases in a cluster and each database can be configured with a different number of replicas. When creating a database, the parameter `replica` is used to specify the number of replicas. To achieve high availability, set `replica` to 3.
The number of dnodes in a TDengine cluster must NOT be lower than the number of replicas for any database, otherwise it would fail when trying to create a table.
As long as the dnodes of a TDengine cluster are deployed on different physical machines and the replica number is higher than 1, high availability can be achieved without any other assistance. For disaster recovery, dnodes of a TDengine cluster should be deployed in geographically different data centers.
+
+Alternatively, you can use taosX to synchronize the data from one TDengine cluster to another cluster in a remote location. However, taosX is only available in TDengine enterprise version, for more information please contact tdengine.com.
diff --git a/docs/en/13-operation/06-admin.md b/docs/en/13-operation/06-admin.md
deleted file mode 100644
index 458a91b88c6d8319fe8b84c2b34d8ff968957910..0000000000000000000000000000000000000000
--- a/docs/en/13-operation/06-admin.md
+++ /dev/null
@@ -1,50 +0,0 @@
----
-title: User Management
----
-
-A system operator can use TDengine CLI `taos` to create or remove users or change passwords. The SQL commands are documented below:
-
-## Create User
-
-```sql
-CREATE USER PASS <'password'>;
-```
-
-When creating a user and specifying the user name and password, the password needs to be quoted using single quotes.
-
-## Drop User
-
-```sql
-DROP USER ;
-```
-
-Dropping a user can only be performed by root.
-
-## Change Password
-
-```sql
-ALTER USER PASS <'password'>;
-```
-
-To keep the case of the password when changing password, the password needs to be quoted using single quotes.
-
-## Change Privilege
-
-```sql
-ALTER USER PRIVILEGE ;
-```
-
-The privileges that can be changed to are `read` or `write` without single quotes.
-
-Note:there is another privilege `super`, which is not allowed to be authorized to any user.
-
-## Show Users
-
-```sql
-SHOW USERS;
-```
-
-:::note
-In SQL syntax, `< >` means the part that needs to be input by the user, excluding the `< >` itself.
-
-:::
diff --git a/docs/en/13-operation/09-status.md b/docs/en/13-operation/09-status.md
deleted file mode 100644
index 51396524ea281ae665c9fdf61d2e6e6202995537..0000000000000000000000000000000000000000
--- a/docs/en/13-operation/09-status.md
+++ /dev/null
@@ -1,54 +0,0 @@
----
-sidebar_label: Connections & Tasks
-title: Manage Connections and Query Tasks
----
-
-A system operator can use the TDengine CLI to show connections, ongoing queries, stream computing, and can close connections or stop ongoing query tasks or stream computing.
-
-## Show Connections
-
-```sql
-SHOW CONNECTIONS;
-```
-
-One column of the output of the above SQL command is "ip:port", which is the end point of the client.
-
-## Force Close Connections
-
-```sql
-KILL CONNECTION ;
-```
-
-In the above SQL command, `connection-id` is from the first column of the output of `SHOW CONNECTIONS`.
-
-## Show Ongoing Queries
-
-```sql
-SHOW QUERIES;
-```
-
-The first column of the output is query ID, which is composed of the corresponding connection ID and the sequence number of the current query task started on this connection. The format is "connection-id:query-no".
-
-## Force Close Queries
-
-```sql
-KILL QUERY ;
-```
-
-In the above SQL command, `query-id` is from the first column of the output of `SHOW QUERIES `.
-
-## Show Continuous Query
-
-```sql
-SHOW STREAMS;
-```
-
-The first column of the output is stream ID, which is composed of the connection ID and the sequence number of the current stream started on this connection. The format is "connection-id:stream-no".
-
-## Force Close Continuous Query
-
-```sql
-KILL STREAM ;
-```
-
-The above SQL command, `stream-id` is from the first column of the output of `SHOW STREAMS`.
diff --git a/docs/en/13-operation/17-diagnose.md b/docs/en/13-operation/17-diagnose.md
index 2b474fddba4af5ba0c29103cd8ab1249d10d055b..d01d12e831956e6a6db654e1f6dbf5072ac6b243 100644
--- a/docs/en/13-operation/17-diagnose.md
+++ b/docs/en/13-operation/17-diagnose.md
@@ -13,110 +13,59 @@ Diagnostic steps:
1. If the port range to be diagnosed is being occupied by a `taosd` server process, please first stop `taosd.
2. On the server side, execute command `taos -n server -P -l ` to monitor the port range starting from the port specified by `-P` parameter with the role of "server".
3. On the client side, execute command `taos -n client -h -P -l ` to send a testing package to the specified server and port.
-
--l : The size of the testing package, in bytes. The value range is [11, 64,000] and default value is 1,000. Please note that the package length must be same in the above 2 commands executed on server side and client side respectively.
+
+-l : The size of the testing package, in bytes. The value range is [11, 64,000] and default value is 1,000.
+Please note that the package length must be same in the above 2 commands executed on server side and client side respectively.
Output of the server side for the example is below:
```bash
-# taos -n server -P 6000
-12/21 14:50:13.522509 0x7f536f455200 UTL work as server, host:172.27.0.7 startPort:6000 endPort:6011 pkgLen:1000
-
-12/21 14:50:13.522659 0x7f5352242700 UTL TCP server at port:6000 is listening
-12/21 14:50:13.522727 0x7f5351240700 UTL TCP server at port:6001 is listening
-...
-...
+# taos -n server -P 6030 -l 1000
+network test server is initialized, port:6030
+request is received, size:1000
+request is received, size:1000
...
-12/21 14:50:13.523954 0x7f5342fed700 UTL TCP server at port:6011 is listening
-12/21 14:50:13.523989 0x7f53437ee700 UTL UDP server at port:6010 is listening
-12/21 14:50:13.524019 0x7f53427ec700 UTL UDP server at port:6011 is listening
-12/21 14:50:22.192849 0x7f5352242700 UTL TCP: read:1000 bytes from 172.27.0.8 at 6000
-12/21 14:50:22.192993 0x7f5352242700 UTL TCP: write:1000 bytes to 172.27.0.8 at 6000
-12/21 14:50:22.237082 0x7f5351a41700 UTL UDP: recv:1000 bytes from 172.27.0.8 at 6000
-12/21 14:50:22.237203 0x7f5351a41700 UTL UDP: send:1000 bytes to 172.27.0.8 at 6000
-12/21 14:50:22.237450 0x7f5351240700 UTL TCP: read:1000 bytes from 172.27.0.8 at 6001
-12/21 14:50:22.237576 0x7f5351240700 UTL TCP: write:1000 bytes to 172.27.0.8 at 6001
-12/21 14:50:22.281038 0x7f5350a3f700 UTL UDP: recv:1000 bytes from 172.27.0.8 at 6001
-12/21 14:50:22.281141 0x7f5350a3f700 UTL UDP: send:1000 bytes to 172.27.0.8 at 6001
...
...
-...
-12/21 14:50:22.677443 0x7f5342fed700 UTL TCP: read:1000 bytes from 172.27.0.8 at 6011
-12/21 14:50:22.677576 0x7f5342fed700 UTL TCP: write:1000 bytes to 172.27.0.8 at 6011
-12/21 14:50:22.721144 0x7f53427ec700 UTL UDP: recv:1000 bytes from 172.27.0.8 at 6011
-12/21 14:50:22.721261 0x7f53427ec700 UTL UDP: send:1000 bytes to 172.27.0.8 at 6011
+request is received, size:1000
+request is received, size:1000
```
Output of the client side for the example is below:
```bash
# taos -n client -h 172.27.0.7 -P 6000
-12/21 14:50:22.192434 0x7fc95d859200 UTL work as client, host:172.27.0.7 startPort:6000 endPort:6011 pkgLen:1000
-
-12/21 14:50:22.192472 0x7fc95d859200 UTL server ip:172.27.0.7 is resolved from host:172.27.0.7
-12/21 14:50:22.236869 0x7fc95d859200 UTL successed to test TCP port:6000
-12/21 14:50:22.237215 0x7fc95d859200 UTL successed to test UDP port:6000
+taos -n client -h v3s2 -P 6030 -l 1000
+network test client is initialized, the server is v3s2:6030
+request is sent, size:1000
+response is received, size:1000
+request is sent, size:1000
+response is received, size:1000
...
...
...
-12/21 14:50:22.676891 0x7fc95d859200 UTL successed to test TCP port:6010
-12/21 14:50:22.677240 0x7fc95d859200 UTL successed to test UDP port:6010
-12/21 14:50:22.720893 0x7fc95d859200 UTL successed to test TCP port:6011
-12/21 14:50:22.721274 0x7fc95d859200 UTL successed to test UDP port:6011
-```
-
-The output needs to be checked carefully for the system operator to find the root cause and resolve the problem.
-
-## Startup Status and RPC Diagnostic
-
-`taos -n startup -h ` can be used to check the startup status of a `taosd` process. This is a common task which should be performed by a system operator, especially in the case of a cluster, to determine whether `taosd` has been started successfully.
-
-`taos -n rpc -h ` can be used to check whether the port of a started `taosd` can be accessed or not. If `taosd` process doesn't respond or is working abnormally, this command can be used to initiate a rpc communication with the specified fqdn to determine whether it's a network problem or whether `taosd` is abnormal.
-
-## Sync and Arbitrator Diagnostic
+request is sent, size:1000
+response is received, size:1000
+request is sent, size:1000
+response is received, size:1000
-```bash
-taos -n sync -P 6040 -h
-taos -n sync -P 6042 -h
+total succ: 100/100 cost: 16.23 ms speed: 5.87 MB/s
```
-The above commands can be executed in a Linux shell to check whether the port for sync is working well and whether the sync module on the server side is working well. Additionally, `-P 6042` is used to check whether the arbitrator is configured properly and is working well.
-
-## Network Speed Diagnostic
-
-`taos -n speed -h -P 6030 -N 10 -l 10000000 -S TCP`
-
-From version 2.2.0.0 onwards, the above command can be executed in a Linux shell to test network speed. The command sends uncompressed packages to a running `taosd` server process or a simulated server process started by `taos -n server` to test the network speed. Parameters can be used when testing network speed are as below:
-
--n:When set to "speed", it means testing network speed.
--h:The FQDN or IP of the server process to be connected to; if not set, the FQDN configured in `taos.cfg` is used.
--P:The port of the server process to connect to, the default value is 6030.
--N:The number of packages that will be sent in the test, range is [1,10000], default value is 100.
--l:The size of each package in bytes, range is [1024, 1024 \* 1024 \* 1024], default value is 1024.
--S:The type of network packages to send, can be either TCP or UDP, default value is TCP.
-
-## FQDN Resolution Diagnostic
-
-`taos -n fqdn -h `
-
-From version 2.2.0.0 onward, the above command can be executed in a Linux shell to test the resolution speed of FQDN. It can be used to try to resolve a FQDN to an IP address and record the time spent in this process. The parameters that can be used for this purpose are as below:
-
--n:When set to "fqdn", it means testing the speed of resolving FQDN.
--h:The FQDN to be resolved. If not set, the `FQDN` parameter in `taos.cfg` is used by default.
+The output needs to be checked carefully for the system operator to find the root cause and resolve the problem.
## Server Log
-The parameter `debugFlag` is used to control the log level of the `taosd` server process. The default value is 131. For debugging and tracing, it needs to be set to either 135 or 143 respectively.
-
-Once this parameter is set to 135 or 143, the log file grows very quickly especially when there is a huge volume of data insertion and data query requests. If all the logs are stored together, some important information may be missed very easily and so on the server side, important information is stored in a different place from other logs.
+The parameter `debugFlag` is used to control the log level of the `taosd` server process. The default value is 131. For debugging and tracing, it needs to be set to either 135 or 143 respectively.
-- The log at level of INFO, WARNING and ERROR is stored in `taosinfo` so that it is easy to find important information
-- The log at level of DEBUG (135) and TRACE (143) and other information not handled by `taosinfo` are stored in `taosdlog`
+Once this parameter is set to 135 or 143, the log file grows very quickly especially when there is a huge volume of data insertion and data query requests. Ensure that the disk drive on which logs are stored has sufficient space.
## Client Log
-An independent log file, named as "taoslog+" is generated for each client program, i.e. a client process. The default value of `debugFlag` is also 131 and only logs at level of INFO/ERROR/WARNING are recorded. As stated above, for debugging and tracing, it needs to be changed to 135 or 143 respectively, so that logs at DEBUG or TRACE level can be recorded.
+An independent log file, named as "taoslog+" is generated for each client program, i.e. a client process. The parameter `debugFlag` is used to control the log level. The default value is 131. For debugging and tracing, it needs to be set to either 135 or 143 respectively.
+
+The default value of `debugFlag` is also 131 and only logs at level of INFO/ERROR/WARNING are recorded. As stated above, for debugging and tracing, it needs to be changed to 135 or 143 respectively, so that logs at DEBUG or TRACE level can be recorded.
The maximum length of a single log file is controlled by parameter `numOfLogLines` and only 2 log files are kept for each `taosd` server process.
-Log files are written in an async way to minimize the workload on disk, but the trade off for performance is that a few log lines may be lost in some extreme conditions.
+Log files are written in an async way to minimize the workload on disk, but the trade off for performance is that a few log lines may be lost in some extreme conditions. You can configure asynclog to 0 when needed for troubleshooting purposes to ensure that no log information is lost.
diff --git a/docs/en/14-reference/02-rest-api/02-rest-api.mdx b/docs/en/14-reference/02-rest-api/02-rest-api.mdx
index fe18349a6dae3ad44772b4a30a2c3d4ad75b0f47..ce28ee87d9317487d5c610d23287775be6b753ec 100644
--- a/docs/en/14-reference/02-rest-api/02-rest-api.mdx
+++ b/docs/en/14-reference/02-rest-api/02-rest-api.mdx
@@ -2,15 +2,15 @@
title: REST API
---
-To support the development of various types of applications and platforms, TDengine provides an API that conforms to REST principles; namely REST API. To minimize the learning cost, unlike REST APIs for other database engines, TDengine allows insertion of SQL commands in the BODY of an HTTP POST request, to operate the database.
+To support the development of various types of applications and platforms, TDengine provides an API that conforms to REST principles; namely REST API. To minimize the learning cost, unlike REST APIs for other database engines, TDengine allows insertion of SQL commands in the BODY of an HTTP POST request, to operate the database.
-:::note
-One difference from the native connector is that the REST interface is stateless and so the `USE db_name` command has no effect. All references to table names and super table names need to specify the database name in the prefix. (Since version 2.2.0.0, TDengine supports specification of the db_name in RESTful URL. If the database name prefix is not specified in the SQL command, the `db_name` specified in the URL will be used. Since version 2.4.0.0, REST service is provided by taosAdapter by default and it requires that the `db_name` must be specified in the URL.)
+:::note
+One difference from the native connector is that the REST interface is stateless and so the `USE db_name` command has no effect. All references to table names and super table names need to specify the database name in the prefix. TDengine supports specification of the db_name in RESTful URL. If the database name prefix is not specified in the SQL command, the `db_name` specified in the URL will be used.
:::
## Installation
-The REST interface does not rely on any TDengine native library, so the client application does not need to install any TDengine libraries. The client application's development language only needs to support the HTTP protocol.
+The REST interface does not rely on any TDengine native library, so the client application does not need to install any TDengine libraries. The client application's development language only needs to support the HTTP protocol. The REST interface is provided by [taosAdapter](../taosadapter), to use REST interface you need to make sure `taosAdapter` is running properly.
## Verification
@@ -18,86 +18,77 @@ If the TDengine server is already installed, it can be verified as follows:
The following example is in an Ubuntu environment and uses the `curl` tool to verify that the REST interface is working. Note that the `curl` tool may need to be installed in your environment.
-The following example lists all databases on the host h1.taosdata.com. To use it in your environment, replace `h1.taosdata.com` and `6041` (the default port) with the actual running TDengine service FQDN and port number.
+The following example lists all databases on the host h1.tdengine.com. To use it in your environment, replace `h1.tdengine.com` and `6041` (the default port) with the actual running TDengine service FQDN and port number.
-```html
-curl -L -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -d "show databases;" h1.taosdata.com:6041/rest/sql
+```bash
+curl -L -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" \
+ -d "select name, ntables, status from information_schema.ins_databases;" \
+ h1.tdengine.com:6041/rest/sql
```
The following return value results indicate that the verification passed.
```json
{
- "status": "succ",
- "head": [
- "name",
- "created_time",
- "ntables",
- "vgroups",
- "replica",
- "quorum",
- "days",
- "keep1,keep2,keep(D)",
- "cache(MB)",
- "blocks",
- "minrows",
- "maxrows",
- "wallevel",
- "fsync",
- "comp",
- "precision",
- "status"
- ],
- "data": [
- [
- "log",
- "2020-09-02 17:23:00.039",
- 4,
- 1,
- 1,
- 1,
- 10,
- "30,30,30",
- 1,
- 3,
- 100,
- 4096,
- 1,
- 3000,
- 2,
- "us",
- "ready"
- ]
- ],
- "rows": 1
+ "code": 0,
+ "column_meta": [
+ [
+ "name",
+ "VARCHAR",
+ 64
+ ],
+ [
+ "ntables",
+ "BIGINT",
+ 8
+ ],
+ [
+ "status",
+ "VARCHAR",
+ 10
+ ]
+ ],
+ "data": [
+ [
+ "information_schema",
+ 16,
+ "ready"
+ ],
+ [
+ "performance_schema",
+ 9,
+ "ready"
+ ]
+ ],
+ "rows": 2
}
```
## HTTP request URL format
-```
+```text
http://:/rest/sql/[db_name]
```
Parameter Description:
-- fqnd: FQDN or IP address of any host in the cluster
-- port: httpPort configuration item in the configuration file, default is 6041
-- db_name: Optional parameter that specifies the default database name for the executed SQL command. (supported since version 2.2.0.0)
+- fqnd: FQDN or IP address of any host in the cluster.
+- port: httpPort configuration item in the configuration file, default is 6041.
+- db_name: Optional parameter that specifies the default database name for the executed SQL command.
For example, `http://h1.taos.com:6041/rest/sql/test` is a URL to `h1.taos.com:6041` and sets the default database name to `test`.
TDengine supports both Basic authentication and custom authentication mechanisms, and subsequent versions will provide a standard secure digital signature mechanism for authentication.
-- The custom authentication information is as follows. More details about "token" later.
+- authentication information is shown below:
- ```
+ ```text
Authorization: Taosd
```
-- Basic authentication information is shown below
+- Basic authentication information is shown below:
- ```
+ ```text
Authorization: Basic
```
@@ -109,51 +100,148 @@ Use `curl` to initiate an HTTP request with a custom authentication method, with
curl -L -H "Authorization: Basic " -d "" :/rest/sql/[db_name]
```
-Or
+or
```bash
curl -L -u username:password -d "" :/rest/sql/[db_name]
```
-where `TOKEN` is the string after Base64 encoding of `{username}:{password}`, e.g. `root:taosdata` is encoded as `cm9vdDp0YW9zZGF0YQ==`.
+where `TOKEN` is the string after Base64 encoding of `{username}:{password}`, e.g. `root:taosdata` is encoded as `cm9vdDp0YW9zZGF0YQ==`..
## HTTP Return Format
-The return result is in JSON format, as follows:
+### HTTP Response Code
+
+| **Response Code** | **Description** |
+|-------------------|----------------|
+| 200 | Success. (Also used for C interface errors.) |
+| 400 | Parameter error |
+| 401 | Authentication failure |
+| 404 | Interface not found |
+| 500 | Internal error |
+| 503 | Insufficient system resources |
+
+### HTTP body structure
+
+#### Successful Operation
+
+Example:
```json
{
- "status": "succ",
- "head": ["ts", "current", ...],
- "column_meta": [["ts",9,8],["current",6,4], ...],
- "data": [
- ["2018-10-03 14:38:05.000", 10.3, ...],
- ["2018-10-03 14:38:15.000", 12.6, ...]
+ "code": 0,
+ "column_meta": [["affected_rows", "INT", 4]],
+ "data": [[0]],
+ "rows": 1
+}
+```
+
+Description:
+
+- code: (`int`) 0 indicates success.
+- column_meta: (`[1][3]any`) Only returns `[["affected_rows", "INT", 4]]`.
+- rows: (`int`) Only returns `1`.
+- data: (`[][]any`) Returns the number of rows affected.
+
+#### Successful Query
+
+Example:
+
+```json
+{
+ "code": 0,
+ "column_meta": [
+ ["ts", "TIMESTAMP", 8],
+ ["count", "BIGINT", 8],
+ ["endpoint", "VARCHAR", 45],
+ ["status_code", "INT", 4],
+ ["client_ip", "VARCHAR", 40],
+ ["request_method", "VARCHAR", 15],
+ ["request_uri", "VARCHAR", 128]
+ ],
+ "data": [
+ [
+ "2022-06-29T05:50:55.401Z",
+ 2,
+ "LAPTOP-NNKFTLTG:6041",
+ 200,
+ "172.23.208.1",
+ "POST",
+ "/rest/sql"
],
- "rows": 2
+ [
+ "2022-06-29T05:52:16.603Z",
+ 1,
+ "LAPTOP-NNKFTLTG:6041",
+ 200,
+ "172.23.208.1",
+ "POST",
+ "/rest/sql"
+ ],
+ [
+ "2022-06-29T06:28:14.118Z",
+ 1,
+ "LAPTOP-NNKFTLTG:6041",
+ 200,
+ "172.23.208.1",
+ "POST",
+ "/rest/sql"
+ ],
+ [
+ "2022-06-29T05:52:16.603Z",
+ 2,
+ "LAPTOP-NNKFTLTG:6041",
+ 401,
+ "172.23.208.1",
+ "POST",
+ "/rest/sql"
+ ]
+ ],
+ "rows": 4
+}
+```
+
+Description:
+
+- code: `int` 0 indicates success.
+- column_meta: (`[][3]any`) Column information. Each column is described with three values: column name (string), column type (string), and type length (int).
+- rows: (`int`) The number of rows returned.
+- data: (`[][]any`)
+
+The following types may be returned:
+
+- "NULL"
+- "BOOL"
+- "TINYINT"
+- "SMALLINT"
+- "INT"
+- "BIGINT"
+- "FLOAT"
+- "DOUBLE"
+- "VARCHAR"
+- "TIMESTAMP"
+- "NCHAR"
+- "TINYINT UNSIGNED"
+- "SMALLINT UNSIGNED"
+- "INT UNSIGNED"
+- "BIGINT UNSIGNED"
+- "JSON"
+
+#### Errors
+
+Example:
+
+```json
+{
+ "code": 9728,
+ "desc": "syntax error near \"1\""
}
```
Description:
-- status: tells you whethre the operation result is success or failure.
-- head: the definition of the table, or just one column "affected_rows" if no result set is returned. (As of version 2.0.17.0, it is recommended not to rely on the head return value to determine the data column type but rather use column_meta. In later versions, the head item may be removed from the return value.)
-- column_meta: this item is added to the return value to indicate the data type of each column in the data with version 2.0.17.0 and later versions. Each column is described by three values: column name, column type, and type length. For example, `["current",6,4]` means that the column name is "current", the column type is 6, which is the float type, and the type length is 4, which is the float type with 4 bytes. If the column type is binary or nchar, the type length indicates the maximum length of content stored in the column, not the length of the specific data in this return value. When the column type is nchar, the type length indicates the number of Unicode characters that can be saved, not bytes.
-- data: The exact data returned, presented row by row, or just [[affected_rows]] if no result set is returned. The order of the data columns in each row of data is the same as that of the data columns described in column_meta.
-- rows: Indicates how many rows of data there are.
-
-The column types in column_meta are described as follows:
-
-- 1:BOOL
-- 2:TINYINT
-- 3:SMALLINT
-- 4:INT
-- 5:BIGINT
-- 6:FLOAT
-- 7:DOUBLE
-- 8:BINARY
-- 9:TIMESTAMP
-- 10:NCHAR
+- code: (`int`) Error code.
+- desc: (`string`): Error code description.
## Custom Authorization Code
@@ -165,11 +253,9 @@ curl http://:/rest/login//
Where `fqdn` is the FQDN or IP address of the TDengine database. `port` is the port number of the TDengine service. `username` is the database username. `password` is the database password. The return value is in `JSON` format, and the meaning of each field is as follows.
-- status: flag bit of the request result
-
-- code: return value code
-
-- desc: authorization code
+- status: flag bit of the request result.
+- code: return value code.
+- desc: authorization code.
Example of getting authorization code.
@@ -187,7 +273,7 @@ Response body:
}
```
-## For example
+## Usage examples
- query all records from table d1001 of database demo
@@ -199,19 +285,44 @@ Response body:
```json
{
- "status": "succ",
- "head": ["ts", "current", "voltage", "phase"],
- "column_meta": [
- ["ts", 9, 8],
- ["current", 6, 4],
- ["voltage", 4, 4],
- ["phase", 6, 4]
- ],
- "data": [
- ["2018-10-03 14:38:05.000", 10.3, 219, 0.31],
- ["2018-10-03 14:38:15.000", 12.6, 218, 0.33]
- ],
- "rows": 2
+ "code": 0,
+ "column_meta": [
+ [
+ "ts",
+ "TIMESTAMP",
+ 8
+ ],
+ [
+ "current",
+ "FLOAT",
+ 4
+ ],
+ [
+ "voltage",
+ "INT",
+ 4
+ ],
+ [
+ "phase",
+ "FLOAT",
+ 4
+ ]
+ ],
+ "data": [
+ [
+ "2022-07-30T06:44:40.32Z",
+ 10.3,
+ 219,
+ 0.31
+ ],
+ [
+ "2022-07-30T06:44:41.32Z",
+ 12.6,
+ 218,
+ 0.33
+ ]
+ ],
+ "rows": 2
}
```
@@ -225,83 +336,23 @@ Response body:
```json
{
- "status": "succ",
- "head": ["affected_rows"],
- "column_meta": [["affected_rows", 4, 4]],
- "data": [[1]],
- "rows": 1
+ "code": 0,
+ "column_meta": [
+ [
+ "affected_rows",
+ "INT",
+ 4
+ ]
+ ],
+ "data": [
+ [
+ 0
+ ]
+ ],
+ "rows": 1
}
```
-## Other Uses
-
-### Unix timestamps for result sets
-
-When the HTTP request URL uses `/rest/sqlt`, the returned result set's timestamp value will be in Unix timestamp format, for example:
-
-```bash
-curl -L -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -d "select * from demo.d1001" 192.168.0.1:6041/rest/sqlt
-```
-
-Response body:
-
-```json
-{
- "status": "succ",
- "head": ["ts", "current", "voltage", "phase"],
- "column_meta": [
- ["ts", 9, 8],
- ["current", 6, 4],
- ["voltage", 4, 4],
- ["phase", 6, 4]
- ],
- "data": [
- [1538548685000, 10.3, 219, 0.31],
- [1538548695000, 12.6, 218, 0.33]
- ],
- "rows": 2
-}
-```
-
-### UTC format for the result set
+## Reference
-When the HTTP request URL uses `/rest/sqlutc`, the timestamp of the returned result set will be expressed as a UTC format, for example:
-
-```bash
- curl -L -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -d "select * from demo.t1" 192.168.0.1:6041/rest/sqlutc
-```
-
-Response body:
-
-```json
-{
- "status": "succ",
- "head": ["ts", "current", "voltage", "phase"],
- "column_meta": [
- ["ts", 9, 8],
- ["current", 6, 4],
- ["voltage", 4, 4],
- ["phase", 6, 4]
- ],
- "data": [
- ["2018-10-03T14:38:05.000+0800", 10.3, 219, 0.31],
- ["2018-10-03T14:38:15.000+0800", 12.6, 218, 0.33]
- ],
- "rows": 2
-}
-```
-
-## Important configuration items
-
-Only some configuration parameters related to the RESTful interface are listed below. Please see the description in the configuration file for other system parameters.
-
-- The port number of the external RESTful service is bound to 6041 by default (the actual value is serverPort + 11, so it can be changed by modifying the setting of the serverPort parameter).
-- httpMaxThreads: the number of threads to start, default is 2 (the default value is rounded down to half of the CPU cores with version 2.0.17.0 and later versions).
-- restfulRowLimit: the maximum number of result sets (in JSON format) to return. The default value is 10240.
-- httpEnableCompress: whether to support compression, the default is not supported. Currently, TDengine only supports the gzip compression format.
-- httpDebugFlag: logging switch, default is 131. 131: error and alarm messages only, 135: debug messages, 143: very detailed debug messages.
-- httpDbNameMandatory: users must specify the default database name in the RESTful URL. The default is 0, which turns off this check. If set to 1, users must put a default database name in every RESTful URL. Otherwise, it will return an execution error and reject this SQL statement, regardless of whether the SQL statement executed at this time requires a specified database.
-
-:::note
-If you are using the REST API provided by taosd, you should write the above configuration in taosd's configuration file taos.cfg. If you use the REST API of taosAdapter, you need to refer to taosAdapter [corresponding configuration method](/reference/taosadapter/).
-:::
+[taosAdapter](/reference/taosadapter/)
diff --git a/docs/en/14-reference/03-connector/cpp.mdx b/docs/en/14-reference/03-connector/03-cpp.mdx
similarity index 78%
rename from docs/en/14-reference/03-connector/cpp.mdx
rename to docs/en/14-reference/03-connector/03-cpp.mdx
index e0cdf2bf2ce7eed06cacaf71a5b9baf56a3aee2b..02d7df48db540a3eb44379ada7332b2838924212 100644
--- a/docs/en/14-reference/03-connector/cpp.mdx
+++ b/docs/en/14-reference/03-connector/03-cpp.mdx
@@ -1,10 +1,9 @@
---
-sidebar_position: 1
sidebar_label: C/C++
title: C/C++ Connector
---
-C/C++ developers can use TDengine's client driver and the C/C++ connector, to develop their applications to connect to TDengine clusters for data writing, querying, and other functions. To use the C/C++ connector you must include the TDengine header file _taos.h_, which lists the function prototypes of the provided APIs. The application also needs to link to the corresponding dynamic libraries on the platform where it is located.
+C/C++ developers can use TDengine's client driver and the C/C++ connector, to develop their applications to connect to TDengine clusters for data writing, querying, and other functions. To use the C/C++ connector you must include the TDengine header file _taos.h_, which lists the function prototypes of the provided APIs. The application also needs to link to the corresponding dynamic libraries on the platform where it is located.
```c
#include
@@ -12,8 +11,8 @@ C/C++ developers can use TDengine's client driver and the C/C++ connector, to de
After TDengine server or client installation, `taos.h` is located at
-- Linux: `/usr/local/taos/include`
-- Windows: `C:\TDengine\include`
+- Linux:`/usr/local/taos/include`
+- Windows:`C:\TDengine\include`
The dynamic libraries for the TDengine client driver are located in.
@@ -28,7 +27,7 @@ Please refer to [list of supported platforms](/reference/connector#supported-pla
The version number of the TDengine client driver and the version number of the TDengine server should be same. A lower version of the client driver is compatible with a higher version of the server, if the first three version numbers are the same (i.e., only the fourth version number is different). For e.g. if the client version is x.y.z.1 and the server version is x.y.z.2 the client and server are compatible. But in general we do not recommend using a lower client version with a newer server version. It is also strongly discouraged to use a higher version of the client driver to access a lower version of the TDengine server.
-## Installation steps
+## Installation Steps
Please refer to the [Installation Steps](/reference/connector#installation-steps) for TDengine client driver installation
@@ -45,7 +44,7 @@ The following is sample code for establishing a connection, which omits the quer
exit(1);
}
- /* put your code here for query and writing */
+ /* put your code here for read and write */
taos_close(taos);
taos_cleanup();
@@ -60,7 +59,7 @@ In the above example code, `taos_connect()` establishes a connection to port 603
:::
-## Example program
+## Sample program
This section shows sample code for standard access methods to TDengine clusters using the client driver.
@@ -125,7 +124,7 @@ You can find it in the installation directory under the `examples/c` path. This
:::
-## API reference
+## API Reference
The following describes the basic API, synchronous API, asynchronous API, subscription API, and schemaless write API of TDengine client driver, respectively.
@@ -141,10 +140,9 @@ The base API is used to do things like create database connections and provide a
Cleans up the runtime environment and should be called before the application exits.
-- ` int taos_options(TSDB_OPTION option, const void * arg, ...) `
+- `int taos_options(TSDB_OPTION option, const void * arg, ...)`
- Set client options, currently supports region setting (`TSDB_OPTION_LOCALE`), character set
-(`TSDB_OPTION_CHARSET`), time zone (`TSDB_OPTION_TIMEZONE`), configuration file path (`TSDB_OPTION_CONFIGDIR`). The region setting, character set, and time zone default to the current settings of the operating system.
+ Set client options, currently supports region setting (`TSDB_OPTION_LOCALE`), character set (`TSDB_OPTION_CHARSET`), time zone (`TSDB_OPTION_TIMEZONE`), configuration file path (`TSDB_OPTION_CONFIGDIR`). The region setting, character set, and time zone default to the current settings of the operating system.
- `char *taos_get_client_info()`
@@ -157,7 +155,7 @@ The base API is used to do things like create database connections and provide a
- host: FQDN of any node in the TDengine cluster
- user: user name
- pass: password
- - db: the database name. Even if the user does not provide this, the connection will still work correctly. The user can create a new database through this connection. If the user provides the database name, it means that the database has already been created and the connection can be used for regular operations on the database.
+ - db: the database name. Even if the user does not provide this, the connection will still work correctly. The user can create a new database through this connection. If the user provides the database name, it means that the database has already been created and the connection can be used for regular operations on the database.
- port: the port the taosd program is listening on
NULL indicates a failure. The application needs to save the returned parameters for subsequent use.
@@ -171,7 +169,7 @@ The base API is used to do things like create database connections and provide a
Get server-side version information.
-- ` int taos_select_db(TAOS *taos, const char *db)`
+- `int taos_select_db(TAOS *taos, const char *db)`
Set the current default database to `db`.
@@ -211,15 +209,15 @@ The APIs described in this subsection are all synchronous interfaces. After bein
Get the number of rows affected by the executed SQL statement.
-- ` TAOS_FIELD *taos_fetch_fields(TAOS_RES *res)`
+- `TAOS_FIELD *taos_fetch_fields(TAOS_RES *res)`
Gets the properties of each column of the query result set (column name, column data type, column length), used in conjunction with `taos_num_fields()` to parse a tuple (one row) of data returned by `taos_fetch_row()`. The structure of `TAOS_FIELD` is as follows.
```c
typedef struct taosField {
- char name[65]; // column name
- uint8_t type; // data type
- int16_t bytes; // length, in bytes
+ char name[65]; // column name
+ uint8_t type; // data type
+ int16_t bytes; // length, in bytes
} TAOS_FIELD;
```
@@ -227,7 +225,7 @@ typedef struct taosField {
Stops the execution of the current query.
-- ` void taos_free_result(TAOS_RES *res)`
+- `void taos_free_result(TAOS_RES *res)`
Frees the query result set and the associated resources. Be sure to call this API to free the resources after the query is completed. Failing to call this, may lead to a memory leak in the application. However, note that the application will crash if you call a function like `taos_consume()` to get the query results after freeing the resources.
@@ -235,7 +233,7 @@ typedef struct taosField {
Get the reason for the failure of the last API call. The return value is an error message identified by a string.
-- 'int taos_errno(TAOS_RES *res)`
+- `int taos_errno(TAOS_RES *res)`
Get the reason for the last API call failure. The return value is the error code.
@@ -294,7 +292,7 @@ The specific functions related to the interface are as follows (see also the [pr
Creates a TAOS_STMT object for subsequent calls.
-- ` int taos_stmt_prepare(TAOS_STMT *stmt, const char *sql, unsigned long length)`
+- `int taos_stmt_prepare(TAOS_STMT *stmt, const char *sql, unsigned long length)`
Parse a SQL command, and bind the parsed result and parameter information to `stmt`. If the parameter length is greater than 0, use this parameter as the length of the SQL command. If it is equal to 0, the length of the SQL command will be determined automatically.
@@ -332,16 +330,16 @@ The specific functions related to the interface are as follows (see also the [pr
```c
typedef struct TAOS_MULTI_BIND {
- int buffer_type;
- void * buffer;
- uintptr_t buffer_length;
- uintptr_t * length;
- char * is_null;
- int num; // the number of columns
+ int buffer_type;
+ void * buffer;
+ uintptr_t buffer_length;
+ uintptr_t * length;
+ char * is_null;
+ int num; // the number of columns
} TAOS_MULTI_BIND;
```
-- ` int taos_stmt_add_batch(TAOS_STMT *stmt)`
+- `int taos_stmt_add_batch(TAOS_STMT *stmt)`
Adds the currently bound parameter to the batch. After calling this function, you can call `taos_stmt_bind_param()` or `taos_stmt_bind_param_batch()` again to bind a new parameter. Note that this function only supports INSERT/IMPORT statements. Other SQL command such as SELECT will return an error.
@@ -349,7 +347,7 @@ The specific functions related to the interface are as follows (see also the [pr
Execute the prepared statement. Currently, a statement can only be executed once.
-- ` TAOS_RES* taos_stmt_use_result(TAOS_STMT *stmt)`
+- `TAOS_RES* taos_stmt_use_result(TAOS_STMT *stmt)`
Gets the result set of a statement. Use the result set in the same way as in the non-parametric call. When finished, `taos_free_result()` should be called on this result set to free resources.
@@ -357,7 +355,7 @@ The specific functions related to the interface are as follows (see also the [pr
Finish execution and release all resources.
-- ` char * taos_stmt_errstr(TAOS_STMT *stmt)`
+- `char * taos_stmt_errstr(TAOS_STMT *stmt)`
(Available in 2.1.3.0 and later versions)
Used to get error information if other STMT APIs return errors (return error codes or null pointers).
@@ -405,46 +403,3 @@ In addition to writing data using the SQL method or the parameter binding API, w
**Supported Versions**
This feature interface is supported from version 2.3.0.0.
-
-### Subscription and Consumption API
-
-The Subscription API currently supports subscribing to one or more tables and continuously fetching the latest data written to them by polling periodically.
-
-- `TAOS_SUB *taos_subscribe(TAOS* taos, int restart, const char* topic, const char *sql, TAOS_SUBSCRIBE_CALLBACK fp, void *param, int interval)`
-
- This function is responsible for starting the subscription service, returning the subscription object on success and `NULL` on failure, with the following parameters.
-
- - taos: the database connection that has been established.
- - restart: if the subscription already exists, whether to restart or continue the previous subscription.
- - topic: the topic of the subscription (i.e., the name). This parameter is the unique identifier of the subscription.
- - sql: the query statement of the subscription which can only be a _select_ statement. Only the original data should be queried, and data can only be queried in temporal order.
- - fp: the callback function when the query result is received only used when called asynchronously. This parameter should be passed `NULL` when called synchronously. The function prototype is described below.
- - param: additional parameter when calling the callback function. The system API will pass it to the callback function as is, without any processing.
- - interval: polling period in milliseconds. The callback function will be called periodically according to this parameter when called asynchronously. The interval should not be too small to avoid impact on system performance when called synchronously. If the interval between two calls to `taos_consume()` is less than this period, the API will block until the interval exceeds this period.
-
-- ` typedef void (*TAOS_SUBSCRIBE_CALLBACK)(TAOS_SUB* tsub, TAOS_RES *res, void* param, int code)`
-
- The prototype of the callback function in asynchronous mode with the following parameters
-
- - tsub: subscription object
- - res: query result set, note that there may be no records in the result set
- - param: additional parameters provided by the client program when calling `taos_subscribe()`
- - code: error code
-
- :::note
- The callback function should not take too long to process, especially if the returned result set has a lot of data. Otherwise, it may lead to an abnormal state, such as client blocking. If you must perform complex calculations, we recommend handling them in a separate thread.
-
- :::
-
-- `TAOS_RES *taos_consume(TAOS_SUB *tsub)`
-
- In synchronous mode, this function is used to fetch the results of a subscription. The user application places it in a loop. If the interval between two calls to `taos_consume()` is less than the polling period of the subscription, the API will block until the interval exceeds this period. If a new record arrives in the database, the API returns that latest record. Otherwise, it returns an empty result set with no records. If the return value is `NULL`, there is a system error. This API should not be called by user programs in asynchronous mode.
-
- :::note
- After calling `taos_consume()`, the user application should make sure to call `taos_fetch_row()` or `taos_fetch_block()` to process the subscription results as soon as possible. Otherwise, the server-side will keep caching the query result data waiting to be read by the client, which in extreme cases will cause the server side to run out of memory and affect the stability of the service.
-
- :::
-
-- `void taos_unsubscribe(TAOS_SUB *tsub, int keepProgress)`
-
- Unsubscribe. If the parameter `keepProgress` is not 0, the API will keep the progress information of the subscription, and subsequent calls to `taos_subscribe()` will continue based on this progress; otherwise, the progress information will be deleted, and subsequent readings will have to be restarted.
diff --git a/docs/en/14-reference/03-connector/java.mdx b/docs/en/14-reference/03-connector/04-java.mdx
similarity index 75%
rename from docs/en/14-reference/03-connector/java.mdx
rename to docs/en/14-reference/03-connector/04-java.mdx
index 22f99bb9ae8fa669155ba8ac7cec1ad2c609cb32..129d90ea85d9455c1ae460b3799b5253dd3a49fc 100644
--- a/docs/en/14-reference/03-connector/java.mdx
+++ b/docs/en/14-reference/03-connector/04-java.mdx
@@ -1,19 +1,18 @@
---
toc_max_heading_level: 4
-sidebar_position: 2
sidebar_label: Java
title: TDengine Java Connector
-description: TDengine Java based on JDBC API and provide both native and REST connections
+description: The TDengine Java Connector is implemented on the standard JDBC API and provides native and REST connectors.
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
-'taos-jdbcdriver' is TDengine's official Java language connector, which allows Java developers to develop applications that access the TDengine database. 'taos-jdbcdriver' implements the interface of the JDBC driver standard and provides two forms of connectors. One is to connect to a TDengine instance natively through the TDengine client driver (taosc), which supports functions including data writing, querying, subscription, schemaless writing, and bind interface. And the other is to connect to a TDengine instance through the REST interface provided by taosAdapter (2.4.0.0 and later). The implementation of the REST connection and those of the native connections have slight differences in features.
+`taos-jdbcdriver` is the official Java connector for TDengine. Java developers can use it to develop applications that access data in TDengine. `taos-jdbcdriver` implements standard JDBC driver interfaces and two connection methods: One is **native connection**, which connects to TDengine instances natively through the TDengine client driver (taosc), supporting data writing, querying, subscriptions, schemaless writing, and bind interface. The second is **REST connection** which is implemented through taosAdapter. The set of features implemented by the REST connection differs slightly from those implemented by the native connection.
-
+
-The preceding diagram shows two ways for a Java app to access TDengine via connector:
+The preceding figure shows the two ways in which a Java application can access TDengine.
- JDBC native connection: Java applications use TSDBDriver on physical node 1 (pnode1) to call client-driven directly (`libtaos.so` or `taos.dll`) APIs to send writing and query requests to taosd instances located on physical node 2 (pnode2).
- JDBC REST connection: The Java application encapsulates the SQL as a REST request via RestfulDriver, sends it to the REST server (taosAdapter) on physical node 2. taosAdapter forwards the request to TDengine server and returns the result.
@@ -30,34 +29,34 @@ TDengine's JDBC driver implementation is as consistent as possible with the rela
## Supported platforms
-Native connection supports the same platform as TDengine client-driven support.
+Native connections are supported on the same platforms as the TDengine client driver.
REST connection supports all platforms that can run Java.
## Version support
-Please refer to [Version Support List](/reference/connector#version-support).
+Please refer to [version support list](/reference/connector#version-support)
## TDengine DataType vs. Java DataType
TDengine currently supports timestamp, number, character, Boolean type, and the corresponding type conversion with Java is as follows:
-| TDengine DataType | JDBCType (driver version < 2.0.24) | JDBCType (driver version > = 2.0.24) |
-| ----------------- | ---------------------------------- | ------------------------------------ |
-| TIMESTAMP | java.lang.Long | java.sql.Timestamp |
-| INT | java.lang.Integer | java.lang.Integer |
-| BIGINT | java.lang.Long | java.lang.Long |
-| FLOAT | java.lang.Float | java.lang.Float |
-| DOUBLE | java.lang.Double | java.lang.Double |
-| SMALLINT | java.lang.Short | java.lang.Short |
-| TINYINT | java.lang.Byte | java.lang.Byte |
-| BOOL | java.lang.Boolean | java.lang.Boolean |
-| BINARY | java.lang.String | byte array |
-| NCHAR | java.lang.String | java.lang.String |
-| JSON | - | java.lang.String |
+| TDengine DataType | JDBCType |
+| ----------------- | ---------------------------------- |
+| TIMESTAMP | java.sql.Timestamp |
+| INT | java.lang.Integer |
+| BIGINT | java.lang.Long |
+| FLOAT | java.lang.Float |
+| DOUBLE | java.lang.Double |
+| SMALLINT | java.lang.Short |
+| TINYINT | java.lang.Byte |
+| BOOL | java.lang.Boolean |
+| BINARY | byte array |
+| NCHAR | java.lang.String |
+| JSON | java.lang.String |
**Note**: Only TAG supports JSON types
-## Installation steps
+## Installation Steps
### Pre-installation preparation
@@ -71,17 +70,19 @@ Before using Java Connector to connect to the database, the following conditions
+taos-jdbcdriver has been published on the [Sonatype Repository](https://search.maven.org/artifact/com.taosdata.jdbc/taos-jdbcdriver) and synchronized to other major repositories.
+
- [sonatype](https://search.maven.org/artifact/com.taosdata.jdbc/taos-jdbcdriver)
- [mvnrepository](https://mvnrepository.com/artifact/com.taosdata.jdbc/taos-jdbcdriver)
- [maven.aliyun](https://maven.aliyun.com/mvn/search)
Add following dependency in the `pom.xml` file of your Maven project:
-```xml
+```xml-dtd
com.taosdata.jdbctaos-jdbcdriver
- 2.0.**
+ 3.0.0
```
@@ -90,26 +91,26 @@ Add following dependency in the `pom.xml` file of your Maven project:
You can build Java connector from source code after cloning the TDengine project:
-```
-git clone https://github.com/taosdata/taos-connector-jdbc.git --branch 2.0
+```shell
+git clone https://github.com/taosdata/taos-connector-jdbc.git
cd taos-connector-jdbc
mvn clean install -Dmaven.test.skip=true
```
-After compilation, a jar package named taos-jdbcdriver-2.0.XX-dist.jar is generated in the target directory, and the compiled jar file is automatically placed in the local Maven repository.
+After you have compiled taos-jdbcdriver, the `taos-jdbcdriver-3.0.*-dist.jar` file is created in the target directory. The compiled JAR file is automatically stored in your local Maven repository.
-## Establish a connection
+## Establishing a connection
TDengine's JDBC URL specification format is:
-`jdbc:[TAOS| TAOS-RS]://[host_name]:[port]/[database_name]? [user={user}|&password={password}|&charset={charset}|&cfgdir={config_dir}|&locale={locale}|&timezone={timezone}]`
+`jdbc:[TAOS|TAOS-RS]://[host_name]:[port]/[database_name]?[user={user}|&password={password}|&charset={charset}|&cfgdir={config_dir}|&locale={locale}|&timezone={timezone}]`
For establishing connections, native connections differ slightly from REST connections.
-
+
```java
Class.forName("com.taosdata.jdbc.TSDBDriver");
@@ -129,55 +130,50 @@ The configuration parameters in the URL are as follows:
- charset: The character set used by the client, the default value is the system character set.
- locale: Client locale, by default, use the system's current locale.
- timezone: The time zone used by the client, the default value is the system's current time zone.
-- batchfetch: true: pulls result sets in batches when executing queries; false: pulls result sets row by row. The default value is: false. Enabling batch pulling and obtaining a batch of data can improve query performance when the query data volume is large.
+- batchfetch: true: pulls result sets in batches when executing queries; false: pulls result sets row by row. The default value is true. Enabling batch pulling and obtaining a batch of data can improve query performance when the query data volume is large.
- batchErrorIgnore:true: When executing statement executeBatch, if there is a SQL execution failure in the middle, the following SQL will continue to be executed. false: No more statements after the failed SQL are executed. The default value is: false.
-For more information about JDBC native connections, see [Video Tutorial](https://www.taosdata.com/blog/2020/11/11/1955.html).
-
**Connect using the TDengine client-driven configuration file **
When you use a JDBC native connection to connect to a TDengine cluster, you can use the TDengine client driver configuration file to specify parameters such as `firstEp` and `secondEp` of the cluster in the configuration file as below:
1. Do not specify hostname and port in Java applications.
- ```java
- public Connection getConn() throws Exception{
- Class.forName("com.taosdata.jdbc.TSDBDriver");
- String jdbcUrl = "jdbc:TAOS://:/test?user=root&password=taosdata";
- Properties connProps = new Properties();
- connProps.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8");
- connProps.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8");
- connProps.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8");
- Connection conn = DriverManager.getConnection(jdbcUrl, connProps);
- return conn;
- }
- ```
+```java
+public Connection getConn() throws Exception{
+ Class.forName("com.taosdata.jdbc.TSDBDriver");
+ String jdbcUrl = "jdbc:TAOS://:/test?user=root&password=taosdata";
+ Properties connProps = new Properties();
+ connProps.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8");
+ connProps.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8");
+ connProps.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8");
+ Connection conn = DriverManager.getConnection(jdbcUrl, connProps);
+ return conn;
+}
+```
2. specify the firstEp and the secondEp in the configuration file taos.cfg
- ```shell
- # first fully qualified domain name (FQDN) for TDengine system
- firstEp cluster_node1:6030
+```shell
+# first fully qualified domain name (FQDN) for TDengine system
+firstEp cluster_node1:6030
- # second fully qualified domain name (FQDN) for TDengine system, for cluster only
- secondEp cluster_node2:6030
+# second fully qualified domain name (FQDN) for TDengine system, for cluster only
+secondEp cluster_node2:6030
- # default system charset
- # charset UTF-8
+# default system charset
+# charset UTF-8
- # system locale
- # locale en_US.UTF-8
- ```
+# system locale
+# locale en_US.UTF-8
+```
In the above example, JDBC uses the client's configuration file to establish a connection to a hostname `cluster_node1`, port 6030, and a database named `test`. When the firstEp node in the cluster fails, JDBC attempts to connect to the cluster using secondEp.
In TDengine, as long as one node in firstEp and secondEp is valid, the connection to the cluster can be established normally.
-:::note
The configuration file here refers to the configuration file on the machine where the application that calls the JDBC Connector is located, the default path is `/etc/taos/taos.cfg` on Linux, and the default path is `C://TDengine/cfg/taos.cfg` on Windows.
-:::
-
@@ -195,11 +191,11 @@ There is no dependency on the client driver when Using a JDBC REST connection. C
2. jdbcUrl starting with "jdbc:TAOS-RS://".
3. use 6041 as the connection port.
-The configuration parameters in the URL are as follows.
+The configuration parameters in the URL are as follows:
-- user: Login TDengine user name, default value 'root'.
-- password: user login password, default value 'taosdata'.
-- batchfetch: true: pull the result set in batch when executing the query; false: pull the result set row by row. The default value is false. batchfetch uses HTTP for data transfer. The JDBC REST connection supports bulk data pulling function in taos-jdbcdriver-2.0.38 and TDengine 2.4.0.12 and later versions. taos-jdbcdriver and TDengine transfer data via WebSocket connection. Compared with HTTP, WebSocket enables JDBC REST connection to support large data volume querying and improve query performance.
+- user: Log in to the TDengine username. The default value is 'root'.
+- password: User login password, the default value is 'taosdata'.
+- batchfetch: true: pulls result sets in batches when executing queries; false: pulls result sets row by row. The default value is: false. batchfetch uses HTTP for data transfer. JDBC REST supports batch pulls. taos-jdbcdriver and TDengine transfer data via WebSocket connection. Compared with HTTP, WebSocket enables JDBC REST connection to support large data volume querying and improve query performance.
- charset: specify the charset to parse the string, this parameter is valid only when set batchfetch to true.
- batchErrorIgnore: true: when executing executeBatch of Statement, if one SQL execution fails in the middle, continue to execute the following SQL. false: no longer execute any statement after the failed SQL. The default value is: false.
- httpConnectTimeout: REST connection timeout in milliseconds, the default value is 5000 ms.
@@ -211,13 +207,13 @@ The configuration parameters in the URL are as follows.
:::note
-- Unlike the native connection method, the REST interface is stateless. When using the JDBC REST connection, you need to specify the database name of the table and super table in SQL. For example.
+- Unlike the native connection method, the REST interface is stateless. When using the JDBC REST connection, you need to specify the database name of the table and super table in SQL. For example:
```sql
INSERT INTO test.t1 USING test.weather (ts, temperature) TAGS('California.SanFrancisco') VALUES(now, 24.6);
```
-- Starting from taos-jdbcdriver-2.0.36 and TDengine 2.2.0.0, if dbname is specified in the URL, JDBC REST connections will use `/rest/sql/dbname` as the URL for REST requests by default, and there is no need to specify dbname in SQL. For example, if the URL is `jdbc:TAOS-RS://127.0.0.1:6041/test`, then the SQL can be executed: insert into test using weather(ts, temperature) tags('California.SanFrancisco') values(now, 24.6);
+- If the dbname is specified in the URL, the JDBC REST connection uses /rest/sql/dbname as the default URL for RESTful requests. In this case, it is not necessary to specify the dbname in SQL. For example, if the URL is `jdbc:TAOS-RS://127.0.0.1:6041/test`, then the SQL can be executed: insert into test using weather(ts, temperature) tags('California.SanFrancisco') values(now, 24.6);
:::
@@ -228,10 +224,10 @@ INSERT INTO test.t1 USING test.weather (ts, temperature) TAGS('California.SanFra
In addition to getting the connection from the specified URL, you can use Properties to specify parameters when the connection is established.
-**Note**:
+Note:
- The client parameter set in the application is process-level. If you want to update the parameters of the client, you need to restart the application. This is because the client parameter is a global parameter that takes effect only the first time the application is set.
-- The following sample code is based on taos-jdbcdriver-2.0.36.
+- The following sample code is based on taos-jdbcdriver-3.0.0.
```java
public Connection getConn() throws Exception{
@@ -257,14 +253,14 @@ public Connection getRestConn() throws Exception{
}
```
-In the above example, a connection is established to `taosdemo.com`, port is 6030/6041, and database named `test`. The connection specifies the user name as `root` and the password as `taosdata` in the URL and specifies the character set, language environment, time zone, and whether to enable bulk fetching in the connProps.
+In the above example, a connection is established to `taosdemo.com`, port is 6030/6041, and database named `test`. The connection specifies the user name as `root` and the password as `taosdata` in the URL and specifies the character set, language environment, time zone, and whether to enable bulk fetching in the connProps.The url specifies the user name as `root` and the password as `taosdata`.
The configuration parameters in properties are as follows.
- TSDBDriver.PROPERTY_KEY_USER: login TDengine user name, default value 'root'.
- TSDBDriver.PROPERTY_KEY_PASSWORD: user login password, default value 'taosdata'.
- TSDBDriver.PROPERTY_KEY_BATCH_LOAD: true: pull the result set in batch when executing query; false: pull the result set row by row. The default value is: false.
-- TSDBDriver.PROPERTY_KEY_BATCH_ERROR_IGNORE: true: when executing executeBatch of Statement, if there is a SQL execution failure in the middle, continue to execute the following sq. false: no longer execute any statement after the failed SQL. The default value is: false.
+- TSDBDriver.PROPERTY_KEY_BATCH_ERROR_IGNORE: true: when executing executeBatch of Statement, if there is a SQL execution failure in the middle, continue to execute the following sql. false: no longer execute any statement after the failed SQL. The default value is: false.
- TSDBDriver.PROPERTY_KEY_CONFIG_DIR: only works when using JDBC native connection. Client configuration file directory path, default value `/etc/taos` on Linux OS, default value `C:/TDengine/cfg` on Windows OS.
- TSDBDriver.PROPERTY_KEY_CHARSET: In the character set used by the client, the default value is the system character set.
- TSDBDriver.PROPERTY_KEY_LOCALE: this only takes effect when using JDBC native connection. Client language environment, the default value is system current locale.
@@ -272,7 +268,7 @@ The configuration parameters in properties are as follows.
- TSDBDriver.HTTP_CONNECT_TIMEOUT: REST connection timeout in milliseconds, the default value is 5000 ms. It only takes effect when using JDBC REST connection.
- TSDBDriver.HTTP_SOCKET_TIMEOUT: socket timeout in milliseconds, the default value is 5000 ms. It only takes effect when using JDBC REST connection and batchfetch is false.
- TSDBDriver.PROPERTY_KEY_MESSAGE_WAIT_TIMEOUT: message transmission timeout in milliseconds, the default value is 3000 ms. It only takes effect when using JDBC REST connection and batchfetch is true.
-- TSDBDriver.PROPERTY_KEY_USE_SSL: connecting Securely Using SSL. true: using SSL conneciton, false: not using SSL connection. It only takes effect when using using JDBC REST connection.
+- TSDBDriver.PROPERTY_KEY_USE_SSL: connecting Securely Using SSL. true: using SSL conneciton, false: not using SSL connection. It only takes effect when using JDBC REST connection.
For JDBC native connections, you can specify other parameters, such as log level, SQL length, etc., by specifying URL and Properties. For more detailed configuration, please refer to [Client Configuration](/reference/config/#Client-Only).
### Priority of configuration parameters
@@ -304,7 +300,7 @@ stmt.executeUpdate("create table if not exists tb (ts timestamp, temperature int
> **Note**: If you do not use `use db` to specify the database, all subsequent operations on the table need to add the database name as a prefix, such as db.tb.
-### Insert data
+### 插入数据
```java
// insert data
@@ -319,7 +315,7 @@ System.out.println("insert " + affectedRows + " rows.");
### Querying data
```java
-// query data
+// insert data
ResultSet resultSet = stmt.executeQuery("select * from tb");
Timestamp ts = null;
@@ -354,25 +350,21 @@ try (Statement statement = connection.createStatement()) {
}
```
-There are three types of error codes that the JDBC connector can report:
-
-- Error code of the JDBC driver itself (error code between 0x2301 and 0x2350)
-- Error code of the native connection method (error code between 0x2351 and 0x2400)
-- Error code of other TDengine function modules
+There are three types of error codes that the JDBC connector can report: - Error code of the JDBC driver itself (error code between 0x2301 and 0x2350), - Error code of the native connection method (error code between 0x2351 and 0x2400), and - Error code of other TDengine function modules.
For specific error codes, please refer to.
- [TDengine Java Connector](https://github.com/taosdata/taos-connector-jdbc/blob/main/src/main/java/com/taosdata/jdbc/TSDBErrorNumbers.java)
-- [TDengine_ERROR_CODE](https://github.com/taosdata/TDengine/blob/develop/src/inc/taoserror.h)
+
### Writing data via parameter binding
-TDengine's native JDBC connection implementation has significantly improved its support for data writing (INSERT) scenarios via bind interface with version 2.1.2.0 and later versions. Writing data in this way avoids the resource consumption of SQL syntax parsing, resulting in significant write performance improvements in many cases.
+TDengine has significantly improved the bind APIs to support data writing (INSERT) scenarios. Writing data in this way avoids the resource consumption of SQL syntax parsing, resulting in significant write performance improvements in many cases.
-**Note**.
+**Note:**
- JDBC REST connections do not currently support bind interface
-- The following sample code is based on taos-jdbcdriver-2.0.36
+- The following sample code is based on taos-jdbcdriver-3.0.0
- The setString method should be called for binary type data, and the setNString method should be called for nchar type data
- both setString and setNString require the user to declare the width of the corresponding column in the size parameter of the table definition
@@ -577,7 +569,7 @@ public class ParameterBindingDemo {
// set table name
pstmt.setTableName("t5_" + i);
// set tags
- pstmt.setTagNString(0, "California-abc");
+ pstmt.setTagNString(0, "California.SanFrancisco");
// set columns
ArrayList tsList = new ArrayList<>();
@@ -588,7 +580,7 @@ public class ParameterBindingDemo {
ArrayList f1List = new ArrayList<>();
for (int j = 0; j < numOfRow; j++) {
- f1List.add("California-abc");
+ f1List.add("California.LosAngeles");
}
pstmt.setNString(1, f1List, BINARY_COLUMN_SIZE);
@@ -635,12 +627,12 @@ public void setNString(int columnIndex, ArrayList list, int size) throws
### Schemaless Writing
-Starting with version 2.2.0.0, TDengine has added the ability to perform schemaless writing. It is compatible with InfluxDB's Line Protocol, OpenTSDB's telnet line protocol, and OpenTSDB's JSON format protocol. See [schemaless writing](/reference/schemaless/) for details.
+TDengine supports schemaless writing. It is compatible with InfluxDB's Line Protocol, OpenTSDB's telnet line protocol, and OpenTSDB's JSON format protocol. For more information, see [Schemaless Writing](../../schemaless).
-**Note**.
+Note:
- JDBC REST connections do not currently support schemaless writes
-- The following sample code is based on taos-jdbcdriver-2.0.36
+- The following sample code is based on taos-jdbcdriver-3.0.0
```java
public class SchemalessInsertTest {
@@ -671,59 +663,137 @@ public class SchemalessInsertTest {
}
```
-### Subscriptions
+### Data Subscription
The TDengine Java Connector supports subscription functionality with the following application API.
-#### Create subscriptions
+#### Create a Topic
```java
-TSDBSubscribe sub = ((TSDBConnection)conn).subscribe("topicname", "select * from meters", false);
+Connection connection = DriverManager.getConnection(url, properties);
+Statement statement = connection.createStatement();
+statement.executeUpdate("create topic if not exists topic_speed as select ts, speed from speed_table");
```
The three parameters of the `subscribe()` method have the following meanings.
-- topicname: the name of the subscribed topic. This parameter is the unique identifier of the subscription.
-- sql: the query statement of the subscription. This statement can only be a `select` statement. Only original data can be queried, and you can query the data only temporal order.
-- restart: if the subscription already exists, whether to restart or continue the previous subscription
+- topic_speed: the subscribed topic (name). This is the unique identifier of the subscription.
+- sql: the query statement of the subscription which can only be a _select_ statement. Only the original data should be queried, and data can only be queried in temporal order..
+
+The preceding example uses the SQL statement `select ts, speed from speed_table` and creates a subscription named `topic_speed`.
+
+#### Create a Consumer
-The above example will use the SQL command `select * from meters` to create a subscription named `topicname`. If the subscription exists, it will continue the progress of the previous query instead of consuming all the data from the beginning.
+```java
+Properties config = new Properties();
+config.setProperty("enable.auto.commit", "true");
+config.setProperty("group.id", "group1");
+config.setProperty("value.deserializer", "com.taosdata.jdbc.tmq.ConsumerTest.ResultDeserializer");
+
+TaosConsumer consumer = new TaosConsumer<>(config);
+```
+
+- enable.auto.commit: Specifies whether to commit automatically.
+- group.id: consumer: Specifies the group that the consumer is in.
+- value.deserializer: To deserialize the results, you can inherit `com.taosdata.jdbc.tmq.ReferenceDeserializer` and specify the result set bean. You can also inherit `com.taosdata.jdbc.tmq.Deserializer` and perform custom deserialization based on the SQL result set.
+- For more information, see [Consumer Parameters](../../../develop/tmq).
#### Subscribe to consume data
```java
-int total = 0;
while(true) {
- TSDBResultSet rs = sub.consume();
- int count = 0;
- while(rs.next()) {
- count++;
- }
- total += count;
- System.out.printf("%d rows consumed, total %d\n", count, total);
- Thread.sleep(1000);
+ ConsumerRecords records = consumer.poll(Duration.ofMillis(100));
+ for (ResultBean record : records) {
+ process(record);
+ }
}
```
-The `consume()` method returns a result set containing all new data from the last `consume()`. Be sure to choose a reasonable frequency for calling `consume()` as needed (e.g. `Thread.sleep(1000)` in the example). Otherwise, it will cause unnecessary stress on the server-side.
+`poll` obtains one message each time it is run.
#### Close subscriptions
```java
-sub.close(true);
+// Unsubscribe
+consumer.unsubscribe();
+// Close consumer
+consumer.close()
```
-The `close()` method closes a subscription. If its argument is `true` it means that the subscription progress information is retained, and the subscription with the same name can be created to continue consuming data; if it is `false` it does not retain the subscription progress.
+For more information, see [Data Subscription](../../../develop/tmq).
-### Closing resources
+### Usage examples
```java
-resultSet.close();
-stmt.close();
-conn.close();
-```
+public abstract class ConsumerLoop {
+ private final TaosConsumer consumer;
+ private final List topics;
+ private final AtomicBoolean shutdown;
+ private final CountDownLatch shutdownLatch;
+
+ public ConsumerLoop() throws SQLException {
+ Properties config = new Properties();
+ config.setProperty("msg.with.table.name", "true");
+ config.setProperty("enable.auto.commit", "true");
+ config.setProperty("group.id", "group1");
+ config.setProperty("value.deserializer", "com.taosdata.jdbc.tmq.ConsumerTest.ConsumerLoop$ResultDeserializer");
+
+ this.consumer = new TaosConsumer<>(config);
+ this.topics = Collections.singletonList("topic_speed");
+ this.shutdown = new AtomicBoolean(false);
+ this.shutdownLatch = new CountDownLatch(1);
+ }
-> **Be sure to close the connection**, otherwise, there will be a connection leak.
+ public abstract void process(ResultBean result);
+
+ public void pollData() throws SQLException {
+ try {
+ consumer.subscribe(topics);
+
+ while (!shutdown.get()) {
+ ConsumerRecords records = consumer.poll(Duration.ofMillis(100));
+ for (ResultBean record : records) {
+ process(record);
+ }
+ }
+ consumer.unsubscribe();
+ } finally {
+ consumer.close();
+ shutdownLatch.countDown();
+ }
+ }
+
+ public void shutdown() throws InterruptedException {
+ shutdown.set(true);
+ shutdownLatch.await();
+ }
+
+ public static class ResultDeserializer extends ReferenceDeserializer {
+
+ }
+
+ public static class ResultBean {
+ private Timestamp ts;
+ private int speed;
+
+ public Timestamp getTs() {
+ return ts;
+ }
+
+ public void setTs(Timestamp ts) {
+ this.ts = ts;
+ }
+
+ public int getSpeed() {
+ return speed;
+ }
+
+ public void setSpeed(int speed) {
+ this.speed = speed;
+ }
+ }
+}
+```
### Use with connection pool
@@ -754,7 +824,7 @@ Example usage is as follows.
//query or insert
// ...
- connection.close(); // put back to connection pool
+ connection.close(); // put back to conneciton pool
}
```
@@ -786,26 +856,12 @@ public static void main(String[] args) throws Exception {
//query or insert
// ...
- connection.close(); // put back to connection pool
+ connection.close(); // put back to conneciton pool
}
```
> For more questions about using druid, please see [Official Instructions](https://github.com/alibaba/druid).
-**Caution:**
-
-- TDengine `v1.6.4.1` provides a special function `select server_status()` for heartbeat detection, so it is recommended to use `select server_status()` for Validation Query when using connection pooling.
-
-As you can see below, `select server_status()` returns `1` on successful execution.
-
-```sql
-taos> select server_status();
-server_status()|
-================
-1 |
-Query OK, 1 row(s) in set (0.000141s)
-```
-
### More sample programs
The source code of the sample application is under `TDengine/examples/JDBC`:
@@ -816,12 +872,13 @@ The source code of the sample application is under `TDengine/examples/JDBC`:
- SpringJdbcTemplate: using taos-jdbcdriver in Spring JdbcTemplate.
- mybatisplus-demo: using taos-jdbcdriver in Springboot + Mybatis.
-Please refer to: [JDBC example](https://github.com/taosdata/TDengine/tree/develop/examples/JDBC)
+[JDBC example](https://github.com/taosdata/TDengine/tree/3.0/examples/JDBC)
## Recent update logs
| taos-jdbcdriver version | major changes |
| :---------------------: | :--------------------------------------------: |
+| 3.0.0 | Support for TDengine 3.0 |
| 2.0.39 - 2.0.40 | Add REST connection/request timeout parameters |
| 2.0.38 | JDBC REST connections add bulk pull function |
| 2.0.37 | Support json tags |
@@ -841,13 +898,19 @@ Please refer to: [JDBC example](https://github.com/taosdata/TDengine/tree/develo
**Solution**: On Windows you can copy `C:\TDengine\driver\taos.dll` to the `C:\Windows\System32` directory, on Linux the following soft link will be created `ln -s /usr/local/taos/driver/libtaos.so.x.x.x.x /usr/lib/libtaos.so` will work.
-3. java.lang.UnsatisfiedLinkError: taos.dll Can't load AMD 64 bit on an IA 32-bit platform
+3. java.lang.UnsatisfiedLinkError: taos.dll Can't load AMD 64 bit on a IA 32-bit platform
**Cause**: Currently, TDengine only supports 64-bit JDK.
- **Solution**: Reinstall the 64-bit JDK. 4.
+ **Solution**: Reinstall the 64-bit JDK.
+
+4. java.lang.NoSuchMethodError: setByteArray
+
+ **Cause**: taos-jbdcdriver 3.* only supports TDengine 3.0 and later.
+
+ **Solution**: Use taos-jdbcdriver 2.* with your TDengine 2.* deployment.
-For other questions, please refer to [FAQ](/train-faq/faq)
+For additional troubleshooting, see [FAQ](../../../train-faq/faq).
## API Reference
diff --git a/docs/en/14-reference/03-connector/go.mdx b/docs/en/14-reference/03-connector/05-go.mdx
similarity index 80%
rename from docs/en/14-reference/03-connector/go.mdx
rename to docs/en/14-reference/03-connector/05-go.mdx
index 8a05f2d841bbcdbab2bdb7471691ca0ae49a4f6b..00e3bc1bc38bb7433e823642202957abbdf5566c 100644
--- a/docs/en/14-reference/03-connector/go.mdx
+++ b/docs/en/14-reference/03-connector/05-go.mdx
@@ -1,6 +1,5 @@
---
toc_max_heading_level: 4
-sidebar_position: 4
sidebar_label: Go
title: TDengine Go Connector
---
@@ -8,7 +7,7 @@ title: TDengine Go Connector
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
-import Preparation from "./_preparation.mdx"
+import Preparition from "./_preparition.mdx"
import GoInsert from "../../07-develop/03-insert-data/_go_sql.mdx"
import GoInfluxLine from "../../07-develop/03-insert-data/_go_line.mdx"
import GoOpenTSDBTelnet from "../../07-develop/03-insert-data/_go_opts_telnet.mdx"
@@ -23,7 +22,7 @@ This article describes how to install `driver-go` and connect to TDengine cluste
The source code of `driver-go` is hosted on [GitHub](https://github.com/taosdata/driver-go).
-## Supported Platforms
+## Supported platforms
Native connections are supported on the same platforms as the TDengine client driver.
REST connections are supported on all platforms that can run Go.
@@ -41,33 +40,31 @@ A "native connection" is established by the connector directly to the TDengine i
* Normal queries
* Continuous queries
* Subscriptions
-* schemaless interface
-* parameter binding interface
+* Schemaless interface
+* Parameter binding interface
### REST connection
A "REST connection" is a connection between the application and the TDengine instance via the REST API provided by the taosAdapter component. The following features are supported:
-* General queries
+* Normal queries
* Continuous queries
-## Installation steps
+## Installation Steps
-### Pre-installation
+### Pre-installation preparation
-- Install Go development environment (Go 1.14 and above, GCC 4.8.5 and above)
+* Install Go development environment (Go 1.14 and above, GCC 4.8.5 and above)
- If you use the native connector, please install the TDengine client driver. Please refer to [Install Client Driver](/reference/connector/#install-client-driver) for specific steps
Configure the environment variables and check the command.
-* `go env`
-* `gcc -v`
+* ```go env```
+* ```gcc -v```
### Use go get to install
-```
-go get -u github.com/taosdata/driver-go/v2@develop
-```
+`go get -u github.com/taosdata/driver-go/v3@latest`
### Manage with go mod
@@ -75,14 +72,14 @@ go get -u github.com/taosdata/driver-go/v2@develop
```text
go mod init taos-demo
- ```
+ ```
2. Introduce taosSql
```go
import (
"database/sql"
- _ "github.com/taosdata/driver-go/v2/taosSql"
+ _ "github.com/taosdata/driver-go/v3/taosSql"
)
```
@@ -90,7 +87,7 @@ go get -u github.com/taosdata/driver-go/v2@develop
```text
go mod tidy
- ```
+ ```
4. Run the program with `go run taos-demo` or compile the binary with the `go build` command.
@@ -99,14 +96,14 @@ go get -u github.com/taosdata/driver-go/v2@develop
go build
```
-## Create a connection
+## Establishing a connection
### Data source name (DSN)
Data source names have a standard format, e.g. [PEAR DB](http://pear.php.net/manual/en/package.database.db.intro-dsn.php), but no type prefix (square brackets indicate optionally):
``` text
-[username[:password]@][protocol[(address)]]/[dbname][?param1=value1&... ¶mN=valueN]
+[username[:password]@][protocol[(address)]]/[dbname][?param1=value1&...¶mN=valueN]
```
DSN in full form.
@@ -114,7 +111,6 @@ DSN in full form.
```text
username:password@protocol(address)/dbname?param=value
```
-
### Connecting via connector
@@ -126,7 +122,7 @@ Use `taosSql` as `driverName` and use a correct [DSN](#DSN) as `dataSourceName`,
* configPath specifies the `taos.cfg` directory
-Example.
+For example:
```go
package main
@@ -135,13 +131,13 @@ import (
"database/sql"
"fmt"
- _ "github.com/taosdata/driver-go/v2/taosSql"
+ _ "github.com/taosdata/driver-go/v3/taosSql"
)
func main() {
var taosUri = "root:taosdata@tcp(localhost:6030)/"
taos, err := sql.Open("taosSql", taosUri)
- if err ! = nil {
+ if err != nil {
fmt.Println("failed to connect TDengine, err:", err)
return
}
@@ -158,7 +154,7 @@ Use `taosRestful` as `driverName` and use a correct [DSN](#DSN) as `dataSourceNa
* `disableCompression` whether to accept compressed data, default is true do not accept compressed data, set to false if transferring data using gzip compression.
* `readBufferSize` The default size of the buffer for reading data is 4K (4096), which can be adjusted upwards when the query result has a lot of data.
-Example.
+For example:
```go
package main
@@ -167,13 +163,13 @@ import (
"database/sql"
"fmt"
- _ "github.com/taosdata/driver-go/v2/taosRestful"
+ _ "github.com/taosdata/driver-go/v3/taosRestful"
)
func main() {
var taosUri = "root:taosdata@http(localhost:6041)/"
taos, err := sql.Open("taosRestful", taosUri)
- if err ! = nil {
+ if err != nil {
fmt.Println("failed to connect TDengine, err:", err)
return
}
@@ -208,14 +204,14 @@ func main() {
### More sample programs
-* [sample program](https://github.com/taosdata/TDengine/tree/develop/examples/go)
-* [Video tutorial](https://www.taosdata.com/blog/2020/11/11/1951.html).
+* [sample program](https://github.com/taosdata/driver-go/tree/3.0/examples)
+
## Usage limitations
Since the REST interface is stateless, the `use db` syntax will not work. You need to put the db name into the SQL command, e.g. `create table if not exists tb1 (ts timestamp, a int)` to `create table if not exists test.tb1 (ts timestamp, a int)` otherwise it will report the error `[0x217] Database not specified or available`.
-You can also put the db name in the DSN by changing `root:taosdata@http(localhost:6041)/` to `root:taosdata@http(localhost:6041)/test`. This method is supported by taosAdapter since TDengine 2.4.0.5. Executing the `create database` statement when the specified db does not exist will not report an error while executing other queries or writing against that db will report an error.
+You can also put the db name in the DSN by changing `root:taosdata@http(localhost:6041)/` to `root:taosdata@http(localhost:6041)/test`. Executing the `create database` statement when the specified db does not exist will not report an error while executing other queries or writing against that db will report an error.
The complete example is as follows.
@@ -227,7 +223,7 @@ import (
"fmt"
"time"
- _ "github.com/taosdata/driver-go/v2/taosRestful"
+ _ "github.com/taosdata/driver-go/v3/taosRestful"
)
func main() {
@@ -269,35 +265,27 @@ func main() {
## Frequently Asked Questions
-1. Cannot find the package `github.com/taosdata/driver-go/v2/taosRestful`
-
- Change the `github.com/taosdata/driver-go/v2` line in the require block of the `go.mod` file to `github.com/taosdata/driver-go/v2 develop`, then execute `go mod tidy`.
-
-2. bind interface in database/sql crashes
+1. bind interface in database/sql crashes
REST does not support parameter binding related interface. It is recommended to use `db.Exec` and `db.Query`.
-3. error `[0x217] Database not specified or available` after executing other statements with `use db` statement
+2. error `[0x217] Database not specified or available` after executing other statements with `use db` statement
The execution of SQL command in the REST interface is not contextual, so using `use db` statement will not work, see the usage restrictions section above.
-4. use `taosSql` without error but use `taosRestful` with error `[0x217] Database not specified or available`
+3. use `taosSql` without error but use `taosRestful` with error `[0x217] Database not specified or available`
Because the REST interface is stateless, using the `use db` statement will not take effect. See the usage restrictions section above.
-5. Upgrade `github.com/taosdata/driver-go/v2/taosRestful`
-
- Change the `github.com/taosdata/driver-go/v2` line in the `go.mod` file to `github.com/taosdata/driver-go/v2 develop`, then execute `go mod tidy`.
-
-6. `readBufferSize` parameter has no significant effect after being increased
+4. `readBufferSize` parameter has no significant effect after being increased
Increasing `readBufferSize` will reduce the number of `syscall` calls when fetching results. If the query result is smaller, modifying this parameter will not improve performance significantly. If you increase the parameter value too much, the bottleneck will be parsing JSON data. If you need to optimize the query speed, you must adjust the value based on the actual situation to achieve the best query performance.
-7. `disableCompression` parameter is set to `false` when the query efficiency is reduced
+5. `disableCompression` parameter is set to `false` when the query efficiency is reduced
When set `disableCompression` parameter to `false`, the query result will be compressed by `gzip` and then transmitted, so you have to decompress the data by `gzip` after getting it.
-8. `go get` command can't get the package, or timeout to get the package
+6. `go get` command can't get the package, or timeout to get the package
Set Go proxy `go env -w GOPROXY=https://goproxy.cn,direct`.
@@ -311,14 +299,13 @@ func main() {
:::info
This API is created successfully without checking permissions, but only when you execute a Query or Exec, and check if user/password/host/port is legal.
-
:::
-* `func (db *DB) Exec(query string, args . .interface{}) (Result, error)`
+* `func (db *DB) Exec(query string, args ...interface{}) (Result, error)`
`sql.Open` built-in method to execute non-query related SQL.
-* `func (db *DB) Query(query string, args ... . interface{}) (*Rows, error)`
+* `func (db *DB) Query(query string, args ...interface{}) (*Rows, error)`
`sql.Open` Built-in method to execute query statements.
@@ -338,17 +325,33 @@ The `af` package encapsulates TDengine advanced functions such as connection man
#### Subscribe to
-* `func (conn *Connector) Subscribe(restart bool, topic string, sql string, interval time.Duration) (Subscriber, error)`
+* `func NewConsumer(conf *Config) (*Consumer, error)`
+
+Creates consumer group.
+
+* `func (c *Consumer) Subscribe(topics []string) error`
+
+Subscribes to a topic.
+
+* `func (c *Consumer) Poll(timeout time.Duration) (*Result, error)`
- Subscribe to data.
+Polling information.
-* `func (s *taosSubscriber) Consume() (driver.Rows, error)`
+* `func (c *Consumer) Commit(ctx context.Context, message unsafe.Pointer) error`
- Consume the subscription data, returning the `Rows` structure of the `database/sql/driver` package.
+Commit information.
-* `func (s *taosSubscriber) Unsubscribe(keepProgress bool)`
+* `func (c *Consumer) FreeMessage(message unsafe.Pointer)`
- Unsubscribe from data.
+Free information.
+
+* `func (c *Consumer) Unsubscribe() error`
+
+Unsubscribe.
+
+* `func (c *Consumer) Close() error`
+
+Close consumer.
#### schemaless
@@ -370,11 +373,7 @@ The `af` package encapsulates TDengine advanced functions such as connection man
Parameter bound single row insert.
-* `func (conn *Connector) StmtQuery(sql string, params *param.Param) (rows driver.Rows, err error)`
-
- Parameter bound query that returns the `Rows` structure of the `database/sql/driver` package.
-
-* `func (conn *Connector) InsertStmt() *insertstmt.
+* `func (conn *Connector) InsertStmt() *insertstmt.InsertStmt`
Initialize the parameters.
@@ -412,4 +411,4 @@ The `af` package encapsulates TDengine advanced functions such as connection man
## API Reference
-Full API see [driver-go documentation](https://pkg.go.dev/github.com/taosdata/driver-go/v2)
+Full API see [driver-go documentation](https://pkg.go.dev/github.com/taosdata/driver-go/v3)
diff --git a/docs/en/14-reference/03-connector/rust.mdx b/docs/en/14-reference/03-connector/06-rust.mdx
similarity index 57%
rename from docs/en/14-reference/03-connector/rust.mdx
rename to docs/en/14-reference/03-connector/06-rust.mdx
index ab06f72069e29361a033f724308d950afe6e8d42..1184c98a287cac8a214aff67ace01f7a836940e5 100644
--- a/docs/en/14-reference/03-connector/rust.mdx
+++ b/docs/en/14-reference/03-connector/06-rust.mdx
@@ -1,6 +1,5 @@
---
toc_max_heading_level: 4
-sidebar_position: 5
sidebar_label: Rust
title: TDengine Rust Connector
---
@@ -8,43 +7,45 @@ title: TDengine Rust Connector
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
-import Preparation from "./_preparation.mdx"
+import Preparition from "./_preparition.mdx"
import RustInsert from "../../07-develop/03-insert-data/_rust_sql.mdx"
import RustBind from "../../07-develop/03-insert-data/_rust_stmt.mdx"
import RustQuery from "../../07-develop/04-query-data/_rust.mdx"
-[`taos`][taos] is the official Rust language connector for TDengine. Rust developers can develop applications to access the TDengine instance data.
+[](https://crates.io/crates/taos)  [](https://docs.rs/taos)
-Rust connector provides two ways to establish connections. One is the **Native Connection**, which connects to TDengine instances via the TDengine client driver (taosc). The other is **Websocket connection**, which connects to TDengine instances via taosAdapter service.
+`taos` is the official Rust connector for TDengine. Rust developers can develop applications to access the TDengine instance data.
-The source code is hosted on [taosdata/taos-connector-rust](https://github.com/taosdata/taos-connector-rust).
+`taos` provides two ways to establish connections. One is the **Native Connection**, which connects to TDengine instances via the TDengine client driver (taosc). The other is the **WebSocket connection**, which connects to TDengine instances via the WebSocket interface provided by taosAdapter. You can specify a connection type with Cargo features. By default, both types are supported. The Websocket connection can be used on any platform. The native connection can be used on any platform that the TDengine Client supports.
+
+The source code for the Rust connectors is located on [GitHub](https://github.com/taosdata/taos-connector-rust).
## Supported platforms
-The platforms supported by native connections are the same as those supported by the TDengine client driver.
-REST connections are supported on all platforms that can run Rust.
+Native connections are supported on the same platforms as the TDengine client driver.
+Websocket connections are supported on all platforms that can run Go.
## Version support
-Please refer to [version support list](/reference/connector#version-support).
+Please refer to [version support list](/reference/connector#version-support)
The Rust Connector is still under rapid development and is not guaranteed to be backward compatible before 1.0. We recommend using TDengine version 3.0 or higher to avoid known issues.
## Installation
-### Pre-installation
+### Pre-installation preparation
* Install the Rust development toolchain
* If using the native connection, please install the TDengine client driver. Please refer to [install client driver](/reference/connector#install-client-driver)
-### Add dependencies
+# Add taos dependency
-Add the dependency to the [Rust](https://rust-lang.org) project as follows, depending on the connection method selected.
+Depending on the connection method, add the [taos][taos] dependency in your Rust project as follows:
-
+
-Add [taos] to the `Cargo.toml` file.
+In `cargo.toml`, add [taos][taos]:
```toml
[dependencies]
@@ -53,9 +54,10 @@ taos = "*"
```
-
-Add [taos] to the `Cargo.toml` file.
+
+
+In `cargo.toml`, add [taos][taos] and enable the native feature:
```toml
[dependencies]
@@ -65,7 +67,7 @@ taos = { version = "*", default-features = false, features = ["native"] }
-Add [taos] to the `Cargo.toml` file and enable the `ws` feature.
+In `cargo.toml`, add [taos][taos] and enable the ws feature:
```toml
[dependencies]
@@ -75,15 +77,15 @@ taos = { version = "*", default-features = false, features = ["ws"] }
-## Create a connection
+## Establishing a connection
-In rust connector, we use a DSN connection string as a connection builder. For example,
+[TaosBuilder] creates a connection constructor through the DSN connection description string.
```rust
let builder = TaosBuilder::from_dsn("taos://")?;
```
-You can now use connection client to create the connection.
+You can now use this object to create the connection.
```rust
let conn = builder.build()?;
@@ -96,9 +98,7 @@ let conn1 = builder.build()?;
let conn2 = builder.build()?;
```
-DSN is short for **D**ata **S**ource **N**ame string - [a data structure used to describe a connection to a data source](https://en.wikipedia.org/wiki/Data_source_name).
-
-A common DSN is basically constructed as this:
+The structure of the DSN description string is as follows:
```text
[+]://[[:@]:][/][?=[&=]]
@@ -106,31 +106,31 @@ A common DSN is basically constructed as this:
|driver| protocol | | username | password | host | port | database | params |
```
-- **Driver**: the main entrypoint to a processer. **Required**. In Rust connector, the supported driver names are listed here:
- - **taos**: the legacy TDengine connection data source.
- - **tmq**: subscription data source from TDengine.
- - **http/ws**: use websocket protocol via `ws://` scheme.
- - **https/wss**: use websocket protocol via `wss://` scheme.
-- **Protocol**: the additional information appended to driver, which can be be used to support different kind of data sources. By default, leave it empty for native driver(only under feature "native"), and `ws/wss` for websocket driver (only under feature "ws"). **Optional**.
-- **Username**: as its definition, is the username to the connection. **Optional**.
-- **Password**: the password of the username. **Optional**.
-- **Host**: address host to the datasource. **Optional**.
-- **Port**: address port to the datasource. **Optional**.
-- **Database**: database name or collection name in the datasource. **Optional**.
-- **Params**: a key-value map for any other informations to the datasource. **Optional**.
-
-Here is a simple DSN connection string example:
+The parameters are described as follows:
+
+- **driver**: Specify a driver name so that the connector can choose which method to use to establish the connection. Supported driver names are as follows:
+ - **taos**: Table names use the TDengine connector driver.
+ - **tmq**: Use the TMQ to subscribe to data.
+ - **http/ws**: Use Websocket to establish connections.
+ - **https/wss**: Use Websocket to establish connections, and enable SSL/TLS.
+- **protocol**: Specify which connection method to use. For example, `taos+ws://localhost:6041` uses Websocket to establish connections.
+- **username/password**: Username and password used to create connections.
+- **host/port**: Specifies the server and port to establish a connection. If you do not specify a hostname or port, native connections default to `localhost:6030` and Websocket connections default to `localhost:6041`.
+- **database**: Specify the default database to connect to.
+- **params**:Optional parameters.
+
+A sample DSN description string is as follows:
```text
taos+ws://localhost:6041/test
```
-which means connect `localhost` with port `6041` via `ws` protocol, and make `test` as the default database.
+This indicates that the Websocket connection method is used on port 6041 to connect to the server localhost and use the database `test` by default.
-So that you can use DSN to specify connection protocol at runtime:
+You can create DSNs to connect to servers in your environment.
```rust
-use taos::*; // use it like a `prelude` mod, we need some traits at next.
+use taos::*;
// use native protocol.
let builder = TaosBuilder::from_dsn("taos://localhost:6030")?;
@@ -140,7 +140,7 @@ let conn1 = builder.build();
let conn2 = TaosBuilder::from_dsn("taos+ws://localhost:6041")?;
```
-After connected, you can perform the following operations on the database.
+After the connection is established, you can perform operations on your database.
```rust
async fn demo(taos: &Taos, db: &str) -> Result<(), Error> {
@@ -179,7 +179,7 @@ async fn demo(taos: &Taos, db: &str) -> Result<(), Error> {
}
```
-Rust connector provides two kinds of ways to fetch data:
+There are two ways to query data: Using built-in types or the [serde](https://serde.rs) deserialization framework.
```rust
// Query option 1, use rows stream.
@@ -225,41 +225,41 @@ Rust connector provides two kinds of ways to fetch data:
-#### Stmt bind
+#### STMT Write
### Query data
-|
+
## API Reference
-### Connector builder
+### Connector Constructor
-Use DSN to directly construct a TaosBuilder object.
+You create a connector constructor by using a DSN.
```rust
-let builder = TaosBuilder::from_dsn("")? ;
+let cfg = TaosBuilder::default().build()?;
```
-Use `builder` to create many connections:
+You use the builder object to create multiple connections.
```rust
let conn: Taos = cfg.build();
```
-### Connection pool
+### Connection pooling
-In complex applications, we recommend enabling connection pools. Connection pool for [taos] is implemented using [r2d2] by enabling "r2d2" feature.
+In complex applications, we recommend enabling connection pools. [taos] implements connection pools based on [r2d2].
-Basically, a connection pool with default parameters can be generated as:
+As follows, a connection pool with default parameters can be generated.
```rust
let pool = TaosBuilder::from_dsn(dsn)?.pool()?;
```
-You can set the connection pool parameters using the `PoolBuilder`.
+You can set the same connection pool parameters using the connection pool's constructor.
```rust
let dsn = "taos://localhost:6030";
@@ -273,23 +273,23 @@ let opts = PoolBuilder::new()
let pool = TaosBuilder::from_dsn(dsn)?.with_pool_builder(opts)?;
```
-In the application code, use `pool.get()?` to get a connection object [Taos].
+In the application code, use `pool.get()? ` to get a connection object [Taos].
```rust
-let taos = pool.get()? ;
+let taos = pool.get()?;
```
-### Connection methods
+# Connectors
-The [Taos] connection struct provides several APIs for convenient use.
+The [Taos][struct.Taos] object provides an API to perform operations on multiple databases.
-1. `exec`: Execute some non-query SQL statements, such as `CREATE`, `ALTER`, `INSERT` etc. and return affected rows (only meaningful to `INSERT`).
+1. `exec`: Execute some non-query SQL statements, such as `CREATE`, `ALTER`, `INSERT`, etc.
```rust
let affected_rows = taos.exec("INSERT INTO tb1 VALUES(now, NULL)").await?;
```
-2. `exec_many`: You can execute many SQL statements in order with `exec_many` method.
+2. `exec_many`: Run multiple SQL statements simultaneously or in order.
```rust
taos.exec_many([
@@ -299,15 +299,15 @@ The [Taos] connection struct provides several APIs for convenient use.
]).await?;
```
-3. `query`: Execute the query statement and return the [ResultSet] object.
+3. `query`: Run a query statement and return a [ResultSet] object.
```rust
- let mut q = taos.query("select * from log.logs").await?
+ let mut q = taos.query("select * from log.logs").await?;
```
- The [ResultSet] object stores the query result data and basic information about the returned columns (column name, type, length).
+ The [ResultSet] object stores query result data and the names, types, and lengths of returned columns
- Get filed information with `fields` method.
+ You can obtain column information by using [.fields()].
```rust
let cols = q.fields();
@@ -316,7 +316,7 @@ The [Taos] connection struct provides several APIs for convenient use.
}
```
- Users could fetch data by rows.
+ It fetches data line by line.
```rust
let mut rows = result.rows();
@@ -332,7 +332,7 @@ The [Taos] connection struct provides several APIs for convenient use.
}
```
- Or use it with [serde](https://serde.rs) deserialization.
+ Or use the [serde](https://serde.rs) deserialization framework.
```rust
#[derive(Debug, Deserialize)]
@@ -359,15 +359,17 @@ The [Taos] connection struct provides several APIs for convenient use.
Note that Rust asynchronous functions and an asynchronous runtime are required.
-[Taos] provides a few Rust methods that encapsulate SQL to reduce the frequency of `format!` code blocks.
+[Taos][struct.Taos] provides Rust methods for some SQL statements to reduce the number of `format!`s.
- `.describe(table: &str)`: Executes `DESCRIBE` and returns a Rust data structure.
- `.create_database(database: &str)`: Executes the `CREATE DATABASE` statement.
- `.use_database(database: &str)`: Executes the `USE` statement.
-### Bind API
+In addition, this structure is also the entry point for [Parameter Binding](#Parameter Binding Interface) and [Line Protocol Interface](#Line Protocol Interface). Please refer to the specific API descriptions for usage.
+
+### Bind Interface
-Similar to the C interface, Rust provides the bind interface's wrapping. First, create a bind object [Stmt] for a SQL command with the [Taos] object.
+Similar to the C interface, Rust provides the bind interface's wrapping. First, the [Taos][struct.taos] object creates a parameter binding object [Stmt] for an SQL statement.
```rust
let mut stmt = Stmt::init(&taos).await?;
@@ -387,17 +389,17 @@ stmt.set_tbname("d0")?;
#### `.set_tags(&[tag])`
-Bind tag values when the SQL statement uses a super table.
+Bind sub-table table names and tag values when the SQL statement uses a super table.
```rust
let mut stmt = taos.stmt("insert into ? using stb0 tags(?) values(? ,?)")?;
stmt.set_tbname("d0")?;
-stmt.set_tags(&[Value::VarChar("涛思".to_string())])?;
+stmt.set_tags(&[Value::VarChar("taos".to_string())])?;
```
#### `.bind(&[column])`
-Bind value types. Use the [ColumnView] structure to construct the desired type and bind.
+Bind value types. Use the [ColumnView] structure to create and bind the required types.
```rust
let params = vec![
@@ -421,42 +423,42 @@ let rows = stmt.bind(¶ms)?.add_batch()?.execute()?;
#### `.execute()`
-Execute to insert all bind records. [Stmt] objects can be reused, re-bind, and executed after execution. Remember to call `add_batch` before `execute`.
+Execute SQL. [Stmt] objects can be reused, re-binded, and executed after execution. Before execution, ensure that all data has been added to the queue with `.add_batch`.
```rust
-stmt.add_batch()?.execute()?;
+stmt.execute()?;
// next bind cycle.
-// stmt.set_tbname()? ;
-//stmt.bind()? ;
-//stmt.add_batch().execute()? ;
+//stmt.set_tbname()?;
+//stmt.bind()?;
+//stmt.execute()?;
```
-A runnable example for bind can be found [here](https://github.com/taosdata/taos-connector-rust/blob/main/examples/bind.rs).
+For a working example, see [GitHub](https://github.com/taosdata/taos-connector-rust/blob/main/examples/bind.rs).
-### Subscription API
+### Subscriptions
-Users can subscribe a [TOPIC](../../../taos-sql/tmq/) with TMQ(the TDengine Message Queue) API.
+TDengine starts subscriptions through [TMQ](../../../taos-sql/tmq/).
-Start from a TMQ builder:
+You create a TMQ connector by using a DSN.
```rust
let tmq = TmqBuilder::from_dsn("taos://localhost:6030/?group.id=test")?;
```
-Build a consumer:
+Create a consumer:
```rust
let mut consumer = tmq.build()?;
```
-Subscribe a topic:
+A single consumer can subscribe to one or more topics.
```rust
consumer.subscribe(["tmq_meters"]).await?;
```
-Consume messages, and commit the offset for each message.
+The TMQ is of [futures::Stream](https://docs.rs/futures/latest/futures/stream/index.html) type. You can use the corresponding API to consume each message in the queue and then use `.commit` to mark them as consumed.
```rust
{
@@ -495,22 +497,21 @@ Unsubscribe:
consumer.unsubscribe().await;
```
-In TMQ DSN, you must choose to subscribe with a group id. Also, there's several options could be set:
-
-- `group.id`: **Required**, a group id is any visible string you set.
-- `client.id`: a optional client description string.
-- `auto.offset.reset`: choose to subscribe from *earliest* or *latest*, default is *none* which means 'earliest'.
-- `enable.auto.commit`: automatically commit with specified time interval. By default - in the recommended way _ you must use `commit` to ensure that you've consumed the messages correctly, otherwise, consumers will received repeated messages when re-subscribe.
-- `auto.commit.interval.ms`: the auto commit interval in milliseconds.
+The following parameters can be configured for the TMQ DSN. Only `group.id` is mandatory.
-Check the whole subscription example at [GitHub](https://github.com/taosdata/taos-connector-rust/blob/main/examples/subscribe.rs).
+- `group.id`: Within a consumer group, load balancing is implemented by consuming messages on an at-least-once basis.
+- `client.id`: Subscriber client ID.
+- `auto.offset.reset`: Initial point of subscription. *earliest* subscribes from the beginning, and *latest* subscribes from the newest message. The default is earliest. Note: This parameter is set per consumer group.
+- `enable.auto.commit`: Automatically commits. This can be enabled when data consistency is not essential.
+- `auto.commit.interval.ms`: Interval for automatic commits.
+
+For more information, see [GitHub sample file](https://github.com/taosdata/taos-connector-rust/blob/main/examples/subscribe.rs).
-Please move to the Rust documentation hosting page for other related structure API usage instructions: .
+For information about other structure APIs, see the [Rust documentation](https://docs.rs/taos).
-[TDengine]: https://github.com/taosdata/TDengine
+[taos]: https://github.com/taosdata/rust-connector-taos
[r2d2]: https://crates.io/crates/r2d2
-[Taos]: https://docs.rs/taos/latest/taos/struct.Taos.html
-[ResultSet]: https://docs.rs/taos/latest/taos/struct.ResultSet.html
-[Value]: https://docs.rs/taos/latest/taos/enum.Value.html
-[Stmt]: https://docs.rs/taos/latest/taos/stmt/struct.Stmt.html
-[taos]: https://crates.io/crates/taos
+[TaosBuilder]: https://docs.rs/taos/latest/taos/struct.TaosBuilder.html
+[TaosCfg]: https://docs.rs/taos/latest/taos/struct.TaosCfg.html
+[struct.Taos]: https://docs.rs/taos/latest/taos/struct.Taos.html
+[Stmt]: https://docs.rs/taos/latest/taos/struct.Stmt.html
diff --git a/docs/en/14-reference/03-connector/python.mdx b/docs/en/14-reference/03-connector/07-python.mdx
similarity index 89%
rename from docs/en/14-reference/03-connector/python.mdx
rename to docs/en/14-reference/03-connector/07-python.mdx
index 04eb2e57d4455a83b62633ecb988cb64bf837fea..fc95033baada48e7f322a06d00cede16fb827c51 100644
--- a/docs/en/14-reference/03-connector/python.mdx
+++ b/docs/en/14-reference/03-connector/07-python.mdx
@@ -1,5 +1,4 @@
---
-sidebar_position: 3
sidebar_label: Python
title: TDengine Python Connector
description: "taospy is the official Python connector for TDengine. taospy provides a rich API that makes it easy for Python applications to use TDengine. tasopy wraps both the native and REST interfaces of TDengine, corresponding to the two submodules of tasopy: taos and taosrest. In addition to wrapping the native and REST interfaces, taospy also provides a programming interface that conforms to the Python Data Access Specification (PEP 249), making it easy to integrate taospy with many third-party tools, such as SQLAlchemy and pandas."
@@ -8,14 +7,14 @@ description: "taospy is the official Python connector for TDengine. taospy provi
import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";
-`taospy` is the official Python connector for TDengine. `taospy` provides a rich set of APIs that makes it easy for Python applications to access TDengine. `taospy` wraps both the [native interface](/reference/connector/cpp) and [REST interface](/reference/rest-api) of TDengine, which correspond to the `taos` and `taosrest` modules of the `taospy` package, respectively.
+`taospy is the official Python connector for TDengine. taospy provides a rich API that makes it easy for Python applications to use TDengine. `taospy` wraps both the [native interface](/reference/connector/cpp) and [REST interface](/reference/rest-api) of TDengine, which correspond to the `taos` and `taosrest` modules of the `taospy` package, respectively.
In addition to wrapping the native and REST interfaces, `taospy` also provides a set of programming interfaces that conforms to the [Python Data Access Specification (PEP 249)](https://peps.python.org/pep-0249/). It is easy to integrate `taospy` with many third-party tools, such as [SQLAlchemy](https://www.sqlalchemy.org/) and [pandas](https://pandas.pydata.org/).
The direct connection to the server using the native interface provided by the client driver is referred to hereinafter as a "native connection"; the connection to the server using the REST interface provided by taosAdapter is referred to hereinafter as a "REST connection".
The source code for the Python connector is hosted on [GitHub](https://github.com/taosdata/taos-connector-python).
-## Supported Platforms
+## Supported platforms
- The [supported platforms](/reference/connector/#supported-platforms) for the native connection are the same as the ones supported by the TDengine client.
- REST connections are supported on all platforms that can run Python.
@@ -35,7 +34,6 @@ We recommend using the latest version of `taospy`, regardless of the version of
1. Install Python. Python >= 3.6 is recommended. If Python is not available on your system, refer to the [Python BeginnersGuide](https://wiki.python.org/moin/BeginnersGuide/Download) to install it.
2. Install [pip](https://pypi.org/project/pip/). In most cases, the Python installer comes with the pip utility. If not, please refer to [pip documentation](https://pip.pypa.io/en/stable/installation/) to install it.
-
If you use a native connection, you will also need to [Install Client Driver](/reference/connector#Install-Client-Driver). The client install package includes the TDengine client dynamic link library (`libtaos.so` or `taos.dll`) and the TDengine CLI.
### Install via pip
@@ -80,7 +78,7 @@ pip3 install git+https://github.com/taosdata/taos-connector-python.git
-### Installation verification
+### Verify
@@ -110,10 +108,11 @@ If you have multiple versions of Python on your system, you may have various `pi
C:\> pip3 install taospy
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Requirement already satisfied: taospy in c:\users\username\appdata\local\programs\python\python310\lib\site-packages (2.3.0)
+```
:::
-## Establish connection
+## Establishing a connection
### Connectivity testing
@@ -150,10 +149,19 @@ If the test is successful, it will output the server version information, e.g.
```json
{
- "status": "succ",
- "head": ["server_version()"],
- "column_meta": [["server_version()", 8, 8]],
- "data": [["2.4.0.16"]],
+ "code": 0,
+ "column_meta": [
+ [
+ "server_version()",
+ "VARCHAR",
+ 7
+ ]
+ ],
+ "data": [
+ [
+ "3.0.0.0"
+ ]
+ ],
"rows": 1
}
```
@@ -202,12 +210,12 @@ All arguments to the `connect()` function are optional keyword arguments. The fo
- `url`: The URL of taosAdapter REST service. The default is .
- `user`: TDengine user name. The default is `root`.
- `password`: TDengine user password. The default is `taosdata`.
-- `timeout`: HTTP request timeout in seconds. The default is `socket._GLOBAL_DEFAULT_TIMEOUT`. Usually, no configuration is needed.
+- `timeout`: HTTP request timeout. Enter a value in seconds. The default is `socket._GLOBAL_DEFAULT_TIMEOUT`. Usually, no configuration is needed.
-## Sample program
+## Example program
### Basic Usage
@@ -255,12 +263,12 @@ The TaosCursor class uses native connections for write and query operations. In
##### Use of TaosRestCursor class
-The ``TaosRestCursor`` class is an implementation of the PEP249 Cursor interface.
+The `TaosRestCursor` class is an implementation of the PEP249 Cursor interface.
```python title="Use of TaosRestCursor"
{{#include docs/examples/python/connect_rest_examples.py:basic}}
```
-- `cursor.execute` : Used to execute arbitrary SQL statements.
+- `cursor.execute`: Used to execute arbitrary SQL statements.
- `cursor.rowcount` : For write operations, returns the number of successful rows written. For query operations, returns the number of rows in the result set.
- `cursor.description` : Returns the description of the field. Please refer to [TaosRestCursor](https://docs.taosdata.com/api/taospy/taosrest/cursor.html) for the specific format of the description information.
@@ -274,6 +282,8 @@ The `RestClient` class is a direct wrapper for the [REST API](/reference/rest-ap
For a more detailed description of the `sql()` method, please refer to [RestClient](https://docs.taosdata.com/api/taospy/taosrest/restclient.html).
+
+
@@ -304,8 +314,7 @@ For a more detailed description of the `sql()` method, please refer to [RestClie
| [bind_row.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/bind-row.py) | bind_row.py
| [insert_lines.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/insert-lines.py) | InfluxDB line protocol writing |
| [json_tag.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/json-tag.py) | Use JSON type tags |
-| [subscribe-async.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/subscribe-async.py) | Asynchronous subscription |
-| [subscribe-sync.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/subscribe-sync.py) | synchronous-subscribe |
+| [tmq.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/tmq.py) | TMQ subscription |
## Other notes
@@ -324,22 +333,15 @@ Due to the current imperfection of Python's nanosecond support (see link below),
1. https://stackoverflow.com/questions/10611328/parsing-datetime-strings-containing-nanoseconds
2. https://www.python.org/dev/peps/pep-0564/
-
-## Frequently Asked Questions
-
-Welcome to [ask questions or report questions](https://github.com/taosdata/taos-connector-python/issues).
-
## Important Update
-| Connector version | Important Update | Release date |
-| ---------- | --------------------------------------------------------------------------------- | ---------- |
-| 2.3.1 | 1. support TDengine REST API 2. remove support for Python version below 3.6 | 2022-04-28 |
-| 2.2.5 | support timezone option when connect | 2022-04-13 |
-| 2.2.2 | support sqlalchemy dialect plugin | 2022-03-28 |
-
[**Release Notes**] (https://github.com/taosdata/taos-connector-python/releases)
## API Reference
- [taos](https://docs.taosdata.com/api/taospy/taos/)
- [taosrest](https://docs.taosdata.com/api/taospy/taosrest)
+
+## Frequently Asked Questions
+
+Welcome to [ask questions or report questions](https://github.com/taosdata/taos-connector-python/issues).
diff --git a/docs/en/14-reference/03-connector/08-node.mdx b/docs/en/14-reference/03-connector/08-node.mdx
new file mode 100644
index 0000000000000000000000000000000000000000..f93632b4171a0b563a17f80533d3ede4c76e4425
--- /dev/null
+++ b/docs/en/14-reference/03-connector/08-node.mdx
@@ -0,0 +1,252 @@
+---
+toc_max_heading_level: 4
+sidebar_label: Node.js
+title: TDengine Node.js Connector
+---
+
+import Tabs from "@theme/Tabs";
+import TabItem from "@theme/TabItem";
+
+import Preparition from "./_preparition.mdx";
+import NodeInsert from "../../07-develop/03-insert-data/_js_sql.mdx";
+import NodeInfluxLine from "../../07-develop/03-insert-data/_js_line.mdx";
+import NodeOpenTSDBTelnet from "../../07-develop/03-insert-data/_js_opts_telnet.mdx";
+import NodeOpenTSDBJson from "../../07-develop/03-insert-data/_js_opts_json.mdx";
+import NodeQuery from "../../07-develop/04-query-data/_js.mdx";
+
+`@tdengine/client` and `@tdengine/rest` are the official Node.js connectors. Node.js developers can develop applications to access TDengine instance data. Note: The connectors for TDengine 3.0 are different than those for TDengine 2.x. The new connectors do not support TDengine 2.x.
+
+`@tdengine/client` is **native connection**, which connects to TDengine instances natively through the TDengine client driver (taosc), supporting data writing, querying, subscriptions, schemaless writing, and bind interface. `@tdengine/rest` is the **REST connection**, which connects to TDengine instances via the REST interface provided by taosAdapter. The REST connector can run on any platform, but performance is slightly degraded, and the interface implements a somewhat different set of functional features than the native interface.
+
+The source code for the Node.js connectors is located on [GitHub](https://github.com/taosdata/taos-connector-node/tree/3.0).
+
+## Supported platforms
+
+The platforms supported by the native connector are the same as those supported by the TDengine client driver.
+The REST connector supports all platforms that can run Node.js.
+
+## Version support
+
+Please refer to [version support list](/reference/connector#version-support)
+
+## Supported features
+
+### Native connectors
+
+1. Connection Management
+2. General Query
+3. Continuous Query
+4. Parameter Binding
+5. Subscription
+6. Schemaless
+
+### REST Connector
+
+1. Connection Management
+2. General Query
+3. Continuous Query
+
+## Installation Steps
+
+### Pre-installation preparation
+
+- Install the Node.js development environment
+- If you are using the REST connector, skip this step. However, if you use the native connector, please install the TDengine client driver. Please refer to [Install Client Driver](/reference/connector#Install-Client-Driver) for more details. We use [node-gyp](https://github.com/nodejs/node-gyp) to interact with TDengine instances and also need to install some dependencies mentioned below depending on the specific OS.
+
+
+
+
+- `python` (recommended for `v2.7` , `v3.x.x` currently not supported)
+- `@tdengine/client` 3.0.0 supports Node.js LTS v10.9.0 or later and Node.js LTS v12.8.0 or later. Older versions may be incompatible.
+- `make`
+- C compiler, [GCC](https://gcc.gnu.org) v4.8.5 or higher
+
+
+
+
+- Installation method 1
+
+Use Microsoft's [windows-build-tools](https://github.com/felixrieseberg/windows-build-tools) to execute `npm install --global --production` from the `cmd` command-line interface to install all the necessary tools.
+
+- Installation method 2
+
+Manually install the following tools.
+
+- Install Visual Studio related: [Visual Studio Build Tools](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools) or [Visual Studio 2017 Community](https://visualstudio.microsoft.com/pl/thank-you-downloading-visual-studio/?sku=Community)
+- Install [Python](https://www.python.org/downloads/) 2.7 (`v3.x.x` is not supported) and execute `npm config set python python2.7`.
+- Go to the `cmd` command-line interface, `npm config set msvs_version 2017`
+
+Refer to Microsoft's Node.js User Manual [Microsoft's Node.js Guidelines for Windows](https://github.com/Microsoft/nodejs-guidelines/blob/master/windows-environment.md#compiling-native-addon-modules).
+
+If using ARM64 Node.js on Windows 10 ARM, you must add "Visual C++ compilers and libraries for ARM64" and "Visual C++ ATL for ARM64".
+
+
+
+
+### Install via npm
+
+
+
+
+```bash
+npm install @tdengine/client
+```
+
+
+
+
+```bash
+npm install @tdengine/rest
+```
+
+
+
+
+### Verify
+
+After installing the TDengine client, use the `nodejsChecker.js` program to verify that the current environment supports Node.js access to TDengine.
+
+Verification in details:
+
+- Create an installation test folder such as `~/tdengine-test`. Download the [nodejsChecker.js source code](https://github.com/taosdata/taos-connector-node/blob/3.0/nodejs/examples/nodejsChecker.js) to your local machine.
+
+- Execute the following command from the command-line.
+
+```bash
+npm init -y
+npm install @tdengine/client
+node nodejsChecker.js host=localhost
+```
+
+- After executing the above steps, the command-line will output the result of `nodejsChecker.js` connecting to the TDengine instance and performing a simple insert and query.
+
+## Establishing a connection
+
+Please choose to use one of the connectors.
+
+
+
+
+Install and import the `@tdengine/client` package.
+
+```javascript
+//A cursor also needs to be initialized in order to interact with TDengine from Node.js.
+const taos = require("@tdengine/client");
+var conn = taos.connect({
+ host: "127.0.0.1",
+ user: "root",
+ password: "taosdata",
+ config: "/etc/taos",
+ port: 0,
+});
+var cursor = conn.cursor(); // Initializing a new cursor
+
+//Close a connection
+conn.close();
+```
+
+
+
+
+Install and import the `@tdengine/rest` package.
+
+```javascript
+//A cursor also needs to be initialized in order to interact with TDengine from Node.js.
+import { options, connect } from "@tdengine/rest";
+options.path = "/rest/sql";
+// set host
+options.host = "localhost";
+// set other options like user/passwd
+
+let conn = connect(options);
+let cursor = conn.cursor();
+```
+
+
+
+
+## Usage examples
+
+### Write data
+
+#### SQL Write
+
+
+
+#### InfluxDB line protocol write
+
+
+
+#### OpenTSDB Telnet line protocol write
+
+
+
+#### OpenTSDB JSON line protocol write
+
+
+
+### Querying data
+
+
+
+
+## More sample programs
+
+| Sample Programs | Sample Program Description |
+| --------------------------------------------------------------------------------------------------------------------------------- --------- | -------------------------------------- |
+| [basicUse](https://github.com/taosdata/taos-connector-node/blob/3.0/nodejs/examples/queryExample.js) | Basic operations such as establishing connections and running SQl commands. |
+| [stmtBindBatch](https://github.com/taosdata/taos-connector-node/blob/3.0/nodejs/examples/bindParamBatch.js) | Binding multi-line parameter insertion. | |
+| [stmtBindSingleParamBatch](https://github.com/taosdata/taos-connector-node/blob/3.0/nodejs/examples/bindSingleParamBatch.js) | Columnar binding parameter insertion |
+| [stmtQuery](https://github.com/taosdata/taos-connector-node/blob/3.0/nodejs/examples/stmtQuery.js) | Binding parameter query |
+| [schemless insert](https://github.com/taosdata/taos-connector-node/blob/3.0/nodejs/examples/schemaless.js) | Schemaless insert |
+| [TMQ](https://github.com/taosdata/taos-connector-node/blob/3.0/nodejs/examples/tmq.js) | Using data subscription |
+| [asyncQuery](https://github.com/taosdata/taos-connector-node/blob/3.0/nodejs/examples/asyncQueryExample.js) | Using asynchronous queries |
+| [REST](https://github.com/taosdata/taos-connector-node/blob/3.0/typescript-rest/example/example.ts) | Using TypeScript with the REST connector |
+
+## Usage limitations
+
+`@tdengine/client` 3.0.0 supports Node.js LTS v12.8.0 to 12.9.1 and 10.9.0 to 10.20.0.
+
+
+
+
+
+## Frequently Asked Questions
+
+1. Using REST connections requires starting taosadapter.
+
+ ```bash
+ sudo systemctl start taosadapter
+ ```
+
+2. Node.js versions
+
+ `@tdengine/client` supports Node.js v10.9.0 to 10.20.0 and 12.8.0 to 12.9.1.
+
+3. "Unable to establish connection", "Unable to resolve FQDN"
+
+ Usually, the root cause is an incorrect FQDN configuration. You can refer to this section in the [FAQ](https://docs.tdengine.com/2.4/train-faq/faq/#2-how-to-handle-unable-to-establish-connection) to troubleshoot.
+
+## Important update records
+
+### Native connectors
+
+| package name | version | TDengine version | Description |
+|------------------|---------|---------------------|------------------------------------------------------------------|
+| @tdengine/client | 3.0.0 | 3.0.0 | Supports TDengine 3.0. Not compatible with TDengine 2.x. |
+| td2.0-connector | 2.0.12 | 2.4.x;2.5.x;2.6.x | Fixed cursor.close() bug. |
+| td2.0-connector | 2.0.11 | 2.4.x;2.5.x;2.6.x | Supports parameter binding, JSON tags and schemaless interface |
+| td2.0-connector | 2.0.10 | 2.4.x;2.5.x;2.6.x | Supports connection management, standard queries, connection queries, system information, and data subscription |
+### REST Connector
+
+| package name | version | TDengine version | Description |
+|----------------------|---------|---------------------|---------------------------------------------------------------------------|
+| @tdengine/rest | 3.0.0 | 3.0.0 | Supports TDengine 3.0. Not compatible with TDengine 2.x. |
+| td2.0-rest-connector | 1.0.7 | 2.4.x;2.5.x;2.6.x | Removed default port 6041。 |
+| td2.0-rest-connector | 1.0.6 | 2.4.x;2.5.x;2.6.x | Fixed affectRows bug with create, insert, update, and alter. |
+| td2.0-rest-connector | 1.0.5 | 2.4.x;2.5.x;2.6.x | Support cloud token |
+| td2.0-rest-connector | 1.0.3 | 2.4.x;2.5.x;2.6.x | Supports connection management, standard queries, system information, error information, and continuous queries |
+
+## API Reference
+
+[API Reference](https://docs.taosdata.com/api/td2.0-connector/)
\ No newline at end of file
diff --git a/docs/en/14-reference/03-connector/csharp.mdx b/docs/en/14-reference/03-connector/09-csharp.mdx
similarity index 72%
rename from docs/en/14-reference/03-connector/csharp.mdx
rename to docs/en/14-reference/03-connector/09-csharp.mdx
index 2d1b62fe89c542280c4264dd478538fa00634c79..823e9075993e0a4fd32abafbbd4e95f1cc7bc2cf 100644
--- a/docs/en/14-reference/03-connector/csharp.mdx
+++ b/docs/en/14-reference/03-connector/09-csharp.mdx
@@ -1,6 +1,5 @@
---
toc_max_heading_level: 4
-sidebar_position: 7
sidebar_label: C#
title: C# Connector
---
@@ -8,7 +7,7 @@ title: C# Connector
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
-import Preparation from "./_preparation.mdx"
+import Preparition from "./_preparition.mdx"
import CSInsert from "../../07-develop/03-insert-data/_cs_sql.mdx"
import CSInfluxLine from "../../07-develop/03-insert-data/_cs_line.mdx"
import CSOpenTSDBTelnet from "../../07-develop/03-insert-data/_cs_opts_telnet.mdx"
@@ -16,16 +15,17 @@ import CSOpenTSDBJson from "../../07-develop/03-insert-data/_cs_opts_json.mdx"
import CSQuery from "../../07-develop/04-query-data/_cs.mdx"
import CSAsyncQuery from "../../07-develop/04-query-data/_cs_async.mdx"
-
`TDengine.Connector` is a C# language connector provided by TDengine that allows C# developers to develop C# applications that access TDengine cluster data.
The `TDengine.Connector` connector supports connect to TDengine instances via the TDengine client driver (taosc), providing data writing, querying, subscription, schemaless writing, bind interface, etc. The `TDengine.Connector` currently does not provide a REST connection interface. Developers can write their RESTful application by referring to the [REST API](/reference/rest-api/) documentation.
This article describes how to install `TDengine.Connector` in a Linux or Windows environment and connect to TDengine clusters via `TDengine.Connector` to perform basic operations such as data writing and querying.
-The source code of `TDengine.Connector` is hosted on [GitHub](https://github.com/taosdata/taos-connector-dotnet).
+Note: TDengine Connector 3.x is not compatible with TDengine 2.x. In an environment with TDengine 2.x, you must use TDengine.Connector 1.x for the C# connector.
+
+The source code of `TDengine.Connector` is hosted on [GitHub](https://github.com/taosdata/taos-connector-dotnet/tree/3.0).
-## Supported Platforms
+## Supported platforms
The supported platforms are the same as those supported by the TDengine client driver.
@@ -57,29 +57,29 @@ Please refer to [version support list](/reference/connector#version-support)
You can reference the `TDengine.Connector` published in Nuget to the current project via the `dotnet` command under the path of the existing .NET project.
-```
+``` bash
dotnet add package TDengine.Connector
```
-You can download TDengine's source code and directly reference the latest version of the TDengine.Connector library
+You can [download the source code](https://github.com/taosdata/taos-connector-dotnet/tree/3.0) and directly reference the latest version of the TDengine.Connector library.
-```
-git clone https://github.com/taosdata/TDengine.git
-cd TDengine/src/connector/C#/src/
-cp -r TDengineDriver/ myProject
+```bash
+git clone -b 3.0 https://github.com/taosdata/taos-connector-dotnet.git
+cd taos-connector-dotnet
+cp -r src/ myProject
cd myProject
-dotnet add TDengineDriver/TDengineDriver.csproj
+dotnet add exmaple.csproj reference src/TDengine.csproj
```
-## Create a connection
+## Establish a Connection
-```csharp
+``` C#
using TDengineDriver;
namespace TDengineExample
@@ -146,25 +146,24 @@ namespace TDengineExample
|Sample program |Sample program description |
|--------------------------------------------------------------------------------------------------------------------|------------ --------------------------------|
-| [C#checker](https://github.com/taosdata/TDengine/tree/develop/examples/C%23/C%23checker) | Using TDengine.Connector, you can test C# Driver's synchronous writes and queries |
-| [TDengineTest](https://github.com/taosdata/TDengine/tree/develop/examples/C%23/TDengineTest) | A simple example of writing and querying using TDengine.
-| [insertCn](https://github.com/taosdata/TDengine/tree/develop/examples/C%23/insertCn) | Example of writing and querying Chinese characters using TDengine.
-| [jsonTag](https://github.com/taosdata/TDengine/tree/develop/examples/C%23/jsonTag) | Example of writing and querying JSON tag type data using TDengine.
-| [stmt](https://github.com/taosdata/TDengine/tree/develop/examples/C%23/stmt) | Example of parameter binding using TDengine.
-| [schemaless](https://github.com/taosdata/TDengine/tree/develop/examples/C%23/schemaless) | Example of writing with schemaless implemented using TDengine. |schemaless
-| [benchmark](https://github.com/taosdata/TDengine/tree/develop/examples/C%23/taosdemo) | A simple benchmark implemented using TDengine.
-| [async query](https://github.com/taosdata/taos-connector-dotnet/blob/develop/examples/QueryAsyncSample.cs) | Example of an asynchronous query implemented using TDengine. Example of an asynchronous query
-| [subscribe](https://github.com/taosdata/taos-connector-dotnet/blob/develop/examples/SubscribeSample.cs) | Example of subscribing to data using TDengine. Data example
+| [CURD](https://github.com/taosdata/taos-connector-dotnet/blob/3.0/examples/Query/Query.cs) | Table creation, data insertion, and query examples with TDengine.Connector |
+| [JSON Tag](https://github.com/taosdata/taos-connector-dotnet/blob/3.0/examples/JSONTag) | Writing and querying JSON tag data with TDengine Connector |
+| [stmt](https://github.com/taosdata/taos-connector-dotnet/tree/3.0/examples/Stmt) | Parameter binding with TDengine Connector |
+| [schemaless](https://github.com/taosdata/taos-connector-dotnet/blob/3.0/examples/schemaless) | Schemaless writes with TDengine Connector |
+| [async query](https://github.com/taosdata/taos-connector-dotnet/blob/3.0/examples/AsyncQuery/QueryAsync.cs) | Asynchronous queries with TDengine Connector |
+| [TMQ](https://github.com/taosdata/taos-connector-dotnet/blob/3.0/examples/TMQ/TMQ.cs) | Data subscription with TDengine Connector |
## Important update records
| TDengine.Connector | Description |
|--------------------|--------------------------------|
+| 3.0.0 | Supports TDengine 3.0.0.0. TDengine 2.x is not supported. Added `TDengine.Impl.GetData()` interface to deserialize query results. |
+| 1.0.7 | Fixed TDengine.Query() memory leak. |
| 1.0.6 | Fix schemaless bug in 1.0.4 and 1.0.5. |
-| 1.0.5 | Fix Windows sync query Chinese error bug. | 1.0.4 | Fix schemaless bug.
-| 1.0.4 | Add asynchronous query, subscription, and other functions. Fix the binding parameter bug.
-| 1.0.3 | Add parameter binding, schemaless, JSON tag, etc. | new
-| 1.0.2 | Add connection management, synchronous query, error messages, etc. ## Other
+| 1.0.5 | Fix Windows sync query Chinese error bug. | 1.0.4 | Fix schemaless bug. |
+| 1.0.4 | Add asynchronous query, subscription, and other functions. Fix the binding parameter bug. |
+| 1.0.3 | Add parameter binding, schemaless, JSON tag, etc. |
+| 1.0.2 | Add connection management, synchronous query, error messages, etc. |
## Other descriptions
@@ -173,13 +172,12 @@ namespace TDengineExample
`Taos` is an ADO.NET connector for TDengine, supporting Linux and Windows platforms. Community contributor `Maikebing@@maikebing contributes the connector`. Please refer to:
* Interface download:
-* Usage notes:
## Frequently Asked Questions
1. "Unable to establish connection", "Unable to resolve FQDN"
- Usually, it's caused by an incorrect FQDN configuration. Please refer to this section in the [FAQ](https://docs.tdengine.com/2.4/train-faq/faq/#2-how-to-handle-unable-to-establish-connection) to troubleshoot.
+ Usually, it's caused by an incorrect FQDN configuration. Please refer to this section in the [FAQ](https://docs.tdengine.com/2.4/train-faq/faq/#2-how-to-handle-unable-to-establish-connection) to troubleshoot.
2. Unhandled exception. System.DllNotFoundException: Unable to load DLL 'taos' or one of its dependencies: The specified module cannot be found.
diff --git a/docs/en/14-reference/03-connector/php.mdx b/docs/en/14-reference/03-connector/10-php.mdx
similarity index 98%
rename from docs/en/14-reference/03-connector/php.mdx
rename to docs/en/14-reference/03-connector/10-php.mdx
index 69dcce91e80fa05face1ffb35effe1ce1efa2631..820f70375982eb54cdd87602b891e5f04756c0e5 100644
--- a/docs/en/14-reference/03-connector/php.mdx
+++ b/docs/en/14-reference/03-connector/10-php.mdx
@@ -1,5 +1,4 @@
---
-sidebar_position: 1
sidebar_label: PHP
title: PHP Connector
---
@@ -61,7 +60,7 @@ phpize && ./configure && make -j && make install
**Specify TDengine location:**
```shell
-phpize && ./configure --with-tdengine-dir=/usr/local/Cellar/tdengine/2.4.0.0 && make -j && make install
+phpize && ./configure --with-tdengine-dir=/usr/local/Cellar/tdengine/3.0.0.0 && make -j && make install
```
> `--with-tdengine-dir=` is followed by TDengine location.
diff --git a/docs/en/14-reference/03-connector/_linux_install.mdx b/docs/en/14-reference/03-connector/_linux_install.mdx
index 3fa123794cd8ff304a1bc13449591194e7320aa9..07f8fb5c7118d84c53017f44d9811a3357944cfc 100644
--- a/docs/en/14-reference/03-connector/_linux_install.mdx
+++ b/docs/en/14-reference/03-connector/_linux_install.mdx
@@ -1,16 +1,15 @@
-import PkgList from "/components/PkgList";
+import PkgListV3 from "/components/PkgListV3";
-1. Download the TDengine client installation package
+1. Download the client installation package
-
+
- [All Packages](https://www.taosdata.com/en/all-downloads/)
+ [All Downloads](../../releases)
2. Unzip
Download the package to any directory the current user has read/write permission. Then execute `tar -xzvf TDengine-client-VERSION.tar.gz` command.
The VERSION should be the version of the package you just downloaded.
-
3. Execute the install script
Once the package is unzipped, you will see the following files in the directory:
@@ -18,17 +17,14 @@ import PkgList from "/components/PkgList";
- _ taos.tar.gz_: client driver package
- _ driver_: TDengine client driver
- _examples_: some example programs of different programming languages (C/C#/go/JDBC/MATLAB/python/R)
-
You can run `install_client.sh` to install it.
-
-4. Edit taos.cfg
+4. configure taos.cfg
Edit `taos.cfg` file (full path is `/etc/taos/taos.cfg` by default), modify `firstEP` with actual TDengine server's End Point, for example `h1.tdengine.com:6030`
:::tip
1. If the computer does not run the TDengine service but installs the TDengine client driver, then you need to config `firstEP` in `taos.cfg` only, and there is no need to configure `FQDN`;
-
2. If you encounter the "Unable to resolve FQDN" error, please make sure the FQDN in the `/etc/hosts` file of the current computer is correctly configured, or the DNS service is correctly configured.
:::
diff --git a/docs/en/14-reference/03-connector/_preparation.mdx b/docs/en/14-reference/03-connector/_preparation.mdx
index 07ebdbca3d891ff51a254bc1b83016f1404bb47e..c6e42ce02348595da0fdd75847d6442c285dc10a 100644
--- a/docs/en/14-reference/03-connector/_preparation.mdx
+++ b/docs/en/14-reference/03-connector/_preparation.mdx
@@ -2,7 +2,7 @@
:::info
-Since the TDengine client driver is written in C, using the native connection requires loading the client driver shared library file, which is usually included in the TDengine installer. You can install either standard TDengine server installation package or [TDengine client installation package](/get-started/). For Windows development, you need to install the corresponding [Windows client](https://www.taosdata.com/cn/all-downloads/#TDengine-Windows-Client) for TDengine.
+Since the TDengine client driver is written in C, using the native connection requires loading the client driver shared library file, which is usually included in the TDengine installer. You can install either standard TDengine server installation package or [TDengine client installation package](/get-started/). For Windows development, you need to install the corresponding Windows client, please refer to [Install TDengine](../../get-started/package).
- libtaos.so: After successful installation of TDengine on a Linux system, the dependent Linux version of the client driver `libtaos.so` file will be automatically linked to `/usr/lib/libtaos.so`, which is included in the Linux scannable path and does not need to be specified separately.
- taos.dll: After installing the client on Windows, the dependent Windows version of the client driver taos.dll file will be automatically copied to the system default search path C:/Windows/System32, again without the need to specify it separately.
diff --git a/docs/zh/14-reference/03-connector/_preparition.mdx b/docs/en/14-reference/03-connector/_preparition.mdx
similarity index 100%
rename from docs/zh/14-reference/03-connector/_preparition.mdx
rename to docs/en/14-reference/03-connector/_preparition.mdx
diff --git a/docs/en/14-reference/03-connector/_verify_linux.mdx b/docs/en/14-reference/03-connector/_verify_linux.mdx
index 875c9e132b7acbbe95d394ae6cee6f2bd95ddbe0..3438b1578eaa1df38115d80fd67f491c071d619a 100644
--- a/docs/en/14-reference/03-connector/_verify_linux.mdx
+++ b/docs/en/14-reference/03-connector/_verify_linux.mdx
@@ -2,10 +2,6 @@ Execute TDengine CLI program `taos` directly from the Linux shell to connect to
```text
$ taos
-Welcome to the TDengine shell from Linux, Client Version:3.0.0.0
-Copyright (c) 2022 by TAOS Data, Inc. All rights reserved.
-
-Server is Community Edition.
taos> show databases;
name | create_time | vgroups | ntables | replica | strict | duration | keep | buffer | pagesize | pages | minrows | maxrows | comp | precision | status | retention | single_stable | cachemodel | cachesize | wal_level | wal_fsync_period | wal_retention_period | wal_retention_size | wal_roll_period | wal_seg_size |
diff --git a/docs/en/14-reference/03-connector/_verify_windows.mdx b/docs/en/14-reference/03-connector/_verify_windows.mdx
index 4813bd24c3b4a2a4bf04af3c397bdadd22e9e399..402b1705110295f4d465c9ae7c734eb3e0ad0b5f 100644
--- a/docs/en/14-reference/03-connector/_verify_windows.mdx
+++ b/docs/en/14-reference/03-connector/_verify_windows.mdx
@@ -1,11 +1,6 @@
Go to the `C:\TDengine` directory from `cmd` and execute TDengine CLI program `taos.exe` directly to connect to the TDengine service and enter the TDengine CLI interface, for example, as follows:
```text
-Welcome to the TDengine shell from Windows, Client Version:3.0.0.0
-Copyright (c) 2022 by TAOS Data, Inc. All rights reserved.
-
-Server is Community Edition.
-
taos> show databases;
name | create_time | vgroups | ntables | replica | strict | duration | keep | buffer | pagesize | pages | minrows | maxrows | comp | precision | status | retention | single_stable | cachemodel | cachesize | wal_level | wal_fsync_period | wal_retention_period | wal_retention_size | wal_roll_period | wal_seg_size |
=========================================================================================================================================================================================================================================================================================================================================================================================================================================================================
diff --git a/docs/en/14-reference/03-connector/_windows_install.mdx b/docs/en/14-reference/03-connector/_windows_install.mdx
index 2819be615ee0a80da9f0324d8d41e9b247e8a7f6..ea638ed1ed6c64c3ec4ceaea436f65dd1f09a27e 100644
--- a/docs/en/14-reference/03-connector/_windows_install.mdx
+++ b/docs/en/14-reference/03-connector/_windows_install.mdx
@@ -1,11 +1,10 @@
-import PkgList from "/components/PkgList";
+import PkgListV3 from "/components/PkgListV3";
1. Download the client installation package
-
-
- [All downloads](https://www.taosdata.com/cn/all-downloads/)
+
+ [All Downloads](../../releases)
2. Execute the installer, select the default value as prompted, and complete the installation
3. Installation path
diff --git a/docs/en/14-reference/03-connector/03-connector.mdx b/docs/en/14-reference/03-connector/index.mdx
similarity index 75%
rename from docs/en/14-reference/03-connector/03-connector.mdx
rename to docs/en/14-reference/03-connector/index.mdx
index c3f4530023db19e807565573bd10d41dafcd6f8e..49e2dceec531cf8449749ea9dbb111079771a788 100644
--- a/docs/en/14-reference/03-connector/03-connector.mdx
+++ b/docs/en/14-reference/03-connector/index.mdx
@@ -8,13 +8,13 @@ TDengine provides a rich set of APIs (application development interface). To fac
## Supported platforms
-Currently, TDengine's native interface connectors can support platforms such as X64/ARM64 hardware platforms and Linux/Win64 development environments. The comparison matrix is as follows.
+Currently, TDengine's native interface connectors can support platforms such as x64 and ARM hardware platforms and Linux and Windows development environments. The comparison matrix is as follows.
-| **CPU** | **OS** | **JDBC** | **Python** | **Go** | **Node.js** | **C#** | **Rust** | C/C++ |
-| ------- | ------ | -------- | ---------- | ------ | ----------- | ------ | -------- | ----- |
-| **X86 64bit** | **Linux** | ● | ● | ● | ● | ● | ● | ● |
-| **X86 64bit** | **Win64** | ● | ● | ● | ● | ● | ● | ● |
-| **ARM64** | **Linux** | ● | ● | ● | ● | ○ | ○ | ● |
+| **CPU** | **OS** | **Java** | **Python** | **Go** | **Node.js** | **C#** | **Rust** | C/C++ |
+| -------------- | --------- | -------- | ---------- | ------ | ----------- | ------ | -------- | ----- |
+| **X86 64bit** | **Linux** | ● | ● | ● | ● | ● | ● | ● |
+| **X86 64bit** | **Win64** | ● | ● | ● | ● | ● | ● | ● |
+| **ARM64** | **Linux** | ● | ● | ● | ● | ○ | ○ | ● |
Where ● means the official test verification passed, ○ means the unofficial test verification passed, -- means no assurance.
@@ -26,6 +26,7 @@ TDengine version updates often add new features, and the connector versions in t
| **TDengine Versions** | **Java** | **Python** | **Go** | **C#** | **Node.js** | **Rust** |
| --------------------- | -------- | ---------- | ------------ | ------------- | --------------- | -------- |
+| **3.0.0.0 and later** | 3.0.0 | current version | 3.0 branch | 3.0.0 | 3.0.0 | current version |
| **2.4.0.14 and up** | 2.0.38 | current version | develop branch | 1.0.2 - 1.0.6 | 2.0.10 - 2.0.12 | current version |
| **2.4.0.6 and up** | 2.0.37 | current version | develop branch | 1.0.2 - 1.0.6 | 2.0.10 - 2.0.12 | current version |
| **2.4.0.4 - 2.4.0.5** | 2.0.37 | current version | develop branch | 1.0.2 - 1.0.6 | 2.0.10 - 2.0.12 | current version |
@@ -42,9 +43,8 @@ Comparing the connector support for TDengine functional features as follows.
| -------------- | -------- | ---------- | ------ | ------ | ----------- | -------- |
| **Connection Management** | Support | Support | Support | Support | Support | Support |
| **Regular Query** | Support | Support | Support | Support | Support | Support |
-| **Continuous Query** | Support | Support | Support | Support | Support | Support |
| **Parameter Binding** | Support | Support | Support | Support | Support | Support |
-| **Subscription** | Support | Support | Support | Support | Support | Not Supported |
+| ** TMQ ** | Support | Support | Support | Support | Support | Support |
| **Schemaless** | Support | Support | Support | Support | Support | Support |
| **DataFrame** | Not Supported | Support | Not Supported | Not Supported | Not Supported | Not Supported |
@@ -52,17 +52,17 @@ Comparing the connector support for TDengine functional features as follows.
The different database framework specifications for various programming languages do not mean that all C/C++ interfaces need a wrapper.
:::
-### Using the REST interface
+### Use HTTP Interfaces (REST or WebSocket)
| **Functional Features** | **Java** | **Python** | **Go** | **C# (not supported yet)** | **Node.js** | **Rust** |
| ------------------------------ | -------- | ---------- | -------- | ------------------ | ----------- | -------- |
| **Connection Management** | Support | Support | Support | N/A | Support | Support |
| **Regular Query** | Support | Support | Support | N/A | Support | Support |
| **Continous Query ** | Support | Support | Support | N/A | Support | Support |
-| **Parameter Binding** | Not Supported | Not Supported | Not Supported | N/A | Not Supported | Not Supported |
-| **Subscription** | Not Supported | Not Supported | Not Supported | N/A | Not Supported | Not Supported |
-| **Schemaless** | Not supported | Not Supported | Not Supported | N/A | Not Supported | Not supported |
-| **Bulk Pulling (based on WebSocket) **| Support | Not Supported | Not Supported | N/A | Not Supported | Not Supported |
+| **Parameter Binding** | Not supported | Not supported | Not supported | N/A | Not supported | Support |
+| ** TMQ ** | Not supported | Not supported | Not supported | N/A | Not supported | Support |
+| **Schemaless** | Not supported | Not supported | Not supported | N/A | Not supported | Not supported |
+| **Bulk Pulling (based on WebSocket) **| Support | Support | Not Supported | N/A | Not Supported | Supported |
| **DataFrame** | Not supported | Support | Not supported | N/A | Not supported | Not supported |
:::warning
@@ -85,7 +85,7 @@ The client driver needs to be installed if you use the native interface connecto
:::
-### Installation steps
+### Install
@@ -96,7 +96,7 @@ The client driver needs to be installed if you use the native interface connecto
-### Installation Verification
+### Verify
After completing the above installation and configuration and you have confirmed that the TDengine service is up and running, you can execute the TDengine CLI tool to log in.
diff --git a/docs/en/14-reference/03-connector/node.mdx b/docs/en/14-reference/03-connector/node.mdx
deleted file mode 100644
index 8f586acde4848af71efcb23358be1f8486cedb8e..0000000000000000000000000000000000000000
--- a/docs/en/14-reference/03-connector/node.mdx
+++ /dev/null
@@ -1,248 +0,0 @@
----
-toc_max_heading_level: 4
-sidebar_position: 6
-sidebar_label: Node.js
-title: TDengine Node.js Connector
----
-
-import Tabs from "@theme/Tabs";
-import TabItem from "@theme/TabItem";
-
-import Preparation from "./_preparation.mdx";
-import NodeInsert from "../../07-develop/03-insert-data/_js_sql.mdx";
-import NodeInfluxLine from "../../07-develop/03-insert-data/_js_line.mdx";
-import NodeOpenTSDBTelnet from "../../07-develop/03-insert-data/_js_opts_telnet.mdx";
-import NodeOpenTSDBJson from "../../07-develop/03-insert-data/_js_opts_json.mdx";
-import NodeQuery from "../../07-develop/04-query-data/_js.mdx";
-
-`td2.0-connector` and `td2.0-rest-connector` are the official Node.js language connectors for TDengine. Node.js developers can develop applications to access TDengine instance data.
-
-`td2.0-connector` is a **native connector** that connects to TDengine instances via the TDengine client driver (taosc) and supports data writing, querying, subscriptions, schemaless writing, and bind interface. The `td2.0-rest-connector` is a **REST connector** that connects to TDengine instances via the REST interface provided by taosAdapter. The REST connector can run on any platform, but performance is slightly degraded, and the interface implements a somewhat different set of functional features than the native interface.
-
-The Node.js connector source code is hosted on [GitHub](https://github.com/taosdata/taos-connector-node).
-
-## Supported Platforms
-
-The platforms supported by the native connector are the same as those supported by the TDengine client driver.
-The REST connector supports all platforms that can run Node.js.
-
-## Version support
-
-Please refer to [version support list](/reference/connector#version-support)
-
-## Supported features
-
-### Native connectors
-
-1. connection management
-2. general query
-3. continuous query
-4. parameter binding
-5. subscription function
-6. Schemaless
-
-### REST Connector
-
-1. connection management
-2. general queries
-3. Continuous query
-
-## Installation steps
-
-### Pre-installation
-
-- Install the Node.js development environment
-- If you are using the REST connector, skip this step. However, if you use the native connector, please install the TDengine client driver. Please refer to [Install Client Driver](/reference/connector#Install-Client-Driver) for more details. We use [node-gyp](https://github.com/nodejs/node-gyp) to interact with TDengine instances and also need to install some dependencies mentioned below depending on the specific OS.
-
-
-
-
-- `python` (recommended for `v2.7` , `v3.x.x` currently not supported)
-- `td2.0-connector` 2.0.6 supports Node.js LTS v10.9.0 or later, Node.js LTS v12.8.0 or later; 2.0.5 and earlier support Node.js LTS v10.x versions. Other versions may have package compatibility issues
-- `make`
-- C compiler, [GCC](https://gcc.gnu.org) v4.8.5 or higher
-
-
-
-
-- Installation method 1
-
-Use Microsoft's [windows-build-tools](https://github.com/felixrieseberg/windows-build-tools) to execute `npm install --global --production` from the `cmd` command-line interface to install all the necessary tools.
-
-- Installation method 2
-
-Manually install the following tools.
-
-- Install Visual Studio related: [Visual Studio Build Tools](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools) or [Visual Studio 2017 Community](https://visualstudio.microsoft.com/pl/thank-you-downloading-visual-studio/?sku=Community)
-- Install [Python](https://www.python.org/downloads/) 2.7 (`v3.x.x` is not supported) and execute `npm config set python python2.7`.
-- Go to the `cmd` command-line interface, `npm config set msvs_version 2017`
-
-Refer to Microsoft's Node.js User Manual [Microsoft's Node.js Guidelines for Windows](https://github.com/Microsoft/nodejs-guidelines/blob/master/windows-environment.md#compiling-native-addon-modules).
-
-If using ARM64 Node.js on Windows 10 ARM, you must add "Visual C++ compilers and libraries for ARM64" and "Visual C++ ATL for ARM64".
-
-
-
-
-### Install via npm
-
-
-
-
-```bash
-npm install td2.0-connector
-```
-
-
-
-
-```bash
-npm i td2.0-rest-connector
-```
-
-
-
-
-### Installation verification
-
-After installing the TDengine client, use the `nodejsChecker.js` program to verify that the current environment supports Node.js access to TDengine.
-
-Verification in details:
-
-- Create a new installation verification directory, e.g. `~/tdengine-test`, and download the [nodejsChecker.js source code](https://github.com/taosdata/TDengine/tree/develop/examples/nodejs/) from GitHub. to the work directory.
-
-- Execute the following command from the command-line.
-
-```bash
-npm init -y
-npm install td2.0-connector
-node nodejsChecker.js host=localhost
-```
-
-- After executing the above steps, the command-line will output the result of `nodejsChecker.js` connecting to the TDengine instance and performing a simple insert and query.
-
-## Establishing a connection
-
-Please choose to use one of the connectors.
-
-
-
-
-Install and refer to `td2.0-connector` package:
-
-```javascript
-//A cursor also needs to be initialized in order to interact with TDengine from Node.js.
-const taos = require("td2.0-connector");
-var conn = taos.connect({
- host: "127.0.0.1",
- user: "root",
- password: "taosdata",
- config: "/etc/taos",
- port: 0,
-});
-var cursor = conn.cursor(); // Initializing a new cursor
-
-//Close a connection
-conn.close();
-```
-
-
-
-
-Install and refer to `td2.0-rest-connector`package:
-
-```javascript
-//A cursor also needs to be initialized in order to interact with TDengine from Node.js.
-import { options, connect } from "td2.0-rest-connector";
-options.path = "/rest/sqlt";
-// set host
-options.host = "localhost";
-// set other options like user/passwd
-
-let conn = connect(options);
-let cursor = conn.cursor();
-```
-
-
-
-
-## Usage examples
-
-### Write data
-
-#### SQL Writing
-
-
-
-#### InfluxDB line protocol writing
-
-
-
-#### OpenTSDB Telnet line protocol writing
-
-
-
-#### OpenTSDB JSON line protocol writing
-
-
-
-### Query data
-
-
-
-## More Sample Programs
-
-| Sample Programs | Sample Program Description |
-| --------------------------------------------------------------------------------------------------------------------------------- --------- | -------------------------------------- |
-| [connection](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/cursorClose.js) | Example of establishing a connection. |
-| [stmtBindBatch](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/stmtBindParamBatchSample.js) | Example of binding a multi-line parameter Example of inserting. |
-| [stmtBind](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/stmtBindParamSample.js) | Example of a line-by-line bind parameter insertion. |
-| [stmtBindSingleParamBatch](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/) stmtBindSingleParamBatchSample.js) | Example of binding parameters by column. |
-| [stmtUseResult](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/stmtUseResultSample.js) | Example of a bound parameter query. |
-| [json tag](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/testJsonTag.js) | Example of using Json tag. |
-| [Nanosecond](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/testNanoseconds.js) | An example of using timestamps with nanosecond precision. |
-| [Microsecond](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/testMicroseconds.js) | Example of using microsecond timestamp. |
-| [schemless insert](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/testSchemalessInsert.js) | schemless Example of a schemless insert. |
-| [subscribe](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/testSubscribe.js) | Example of using subscribe. |
-| [asyncQuery](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/tset.js) | An example of using asynchronous queries. |
-| [REST](https://github.com/taosdata/taos-connector-node/blob/develop/typescript-rest/example/example.ts) | An example of using TypeScript with REST connections. |
-
-## Usage restrictions
-
-Node.js Connector >= v2.0.6 currently supports node versions >=v12.8.0 <= v12.9.1 || >=v10.20.0 <= v10.9.0; v10.x versions are supported in 2.0.5 and earlier, other versions may have package compatibility issues.
-
-## Other notes
-
-See [video tutorial](https://www.taosdata.com/blog/2020/11/11/1957.html) for the Node.js connector usage.
-
-## Frequently Asked Questions
-
-1. Using REST connections requires starting taosadapter.
-
- ```bash
- sudo systemctl start taosadapter
- ```
-
-2. "Unable to establish connection", "Unable to resolve FQDN"
-
- Usually, the root cause is an incorrect FQDN configuration. You can refer to this section in the [FAQ](https://docs.tdengine.com/2.4/train-faq/faq/#2-how-to-handle-unable-to-establish-connection) to troubleshoot.
-
-## Important Updates
-
-### Native connectors
-
-| td2.0-connector version | description |
-| -------------------- | ---------------------------------------------------------------- |
-| 2.0.12 | Fix bug with cursor.close() error. | 2.0.12 | Fix bug with cursor.close() error.
-| 2.0.11 | Support for binding parameters, json tag, schemaless interface, etc. |
-| 2.0.10 | Support connection management, general query, continuous query, get system information, subscribe function, etc. | ### REST Connector
-
-### REST Connector
-
-| td2.0-rest-connector version | Description |
-| ------------------------- | ---------------------------------------------------------------- |
-| 1.0.3 | Support connection management, general query, get system information, error message, continuous query, etc. |# API Reference
-
-## API Reference
-
-[API Reference](https://docs.taosdata.com/api/td2.0-connector/)
diff --git a/docs/en/14-reference/04-taosadapter.md b/docs/en/14-reference/04-taosadapter.md
index cad229c32d602e8fc595ec06f72a1a486e2af77b..e7ea620d0bed3aee3ff0acf8063120acca33c335 100644
--- a/docs/en/14-reference/04-taosadapter.md
+++ b/docs/en/14-reference/04-taosadapter.md
@@ -30,7 +30,7 @@ taosAdapter provides the following features.
### Install taosAdapter
-taosAdapter has been part of TDengine server software since TDengine v2.4.0.0. If you use the TDengine server, you don't need additional steps to install taosAdapter. You can download taosAdapter from [TDengine official website](https://tdengine.com/all-downloads/) to download the TDengine server installation package (taosAdapter is included in v2.4.0.0 and later version). If you need to deploy taosAdapter separately on another server other than the TDengine server, you should install the full TDengine server package on that server to install taosAdapter. If you need to build taosAdapter from source code, you can refer to the [Building taosAdapter]( https://github.com/taosdata/taosadapter/blob/develop/BUILD.md) documentation.
+If you use the TDengine server, you don't need additional steps to install taosAdapter. You can download taosAdapter from [TDengine 3.0 released versions](../../releases) to download the TDengine server installation package. If you need to deploy taosAdapter separately on another server other than the TDengine server, you should install the full TDengine server package on that server to install taosAdapter. If you need to build taosAdapter from source code, you can refer to the [Building taosAdapter]( https://github.com/taosdata/taosadapter/blob/3.0/BUILD.md) documentation.
### Start/Stop taosAdapter
@@ -69,20 +69,23 @@ Usage of taosAdapter:
--debug enable debug mode. Env "TAOS_ADAPTER_DEBUG"
--help Print this help message and exit
--influxdb.enable enable influxdb. Env "TAOS_ADAPTER_INFLUXDB_ENABLE" (default true)
+ --log.enableRecordHttpSql whether to record http sql. Env "TAOS_ADAPTER_LOG_ENABLE_RECORD_HTTP_SQL"
--log.path string log path. Env "TAOS_ADAPTER_LOG_PATH" (default "/var/log/taos")
--log.rotationCount uint log rotation count. Env "TAOS_ADAPTER_LOG_ROTATION_COUNT" (default 30)
--log.rotationSize string log rotation size(KB MB GB), must be a positive integer. Env "TAOS_ADAPTER_LOG_ROTATION_SIZE" (default "1GB")
--log.rotationTime duration log rotation time. Env "TAOS_ADAPTER_LOG_ROTATION_TIME" (default 24h0m0s)
+ --log.sqlRotationCount uint record sql log rotation count. Env "TAOS_ADAPTER_LOG_SQL_ROTATION_COUNT" (default 2)
+ --log.sqlRotationSize string record sql log rotation size(KB MB GB), must be a positive integer. Env "TAOS_ADAPTER_LOG_SQL_ROTATION_SIZE" (default "1GB")
+ --log.sqlRotationTime duration record sql log rotation time. Env "TAOS_ADAPTER_LOG_SQL_ROTATION_TIME" (default 24h0m0s)
--logLevel string log level (panic fatal error warn warning info debug trace). Env "TAOS_ADAPTER_LOG_LEVEL" (default "info")
--monitor.collectDuration duration Set monitor duration. Env "TAOS_MONITOR_COLLECT_DURATION" (default 3s)
--monitor.identity string The identity of the current instance, or 'hostname:port' if it is empty. Env "TAOS_MONITOR_IDENTITY"
--monitor.incgroup Whether running in cgroup. Env "TAOS_MONITOR_INCGROUP"
- --monitor.password string TDengine password. Env "TAOS_MONITOR_PASSWORD" (default "taosdata")
- --monitor.pauseAllMemoryThreshold float Memory percentage threshold for pause all. Env "TAOS_MONITOR_PAUSE_ALL_MEMORY_THRESHOLD" (default 80)
+ --monitor.password string TDengine password. Env "TAOS_MONITOR_PASSWORD" (default "taosdata") --monitor.pauseAllMemoryThreshold float Memory percentage threshold for pause all. Env "TAOS_MONITOR_PAUSE_ALL_MEMORY_THRESHOLD" (default 80)
--monitor.pauseQueryMemoryThreshold float Memory percentage threshold for pause query. Env "TAOS_MONITOR_PAUSE_QUERY_MEMORY_THRESHOLD" (default 70)
--monitor.user string TDengine user. Env "TAOS_MONITOR_USER" (default "root")
--monitor.writeInterval duration Set write to TDengine interval. Env "TAOS_MONITOR_WRITE_INTERVAL" (default 30s)
- --monitor.writeToTD Whether write metrics to TDengine. Env "TAOS_MONITOR_WRITE_TO_TD" (default true)
+ --monitor.writeToTD Whether write metrics to TDengine. Env "TAOS_MONITOR_WRITE_TO_TD"
--node_exporter.caCertFile string node_exporter ca cert file path. Env "TAOS_ADAPTER_NODE_EXPORTER_CA_CERT_FILE"
--node_exporter.certFile string node_exporter cert file path. Env "TAOS_ADAPTER_NODE_EXPORTER_CERT_FILE"
--node_exporter.db string node_exporter db name. Env "TAOS_ADAPTER_NODE_EXPORTER_DB" (default "node_exporter")
@@ -98,8 +101,10 @@ Usage of taosAdapter:
--node_exporter.urls strings node_exporter urls. Env "TAOS_ADAPTER_NODE_EXPORTER_URLS" (default [http://localhost:9100])
--node_exporter.user string node_exporter user. Env "TAOS_ADAPTER_NODE_EXPORTER_USER" (default "root")
--opentsdb.enable enable opentsdb. Env "TAOS_ADAPTER_OPENTSDB_ENABLE" (default true)
+ --opentsdb_telnet.batchSize int opentsdb_telnet batch size. Env "TAOS_ADAPTER_OPENTSDB_TELNET_BATCH_SIZE" (default 1)
--opentsdb_telnet.dbs strings opentsdb_telnet db names. Env "TAOS_ADAPTER_OPENTSDB_TELNET_DBS" (default [opentsdb_telnet,collectd_tsdb,icinga2_tsdb,tcollector_tsdb])
--opentsdb_telnet.enable enable opentsdb telnet,warning: without auth info(default false). Env "TAOS_ADAPTER_OPENTSDB_TELNET_ENABLE"
+ --opentsdb_telnet.flushInterval duration opentsdb_telnet flush interval (0s means not valid) . Env "TAOS_ADAPTER_OPENTSDB_TELNET_FLUSH_INTERVAL"
--opentsdb_telnet.maxTCPConnections int max tcp connections. Env "TAOS_ADAPTER_OPENTSDB_TELNET_MAX_TCP_CONNECTIONS" (default 250)
--opentsdb_telnet.password string opentsdb_telnet password. Env "TAOS_ADAPTER_OPENTSDB_TELNET_PASSWORD" (default "taosdata")
--opentsdb_telnet.ports ints opentsdb telnet tcp port. Env "TAOS_ADAPTER_OPENTSDB_TELNET_PORTS" (default [6046,6047,6048,6049])
@@ -111,9 +116,6 @@ Usage of taosAdapter:
-P, --port int http port. Env "TAOS_ADAPTER_PORT" (default 6041)
--prometheus.enable enable prometheus. Env "TAOS_ADAPTER_PROMETHEUS_ENABLE" (default true)
--restfulRowLimit int restful returns the maximum number of rows (-1 means no limit). Env "TAOS_ADAPTER_RESTFUL_ROW_LIMIT" (default -1)
- --ssl.certFile string ssl cert file path. Env "TAOS_ADAPTER_SSL_CERT_FILE"
- --ssl.enable enable ssl. Env "TAOS_ADAPTER_SSL_ENABLE"
- --ssl.keyFile string ssl key file path. Env "TAOS_ADAPTER_SSL_KEY_FILE"
--statsd.allowPendingMessages int statsd allow pending messages. Env "TAOS_ADAPTER_STATSD_ALLOW_PENDING_MESSAGES" (default 50000)
--statsd.db string statsd db name. Env "TAOS_ADAPTER_STATSD_DB" (default "statsd")
--statsd.deleteCounters statsd delete counter cache after gather. Env "TAOS_ADAPTER_STATSD_DELETE_COUNTERS" (default true)
@@ -149,11 +151,12 @@ You do not need to care about these configurations if you do not make interface
For details on the CORS protocol, please refer to: [https://www.w3.org/wiki/CORS_Enabled](https://www.w3.org/wiki/CORS_Enabled) or [https://developer.mozilla.org/zh-CN/docs/Web/HTTP/CORS](https://developer.mozilla.org/zh-CN/docs/Web/HTTP/CORS).
-See [example/config/taosadapter.toml](https://github.com/taosdata/taosadapter/blob/develop/example/config/taosadapter.toml) for sample configuration files.
+See [example/config/taosadapter.toml](https://github.com/taosdata/taosadapter/blob/3.0/example/config/taosadapter.toml) for sample configuration files.
## Feature List
-- Compatible with RESTful interfaces [REST API](/reference/rest-api/)
+- RESTful interface
+ [https://docs.tdengine.com/reference/rest-api/](https://docs.tdengine.com/reference/rest-api/)
- Compatible with InfluxDB v1 write interface
[https://docs.influxdata.com/influxdb/v2.0/reference/api/influxdb-1x/write/](https://docs.influxdata.com/influxdb/v2.0/reference/api/influxdb-1x/write/)
- Compatible with OpenTSDB JSON and telnet format writes
@@ -176,13 +179,7 @@ See [example/config/taosadapter.toml](https://github.com/taosdata/taosadapter/bl
### TDengine RESTful interface
-You can use any client that supports the http protocol to write data to or query data from TDengine by accessing the REST interface address `http://:6041/`. See the [official documentation](/reference/connector#restful) for details. The following EndPoint is supported.
-
-```text
-/rest/sql
-/rest/sqlt
-/rest/sqlutc
-```
+You can use any client that supports the http protocol to write data to or query data from TDengine by accessing the REST interface address `http://:6041/rest/sql`. See the [official documentation](/reference/rest-api/) for details.
### InfluxDB
@@ -203,7 +200,7 @@ Note: InfluxDB token authorization is not supported at present. Only Basic autho
### OpenTSDB
-You can use any client that supports the http protocol to access the RESTful interface address `http://:6041/` to write data in OpenTSDB compatible format to TDengine.
+You can use any client that supports the http protocol to access the RESTful interface address `http://:6041/` to write data in OpenTSDB compatible format to TDengine. The EndPoint is as follows:
```text
/opentsdb/v1/put/json/
@@ -254,7 +251,7 @@ HTTP response content.
Stops processing all write and query requests when the `pauseAllMemoryThreshold` threshold is exceeded.
-HTTP response: code 503
+HTTP response content.
- code 503
- body "memory exceeds threshold"
@@ -269,7 +266,7 @@ Status check interface `http://:6041/-/ping`
Corresponding configuration parameter
-``text
+```text
monitor.collectDuration monitoring interval environment variable `TAOS_MONITOR_COLLECT_DURATION` (default value 3s)
monitor.incgroup whether to run in cgroup (set to true for running in container) environment variable `TAOS_MONITOR_INCGROUP`
monitor.pauseAllMemoryThreshold memory threshold for no more inserts and queries environment variable `TAOS_MONITOR_PAUSE_ALL_MEMORY_THRESHOLD` (default 80)
@@ -297,11 +294,11 @@ taosAdapter supports writing the metrics of HTTP monitoring, CPU percentage, and
For configuration parameters
| **Configuration items** | **Description** | **Default values** |
-| ----------------------- | --------------------------------------------------------- | ---------- |
+|-------------------------|--------------------------------------------|----------|
| monitor.collectDuration | CPU and memory collection interval | 3s |
| monitor.identity | The current taosadapter identifier will be used if not set to `hostname:port` | |
| monitor.incgroup | whether it is running in a cgroup (set to true for running in a container) | false |
-| monitor.writeToTD | Whether to write to TDengine | true |
+| monitor.writeToTD | Whether to write to TDengine | false |
| monitor.user | TDengine connection username | root |
| monitor.password | TDengine connection password | taosdata |
| monitor.writeInterval | Write to TDengine interval | 30s |
@@ -313,9 +310,7 @@ taosAdapter controls the number of results returned by the parameter `restfulRow
This parameter controls the number of results returned by the following interfaces:
- `http://:6041/rest/sql`
-- `http://:6041/rest/sqlt`
-- `http://:6041/rest/sqlutc`
-- ` http://:6041/prometheus/v1/remote_read/:db`
+- `http://:6041/prometheus/v1/remote_read/:db`
## Troubleshooting
@@ -328,7 +323,7 @@ You can also adjust the level of the taosAdapter log output by setting the `--lo
In TDengine server 2.2.x.x or earlier, the TDengine server process (taosd) contains an embedded HTTP service. As mentioned earlier, taosAdapter is a standalone software managed using `systemd` and has its own process ID. There are some configuration parameters and behaviors that are different between the two. See the following table for details.
| **#** | **embedded httpd** | **taosAdapter** | **comment** |
-| ----- | ------------------- | ------------------------------------ | ------------------------------------------------------------------ ------------------------------------------------------------------------ |
+|-------|---------------------|-------------------------------|------------------------------------------------------------------------------------------------|
| 1 | httpEnableRecordSql | --logLevel=debug | |
| 2 | httpMaxThreads | n/a | taosAdapter Automatically manages thread pools without this parameter |
| 3 | telegrafUseFieldNum | See the taosAdapter telegraf configuration method | |
diff --git a/docs/en/14-reference/05-taosbenchmark.md b/docs/en/14-reference/05-taosbenchmark.md
index 5d47cc06e8034d8c49669d71c3f98c1f587acb33..8f63dddfb711a98840cb423d1a4b0c1556a7b5fd 100644
--- a/docs/en/14-reference/05-taosbenchmark.md
+++ b/docs/en/14-reference/05-taosbenchmark.md
@@ -23,11 +23,7 @@ There are two ways to install taosBenchmark:
TaosBenchmark needs to be executed on the terminal of the operating system, it supports two configuration methods: [Command-line arguments](#command-line-arguments-in-detail) and [JSON configuration file](#configuration-file-parameters-in-detail). These two methods are mutually exclusive. Users can use `-f ` to specify a configuration file. When running taosBenchmark with command-line arguments to control its behavior, users should use other parameters for configuration, but not the `-f` parameter. In addition, taosBenchmark offers a special way of running without parameters.
-<<<<<<< HEAD
-taosBenchmark supports complete performance testing of TDengine. taosBenchmark supports the TDengine functions in three categories: write, query, and subscribe. These three functions are mutually exclusive, and users can select only one of them each time taosBenchmark runs. It is important to note that the type of functionality to be tested is not configurable when using the command-line configuration method, which can only test writing performance. To test the query and subscription performance of the TDengine, you must use the configuration file method and specify the function type to test via the parameter `filetype` in the configuration file.
-=======
-taosBenchmark supports the complete performance testing of TDengine by providing functionally to write, query, and subscribe. These three functions are mutually exclusive, users can only select one of them each time taosBenchmark runs. The query and subscribe functionalities are only configurable using a json configuration file by specifying the parameter `filetype`, while write can be performed through both the command-line and a configuration file.
->>>>>>> 108548b4d6 (docs: typo)
+taosBenchmark supports the complete performance testing of TDengine by providing functionally to write, query, and subscribe. These three functions are mutually exclusive, users can only select one of them each time taosBenchmark runs. The query and subscribe functionalities are only configurable using a json configuration file by specifying the parameter `filetype`, while write can be performed through both the command-line and a configuration file. If you want to test the performance of queries or data subscriptionm configure taosBenchmark with the configuration file. You can modify the value of the `filetype` parameter to specify the function that you want to test.
**Make sure that the TDengine cluster is running correctly before running taosBenchmark. **
@@ -61,8 +57,9 @@ Use the following command-line to run taosBenchmark and control its behavior via
taosBenchmark -f
```
+**Sample configuration files**
+
#### Configuration file examples
-##### Example of inserting a scenario JSON configuration file
insert.json
@@ -73,7 +70,7 @@ taosBenchmark -f
-##### Query Scenario JSON Profile Example
+#### Query Scenario JSON Profile Example
query.json
@@ -84,7 +81,7 @@ taosBenchmark -f
-##### Subscription JSON configuration example
+#### Subscription JSON configuration example
subscribe.json
@@ -128,7 +125,7 @@ taosBenchmark -f
Enables interleaved insertion mode and specifies the number of rows of data to be inserted into each child table. Interleaved insertion mode means inserting the number of rows specified by this parameter into each sub-table and repeating the process until all sub-tables have been inserted. The default value is 0, i.e., data is inserted into one sub-table before the next sub-table is inserted.
- **-i/--insert-interval ** :
- Specify the insert interval in `ms` for interleaved insert mode. The default value is 0. It only works if `-B/--interlace-rows` is greater than 0. That means that after inserting interlaced rows for each child table, the data insertion with multiple threads will wait for the interval specified by this value before proceeding to the next round of writes.
+ Specify the insert interval in `ms` for interleaved insert mode. The default value is 0. It only works if `-B/--interlace-rows` is greater than 0. After inserting interlaced rows for each child table, the data insertion thread will wait for the interval specified by this value before proceeding to the next round of writes.
- **-r/--rec-per-req ** :
Writing the number of rows of records per request to TDengine, the default value is 30000.
@@ -184,7 +181,7 @@ taosBenchmark -A INT,DOUBLE,NCHAR,BINARY\(16\)
This parameter indicates writing data with random values. The default is false. If users use this parameter, taosBenchmark will generate the random values. For tag/data columns of numeric type, the value is a random value within the range of values of that type. For NCHAR and BINARY type tag columns/data columns, the value is the random string within the specified length range.
- **-x/--aggr-func** :
- Switch parameter to indicate query aggregation function after insertion. The default value is false.
+ Switch parameter to indicate query aggregation function after insertion. The default is false.
- **-y/--answer-yes** :
Switch parameter that requires the user to confirm at the prompt to continue. The default value is false.
@@ -230,45 +227,34 @@ The parameters listed in this section apply to all function modes.
#### Database related configuration parameters
-The parameters related to database creation are configured in `dbinfo` in the json configuration file, as follows. These parameters correspond to the database parameters specified when `create database` in TDengine.
+The parameters related to database creation are configured in `dbinfo` in the json configuration file, as follows. The other parameters correspond to the database parameters specified when `create database` in [../../taos-sql/database].
- **name**: specify the name of the database.
- **drop**: indicate whether to delete the database before inserting. The default is true.
-- **replica**: specify the number of replicas when creating the database.
-
-- **days**: specify the time span for storing data in a single data file. The default is 10.
-
-- **cache**: specify the size of the cache blocks in MB. The default value is 16.
-
-- **blocks**: specify the number of cache blocks in each vnode. The default is 6.
-
-- **precision**: specify the database time precision. The default value is "ms".
-
-- **keep**: specify the number of days to keep the data. The default value is 3650.
+#### Stream processing related configuration parameters
-- **minRows**: specify the minimum number of records in the file block. The default value is 100.
+The parameters for creating streams are configured in `stream` in the json configuration file, as shown below.
-- **maxRows**: specify the maximum number of records in the file block. The default value is 4096.
+- **stream_name**: Name of the stream. Mandatory.
-- **comp**: specify the file compression level. The default value is 2.
+- **stream_stb**: Name of the supertable for the stream. Mandatory.
-- **walLevel** : specify WAL level, default is 1.
+- **stream_sql**: SQL statement for the stream to process. Mandatory.
-- **cacheLast**: indicate whether to allow the last record of each table to be kept in memory. The default value is 0. The value can be 0, 1, 2, or 3.
+- **trigger_mode**: Triggering mode for stream processing. Optional.
-- **quorum**: specify the number of writing acknowledgments in multi-replica mode. The default value is 1.
+- **watermark**: Watermark for stream processing. Optional.
-- **fsync**: specify the interval of fsync in ms when users set WAL to 2. The default value is 3000.
-
-- **update** : indicate whether to support data update, default value is 0, optional values are 0, 1, 2.
+- **drop**: Whether to create the stream. Specify yes to create the stream or no to not create the stream.
#### Super table related configuration parameters
The parameters for creating super tables are configured in `super_tables` in the json configuration file, as shown below.
- **name**: Super table name, mandatory, no default value.
+
- **child_table_exists** : whether the child table already exists, default value is "no", optional value is "yes" or "no".
- **child_table_count** : The number of child tables, the default value is 10.
@@ -319,6 +305,22 @@ The parameters for creating super tables are configured in `super_tables` in the
- **tags_file** : only works when insert_mode is taosc, rest. The final tag value is related to the childtable_count. Suppose the tag data rows in the CSV file are smaller than the given number of child tables. In that case, taosBenchmark will read the CSV file data cyclically until the number of child tables specified by childtable_count is generated. Otherwise, taosBenchmark will read the childtable_count rows of tag data only. The final number of child tables generated is the smaller of the two.
+#### TSMA configuration parameters
+
+The configuration parameters for specifying TSMAs are in `tsmas` in `super_tables`.
+
+- **name**: Specifies TSMA name. Mandatory.
+
+- **function**: Specifies TSMA function. Mandatory.
+
+- **interval**: Specifies TSMA interval. Mandatory.
+
+- **sliding**: Specifies time offset for TSMA window. Mandatory.
+
+- **custom**: Specifies custom configurations to attach to the end of the TSMA creation statement. Optional.
+
+- **start_when_inserted**: Specifies the number of inserted rows after which TSMA is started. Optional. The default value is 0.
+
#### Tag and Data Column Configuration Parameters
The configuration parameters for specifying super table tag columns and data columns are in `columns` and `tag` in `super_tables`, respectively.
@@ -338,6 +340,8 @@ The configuration parameters for specifying super table tag columns and data col
- **values**: The value field of the nchar/binary column/label, which will be chosen randomly from the values.
+- **sma**: Insert the column into the BSMA. Enter `yes` or `no`. The default is `no`.
+
#### insertion behavior configuration parameters
- **thread_count**: specify the number of threads to insert data. Default is 8.
@@ -350,17 +354,17 @@ The configuration parameters for specifying super table tag columns and data col
- **confirm_parameter_prompt**: The switch parameter requires the user to confirm after the prompt to continue. The default value is false.
-- **interlace_rows**: Enables interleaved insertion mode and specifies the number of rows of data to be inserted into each child table at a time. Interleaved insertion mode means inserting the number of rows specified by this parameter into each sub-table and repeating the process until all sub-tables are inserted. The default value is 0, which means that data will be inserted into the following child table only after data is inserted into one child table.
+- **interlace_rows**: Enables interleaved insertion mode and specifies the number of rows of data to be inserted into each child table at a time. Staggered insertion mode means inserting the number of rows specified by this parameter into each sub-table and repeating the process until all sub-tables have been inserted. The default value is 0, i.e., data is inserted into one sub-table before the next sub-table is inserted.
This parameter can also be configured in `super_tables`, and if so, the configuration in `super_tables` takes precedence and overrides the global setting.
- **insert_interval** :
- Specifies the insertion interval in ms for interleaved insertion mode. The default value is 0. Only works if `-B/--interlace-rows` is greater than 0. It means that after inserting interlace rows for each child table, the data insertion thread will wait for the interval specified by this value before proceeding to the next round of writes.
- This parameter can also be configured in `super_tables`, and if configured, the configuration in `super_tables` takes high priority, overriding the global setting.
+ Specify the insert interval in `ms` for interleaved insert mode. The default value is 0. It only works if `-B/--interlace-rows` is greater than 0. After inserting interlaced rows for each child table, the data insertion thread will wait for the interval specified by this value before proceeding to the next round of writes.
+ This parameter can also be configured in `super_tables`, and if so, the configuration in `super_tables` takes precedence and overrides the global setting.
- **num_of_records_per_req** :
- The number of rows of data to be written per request to TDengine, the default value is 30000. When it is set too large, the TDengine client driver will return the corresponding error message, so you need to lower the setting of this parameter to meet the writing requirements.
+ Writing the number of rows of records per request to TDengine, the default value is 30000. When it is set too large, the TDengine client driver will return the corresponding error message, so you need to lower the setting of this parameter to meet the writing requirements.
-- **prepare_rand**: The number of unique values in the generated random data. A value of 1 means that all data are the same. The default value is 10000.
+- **prepare_rand**: The number of unique values in the generated random data. A value of 1 means that all data are equal. The default value is 10000.
### Query scenario configuration parameters
@@ -388,7 +392,7 @@ The configuration parameters of the super table query are set in `super_table_qu
- **threads**: The number of threads to execute the query SQL, the default value is 1.
-- **sqls** : The default value is 1.
+- **sqls**:
- **sql**: The SQL command to be executed. For the query SQL of super table, keep "xxxx" in the SQL command. The program will automatically replace it with all the sub-table names of the super table.
Replace it with all the sub-table names in the super table.
- **result**: The file to save the query result. If not specified, taosBenchmark will not save result.
@@ -411,9 +415,9 @@ The configuration parameters for subscribing to a sub-table or a generic table a
- **resubAfterConsume**: "yes" means cancel the previous subscription and then subscribe again, "no" means continue the previous subscription, and the default value is "no".
-- **sqls** : The default value is "no".
+- **sqls**:
- **sql** : The SQL command to be executed, required.
- - **result** : The file to save the query result, unspecified is not saved.
+ - **result**: The file to save the query result. If not specified, taosBenchmark will not save result.
#### Configuration parameters for subscribing to supertables
@@ -431,7 +435,7 @@ The configuration parameters for subscribing to a super table are set in `super_
- **resubAfterConsume**: "yes" means cancel the previous subscription and then subscribe again, "no" means continue the previous subscription, and the default value is "no".
-- **sqls** : The default value is "no".
- - **sql**: SQL command to be executed, required; for the query SQL of the super table, keep "xxxx" in the SQL command, and the program will replace it with all the sub-table names of the super table automatically.
+- **sqls**:
+ - **sql**: The SQL command to be executed. For the query SQL of super table, keep "xxxx" in the SQL command. The program will automatically replace it with all the sub-table names of the super table.
Replace it with all the sub-table names in the super table.
- - **result**: The file to save the query result, if not specified, it will not be saved.
+ - **result**: The file to save the query result. If not specified, taosBenchmark will not save result.
diff --git a/docs/en/14-reference/06-taosdump.md b/docs/en/14-reference/06-taosdump.md
index 2105ba83fad9700674e28609016b07ef6de66833..e73441a96b087062b2e3912ed73010fc3e761bb9 100644
--- a/docs/en/14-reference/06-taosdump.md
+++ b/docs/en/14-reference/06-taosdump.md
@@ -116,5 +116,4 @@ Usage: taosdump [OPTION...] dbname [tbname ...]
Mandatory or optional arguments to long options are also mandatory or optional
for any corresponding short options.
-Report bugs to .
```
diff --git a/docs/en/14-reference/07-tdinsight/index.md b/docs/en/14-reference/07-tdinsight/index.md
index e74c9de7b2aa71278a99d45f250e0dcaf86d4704..2e562035254311f2caa0b6d4512842080aab64d5 100644
--- a/docs/en/14-reference/07-tdinsight/index.md
+++ b/docs/en/14-reference/07-tdinsight/index.md
@@ -263,7 +263,7 @@ Once the import is complete, the full page view of TDinsight is shown below.
## TDinsight dashboard details
-The TDinsight dashboard is designed to provide the usage and status of TDengine-related resources [dnodes, mnodes, vnodes](https://www.taosdata.com/cn/documentation/architecture#cluster) or databases.
+The TDinsight dashboard is designed to provide the usage and status of TDengine-related resources [dnodes, mnodes, vnodes](../../taos-sql/node/) or databases.
Details of the metrics are as follows.
diff --git a/docs/en/14-reference/08-taos-shell.md b/docs/en/14-reference/08-taos-shell.md
index c947e86d1ce298f32e82b51c991892a9448dc88b..656db1f481250ed4e34e068a02a93b75f0ac0b81 100644
--- a/docs/en/14-reference/08-taos-shell.md
+++ b/docs/en/14-reference/08-taos-shell.md
@@ -8,7 +8,7 @@ The TDengine command-line interface (hereafter referred to as `TDengine CLI`) is
## Installation
-If executed on the TDengine server-side, there is no need for additional installation steps to install TDengine CLI as it is already included and installed automatically. To run TDengine CLI in an environment where no TDengine server is running, the TDengine client installation package needs to be installed first. For details, please refer to [connector](/reference/connector/).
+If executed on the TDengine server-side, there is no need for additional installation steps to install TDengine CLI as it is already included and installed automatically. To run TDengine CLI in an environment where no TDengine server is running, the TDengine client installation package needs to be installed first. For details, please refer to [Connector](/reference/connector/).
## Execution
@@ -23,6 +23,7 @@ TDengine CLI will display a welcome message and version information if it succes
```cmd
taos>
```
+
After entering the TDengine CLI, you can execute various SQL commands, including inserts, queries, or administrative commands.
## Execute SQL script file
@@ -51,32 +52,33 @@ You can change the behavior of TDengine CLI by specifying command-line parameter
- -P PORT: Specify the port number to be used by the server. Default is `6030`
- -u USER: the user name to use when connecting. Default is `root`
- -p PASSWORD: the password to use when connecting to the server. Default is `taosdata`
-- -?, --help: print out all command-line arguments
+- -?, --help: print out all command-line arguments
And many more parameters.
-- -a AUTHSTR: The auth string to use when connecting to the server
-- -A: Generate auth string from password
+- -a AUTHSTR: Authorization information to connect to the server.
+- -A: Obtain authorization information from username and password.
- -c CONFIGDIR: Specify the directory where configuration file exists. The default is `/etc/taos`, and the default name of the configuration file in this directory is `taos.cfg`
- -C: Print the configuration parameters of `taos.cfg` in the default directory or specified by -c
- -d DATABASE: Specify the database to use when connecting to the server
-- -f FILE: Execute the SQL script file in non-interactive mode
-- -k: Check the service status, 0: unavailable,1: network ok,2: service ok,3: service degraded,4: exiting
-- -l PKTLEN: Test package length to be used for network testing
-- -n NETROLE: test scope for network connection test, default is `client`. The value can be `client`, `server`
-- -N PKTNUM: Test package numbers to be used for network testing
+- -f FILE: Execute the SQL script file in non-interactive mode Note that each SQL statement in the script file must be only one line.
+- -k: Test the operational status of the server. 0: unavailable; 1: network ok; 2: service ok; 3: service degraded; 4: exiting
+- -l PKTLEN: Test package size to be used for network testing
+- -n NETROLE: test scope for network connection test, default is `client`. The value can be `client` or `server`.
+- -N PKTNUM: Number of packets used for network testing
- -r: output the timestamp format as unsigned 64-bits integer (uint64_t in C language)
- -s COMMAND: execute SQL commands in non-interactive mode
-- -t: Check the details of the service status,status same as -k
-- -w DISPLAYWIDTH: 客户端列显示宽度
-- -z, --timezone=TIMEZONE: Specify time zone. Default is the value of current configuration file
-- -V, --version: Print out the current version number
+- -t: Test the boot status of the server. The statuses of -k apply.
+- -w DISPLAYWIDTH: Specify the number of columns of the server display.
+- -z TIMEZONE: Specify time zone. Default is the value of current configuration file
+- -V: Print out the current version number
-Example.
+For example:
```bash
taos -h h1.taos.com -s "use db; show tables;"
```
+
## TDengine CLI tips
- You can use the up and down keys to iterate the history of commands entered
diff --git a/docs/en/14-reference/09-support-platform/index.md b/docs/en/14-reference/09-support-platform/index.md
index 0bb269f2329097975f665b9318b2ec3f320fca5b..19c984898d9037d4414fe13157060fe744b8e179 100644
--- a/docs/en/14-reference/09-support-platform/index.md
+++ b/docs/en/14-reference/09-support-platform/index.md
@@ -5,11 +5,10 @@ description: "List of platforms supported by TDengine server, client, and connec
## List of supported platforms for TDengine server
-| | **Windows server 2016/2019** | **Windows 10/11** | **CentOS 7.9/8** | **Ubuntu 18/20** | **UOS** | **kylin** | **Ningsi V60/V80** |
-| ------------------ | ---------------------------- | ----------------- | ---------------- | ---------------- | ------- | --------- | ------------------ |
-| X64 | ● | ● | ● | ● | ● | ● | ● |
-| Raspberry Pi ARM64 | | | ● | | | | |
-| HUAWEI Cloud ARM64 | | | | ● | | | |
+| | **Windows Server 2016/2019** | **Windows 10/11** | **CentOS 7.9/8** | **Ubuntu 18/20** |
+| ------------ | ---------------------------- | ----------------- | ---------------- | ---------------- |
+| X64 | ● | ● | ● | ● |
+| ARM64 | | | ● | |
Note: ● means officially tested and verified, ○ means unofficially tested and verified.
diff --git a/docs/en/14-reference/11-docker/index.md b/docs/en/14-reference/11-docker/index.md
index b7e60ab3e7f04a6078950977a563382a3524ebaa..7cd1e810dca010d16b0f2e257d47e012c6ef06cc 100644
--- a/docs/en/14-reference/11-docker/index.md
+++ b/docs/en/14-reference/11-docker/index.md
@@ -1,6 +1,6 @@
---
title: Deploying TDengine with Docker
-Description: "This chapter focuses on starting the TDengine service in a container and accessing it."
+description: "This chapter focuses on starting the TDengine service in a container and accessing it."
---
This chapter describes how to start the TDengine service in a container and access it. Users can control the behavior of the service in the container by using environment variables on the docker run command-line or in the docker-compose file.
@@ -24,13 +24,10 @@ The TDengine client taos can be executed in this container to access TDengine us
```shell
$ docker exec -it tdengine taos
-Welcome to the TDengine shell from Linux, Client Version:2.4.0.0
-Copyright (c) 2020 by TAOS Data, Inc.
-
taos> show databases;
- name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status | status precision | update | status |
-================================================================================================================================== ================================================================================================================================== ================
- log | 2022-01-17 13:57:22.270 | 10 | 1 | 1 | 1 | 10 | 30 | 1 | 3 | 100 | 4096 | 1 | 3000 | 2 | 0 | us | 0 | ready |
+ name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status |
+====================================================================================================================================================================================================================================================================================
+ log | 2022-01-17 13:57:22.270 | 10 | 1 | 1 | 1 | 10 | 30 | 1 | 3 | 100 | 4096 | 1 | 3000 | 2 | 0 | us | 0 | ready |
Query OK, 1 row(s) in set (0.002843s)
```
@@ -47,13 +44,10 @@ The above command starts TDengine on the host network and uses the host's FQDN t
```shell
$ taos
-Welcome to the TDengine shell from Linux, Client Version:2.4.0.0
-Copyright (c) 2020 by TAOS Data, Inc.
-
taos> show dnodes;
- id | end_point | vnodes | cores | status | role | create_time | offline reason |
-================================================================================================================================== ====
- 1 | myhost:6030 | 1 | 8 | ready | any | 2022-01-17 22:10:32.619 | |
+ id | end_point | vnodes | cores | status | role | create_time | offline reason |
+======================================================================================================================================
+ 1 | myhost:6030 | 1 | 8 | ready | any | 2022-01-17 22:10:32.619 | |
Query OK, 1 row(s) in set (0.003233s)
```
@@ -78,7 +72,7 @@ Next, ensure the hostname "tdengine" is resolvable in `/etc/hosts`.
echo 127.0.0.1 tdengine |sudo tee -a /etc/hosts
```
-Finally, the TDengine service can be accessed from the taos shell or any connector with "tdengine" as the server address.
+Finally, the TDengine service can be accessed from the TDengine CLI or any connector with "tdengine" as the server address.
```shell
taos -h tdengine -P 6030
@@ -88,13 +82,13 @@ If set `TAOS_FQDN` to the same hostname, the effect is the same as "Start TDengi
## Start TDengine on the specified network
-You can also start TDengine on a specific network.
+You can also start TDengine on a specific network. Perform the following steps:
1. First, create a docker network named `td-net`
```shell
docker network create td-net
- ``` Create td-net
+ ```
2. Start TDengine
@@ -111,7 +105,7 @@ You can also start TDengine on a specific network.
```shell
docker run --rm -it --network td-net -e TAOS_FIRST_EP=tdengine tdengine/tdengine taos
# or
- # docker run --rm -it --network td-net -e tdengine/tdengine taos -h tdengine
+ #docker run --rm -it --network td-net -e tdengine/tdengine taos -h tdengine
```
## Launching a client application in a container
@@ -121,8 +115,8 @@ If you want to start your application in a container, you need to add the corres
```docker
FROM ubuntu:20.04
RUN apt-get update && apt-get install -y wget
-ENV TDENGINE_VERSION=2.4.0.0
-RUN wget -c https://www.taosdata.com/assets-download/TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \
+ENV TDENGINE_VERSION=3.0.0.0
+RUN wget -c https://www.taosdata.com/assets-download/3.0/TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \
&& tar xvf TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \
&& cd TDengine-client-${TDENGINE_VERSION} \
&& ./install_client.sh \
@@ -147,7 +141,7 @@ import (
"fmt"
"time"
- _ "github.com/taosdata/driver-go/v2/taosSql"
+ _ "github.com/taosdata/driver-go/v3/taosSql"
)
type config struct {
@@ -222,8 +216,8 @@ Here is the full Dockerfile:
```docker
FROM golang:1.17.6-buster as builder
-ENV TDENGINE_VERSION=2.4.0.0
-RUN wget -c https://www.taosdata.com/assets-download/TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \
+ENV TDENGINE_VERSION=3.0.0.0
+RUN wget -c https://www.taosdata.com/assets-download/3.0/TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \
&& tar xvf TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \
&& cd TDengine-client-${TDENGINE_VERSION} \
&& ./install_client.sh \
@@ -238,8 +232,8 @@ RUN go build
FROM ubuntu:20.04
RUN apt-get update && apt-get install -y wget
-ENV TDENGINE_VERSION=2.4.0.0
-RUN wget -c https://www.taosdata.com/assets-download/TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \
+ENV TDENGINE_VERSION=3.0.0.0
+RUN wget -c https://www.taosdata.com/assets-download/3.0/TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \
&& tar xvf TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \
&& cd TDengine-client-${TDENGINE_VERSION} \
&& ./install_client.sh \
@@ -316,17 +310,17 @@ password: taosdata
```
:::note
+
- The `VERSION` environment variable is used to set the tdengine image tag
- - `TAOS_FIRST_EP` must be set on the newly created instance so that it can join the TDengine cluster; if there is a high availability requirement, `TAOS_SECOND_EP` needs to be used at the same time
- - `TAOS_REPLICA` is used to set the default number of database replicas. Its value range is [1,3]
- We recommend setting it with `TAOS_ARBITRATOR` to use arbitrator in a two-nodes environment.
-
- :::
+- `TAOS_FIRST_EP` must be set on the newly created instance so that it can join the TDengine cluster; if there is a high availability requirement, `TAOS_SECOND_EP` needs to be used at the same time
+- `TAOS_REPLICA` is used to set the default number of database replicas. Its value range is [1,3]
+ We recommend setting it with `TAOS_ARBITRATOR` to use arbitrator in a two-nodes environment.
+ :::
2. Start the cluster
```shell
- $ VERSION=2.4.0.0 docker-compose up -d
+ $ VERSION=3.0.0.0 docker-compose up -d
Creating network "test_default" with the default driver
Creating volume "test_taosdata-td1" with default driver
Creating volume "test_taoslog-td1" with default driver
@@ -353,9 +347,6 @@ password: taosdata
```shell
$ docker-compose exec td-1 taos -s "show dnodes"
- Welcome to the TDengine shell from Linux, Client Version:2.4.0.0
- Copyright (c) 2020 by TAOS Data, Inc. All rights reserved.
-
taos> show dnodes
id | end_point | vnodes | cores | status | role | create_time | offline reason |
======================================================================================================================================
@@ -371,15 +362,15 @@ password: taosdata
2. At the same time, for flexible deployment, taosAdapter can be started in a separate container
- ```docker
- services:
- # ...
- adapter:
- image: tdengine/tdengine:$VERSION
- command: taosadapter
- ````
+ ```docker
+ services:
+ # ...
+ adapter:
+ image: tdengine/tdengine:$VERSION
+ command: taosadapter
+ ```
- Suppose you want to deploy multiple taosAdapters to improve throughput and provide high availability. In that case, the recommended configuration method uses a reverse proxy such as Nginx to offer a unified access entry. For specific configuration methods, please refer to the official documentation of Nginx. Here is an example:
+ Suppose you want to deploy multiple taosAdapters to improve throughput and provide high availability. In that case, the recommended configuration method uses a reverse proxy such as Nginx to offer a unified access entry. For specific configuration methods, please refer to the official documentation of Nginx. Here is an example:
```docker
version: "3"
@@ -466,7 +457,7 @@ If you want to deploy a container-based TDengine cluster on multiple hosts, you
The docker-compose file can refer to the previous section. Here is the command to start TDengine with docker swarm:
```shell
-$ VERSION=2.4.0 docker stack deploy -c docker-compose.yml taos
+$ VERSION=3.0.0.0 docker stack deploy -c docker-compose.yml taos
Creating network taos_inter
Creating network taos_api
Creating service taos_arbitrator
@@ -482,20 +473,20 @@ Checking status:
$ docker stack ps taos
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
79ni8temw59n taos_nginx.1 nginx:latest TM1701 Running Running about a minute ago
-3e94u72msiyg taos_adapter.1 tdengine/tdengine:2.4.0 TM1702 Running Running 56 seconds ago
-100amjkwzsc6 taos_td-2.1 tdengine/tdengine:2.4.0 TM1703 Running Running about a minute ago
-pkjehr2vvaaa taos_td-1.1 tdengine/tdengine:2.4.0 TM1704 Running Running 2 minutes ago
-tpzvgpsr1qkt taos_arbitrator.1 tdengine/tdengine:2.4.0 TM1705 Running Running 2 minutes ago
-rvss3g5yg6fa taos_adapter.2 tdengine/tdengine:2.4.0 TM1706 Running Running 56 seconds ago
-i2augxamfllf taos_adapter.3 tdengine/tdengine:2.4.0 TM1707 Running Running 56 seconds ago
-lmjyhzccpvpg taos_adapter.4 tdengine/tdengine:2.4.0 TM1708 Running Running 56 seconds ago
+3e94u72msiyg taos_adapter.1 tdengine/tdengine:3.0.0.0 TM1702 Running Running 56 seconds ago
+100amjkwzsc6 taos_td-2.1 tdengine/tdengine:3.0.0.0 TM1703 Running Running about a minute ago
+pkjehr2vvaaa taos_td-1.1 tdengine/tdengine:3.0.0.0 TM1704 Running Running 2 minutes ago
+tpzvgpsr1qkt taos_arbitrator.1 tdengine/tdengine:3.0.0.0 TM1705 Running Running 2 minutes ago
+rvss3g5yg6fa taos_adapter.2 tdengine/tdengine:3.0.0.0 TM1706 Running Running 56 seconds ago
+i2augxamfllf taos_adapter.3 tdengine/tdengine:3.0.0.0 TM1707 Running Running 56 seconds ago
+lmjyhzccpvpg taos_adapter.4 tdengine/tdengine:3.0.0.0 TM1708 Running Running 56 seconds ago
$ docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
-561t4lu6nfw6 taos_adapter replicated 4/4 tdengine/tdengine:2.4.0
-3hk5ct3q90sm taos_arbitrator replicated 1/1 tdengine/tdengine:2.4.0
+561t4lu6nfw6 taos_adapter replicated 4/4 tdengine/tdengine:3.0.0.0
+3hk5ct3q90sm taos_arbitrator replicated 1/1 tdengine/tdengine:3.0.0.0
d8qr52envqzu taos_nginx replicated 1/1 nginx:latest *:6041->6041/tcp, *:6044->6044/udp
-2isssfvjk747 taos_td-1 replicated 1/1 tdengine/tdengine:2.4.0
-9pzw7u02ichv taos_td-2 replicated 1/1 tdengine/tdengine:2.4.0
+2isssfvjk747 taos_td-1 replicated 1/1 tdengine/tdengine:3.0.0.0
+9pzw7u02ichv taos_td-2 replicated 1/1 tdengine/tdengine:3.0.0.0
```
From the above output, you can see two dnodes, two taosAdapters, and one Nginx reverse proxy service.
@@ -511,5 +502,5 @@ verify: Service converged
$ docker service ls -f name=taos_adapter
ID NAME MODE REPLICAS IMAGE PORTS
-561t4lu6nfw6 taos_adapter replicated 1/1 tdengine/tdengine:2.4.0
+561t4lu6nfw6 taos_adapter replicated 1/1 tdengine/tdengine:3.0.0.0
```
diff --git a/docs/en/14-reference/12-config/index.md b/docs/en/14-reference/12-config/index.md
index b6b535429b00796b5d2636c467153415a4281e59..02921c3f6a4ce21175504c3c07bd51bb4a3dcf60 100644
--- a/docs/en/14-reference/12-config/index.md
+++ b/docs/en/14-reference/12-config/index.md
@@ -1,16 +1,13 @@
---
-sidebar_label: Configuration
title: Configuration Parameters
description: "Configuration parameters for client and server in TDengine"
---
-In this chapter, all the configuration parameters on both server and client side are described thoroughly.
-
## Configuration File on Server Side
On the server side, the actual service of TDengine is provided by an executable `taosd` whose parameters can be configured in file `taos.cfg` to meet the requirements of different use cases. The default location of `taos.cfg` is `/etc/taos`, but can be changed by using `-c` parameter on the CLI of `taosd`. For example, the configuration file can be put under `/home/user` and used like below
-```bash
+```
taosd -c /home/user
```
@@ -24,8 +21,6 @@ taosd -C
TDengine CLI `taos` is the tool for users to interact with TDengine. It can share same configuration file as `taosd` or use a separate configuration file. When launching `taos`, parameter `-c` can be used to specify the location where its configuration file is. For example `taos -c /home/cfg` means `/home/cfg/taos.cfg` will be used. If `-c` is not used, the default location of the configuration file is `/etc/taos`. For more details please use `taos --help` to get.
-From version 2.0.10.0 below commands can be used to show the configuration parameters of the client side.
-
```bash
taos -C
```
@@ -36,6 +31,11 @@ taos --dump-config
# Configuration Parameters
+:::note
+The parameters described in this document by the effect that they have on the system.
+
+:::
+
:::note
`taosd` needs to be restarted for the parameters changed in the configuration file to take effect.
@@ -45,19 +45,19 @@ taos --dump-config
### firstEp
-| Attribute | Description |
-| ------------- | ---------------------------------------------------------------------------------------------------- |
-| Applicable | Server and Client |
+| Attribute | Description |
+| -------- | -------------------------------------------------------------- |
+| Applicable | Server and Client |
| Meaning | The end point of the first dnode in the cluster to be connected to when `taosd` or `taos` is started |
-| Default Value | localhost:6030 |
+| Default | localhost:6030 |
### secondEp
-| Attribute | Description |
-| ------------- | ---------------------------------------------------------------------------------------------------------------------- |
-| Applicable | Server and Client |
+| Attribute | Description |
+| -------- | ------------------------------------------------------------------------------------- |
+| Applicable | Server and Client |
| Meaning | The end point of the second dnode to be connected to if the firstEp is not available when `taosd` or `taos` is started |
-| Default Value | None |
+| Default | None |
### fqdn
@@ -65,36 +65,28 @@ taos --dump-config
| ------------- | ------------------------------------------------------------------------ |
| Applicable | Server Only |
| Meaning | The FQDN of the host where `taosd` will be started. It can be IP address |
-| Default Value | The first hostname configured for the host |
-| Note | It should be within 96 bytes |
+| Default Value | The first hostname configured for the host |
+| Note | It should be within 96 bytes | |
### serverPort
-| Attribute | Description |
-| ------------- | ------------------------------------------------------------------------------------------------------------------------------- |
-| Applicable | Server Only |
+| Attribute | Description |
+| -------- | ----------------------------------------------------------------------------------------------------------------------- |
+| Applicable | Server Only |
| Meaning | The port for external access after `taosd` is started |
| Default Value | 6030 |
-| Note | REST service is provided by `taosd` before 2.4.0.0 but by `taosAdapter` after 2.4.0.0, the default port of REST service is 6041 |
:::note
-TDengine uses 13 continuous ports, both TCP and UDP, starting with the port specified by `serverPort`. You should ensure, in your firewall rules, that these ports are kept open. Below table describes the ports used by TDengine in details.
-
+- Ensure that your firewall rules do not block TCP port 6042 on any host in the cluster. Below table describes the ports used by TDengine in details.
:::
-
| Protocol | Default Port | Description | How to configure |
| :------- | :----------- | :----------------------------------------------- | :--------------------------------------------------------------------------------------------- |
-| TCP | 6030 | Communication between client and server | serverPort |
-| TCP | 6035 | Communication among server nodes in cluster | serverPort+5 |
-| TCP | 6040 | Data syncup among server nodes in cluster | serverPort+10 |
+| TCP | 6030 | Communication between client and server. In a multi-node cluster, communication between nodes. serverPort |
| TCP | 6041 | REST connection between client and server | Prior to 2.4.0.0: serverPort+11; After 2.4.0.0 refer to [taosAdapter](/reference/taosadapter/) |
-| TCP | 6042 | Service Port of Arbitrator | The parameter of Arbitrator |
-| TCP | 6043 | Service Port of TaosKeeper | The parameter of TaosKeeper |
-| TCP | 6044 | Data access port for StatsD | refer to [taosAdapter](/reference/taosadapter/) |
-| UDP | 6045 | Data access for statsd | refer to [taosAdapter](/reference/taosadapter/) |
-| TCP | 6060 | Port of Monitoring Service in Enterprise version | |
-| UDP | 6030-6034 | Communication between client and server | serverPort |
-| UDP | 6035-6039 | Communication among server nodes in cluster | serverPort |
+| TCP | 6043 | Service Port of TaosKeeper | The parameter of TaosKeeper |
+| TCP | 6044 | Data access port for StatsD | Configurable through taosAdapter parameters.
+| UDP | 6045 | Data access for statsd | Configurable through taosAdapter parameters.
+| TCP | 6060 | Port of Monitoring Service in Enterprise version | |
### maxShellConns
@@ -105,104 +97,109 @@ TDengine uses 13 continuous ports, both TCP and UDP, starting with the port spec
| Value Range | 10-50000000 |
| Default Value | 5000 |
-### maxConnections
+## Monitoring Parameters
-| Attribute | Description |
-| ------------- | ----------------------------------------------------------------------------- |
-| Applicable | Server Only |
-| Meaning | The maximum number of connections allowed by a database |
-| Value Range | 1-100000 |
-| Default Value | 5000 |
-| Note | The maximum number of worker threads on the client side is maxConnections/100 |
+### monitor
-### rpcForceTcp
+| Attribute | Description |
+| -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| Applicable | Server only |
+| Meaning | The switch for monitoring inside server. The main object of monitoring is to collect information about load on physical nodes, including CPU usage, memory usage, disk usage, and network bandwidth. Monitoring information is sent over HTTP to the taosKeeper service specified by `monitorFqdn` and `monitorProt`.
+| Value Range | 0: monitoring disabled, 1: monitoring enabled |
+| Default | 1 |
-| Attribute | Description |
-| ------------- | ------------------------------------------------------------------- |
-| Applicable | Server and Client |
-| Meaning | TCP is used by force |
-| Value Range | 0: disabled 1: enabled |
-| Default Value | 0 |
-| Note | It's suggested to configure to enable if network is not good enough |
+### monitorFqdn
-## Monitoring Parameters
+| Attribute | Description |
+| -------- | -------------------------- |
+| Applicable | Server Only |
+| Meaning | FQDN of taosKeeper monitoring service |
+| Default | None |
-### monitor
+### monitorPort
-| Attribute | Description |
-| ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| Applicable | Server Only |
-| Meaning | The switch for monitoring inside server. The workload of the hosts, including CPU, memory, disk, network, TTP requests, are collected and stored in a system builtin database `LOG` |
-| Value Range | 0: monitoring disabled, 1: monitoring enabled |
-| Default Value | 1 |
+| Attribute | Description |
+| -------- | --------------------------- |
+| Applicable | Server Only |
+| Meaning | Port of taosKeeper monitoring service |
+| Default Value | 6043 |
### monitorInterval
-| Attribute | Description |
-| ------------- | ------------------------------------------ |
-| Applicable | Server Only |
+| Attribute | Description |
+| -------- | -------------------------------------------- |
+| Applicable | Server Only |
| Meaning | The interval of collecting system workload |
| Unit | second |
-| Value Range | 1-600 |
-| Default Value | 30 |
+| Value Range | 1-200000 |
+| Default Value | 30 |
### telemetryReporting
-| Attribute | Description |
-| ------------- | ---------------------------------------------------------------------------- |
-| Applicable | Server Only |
+| Attribute | Description |
+| -------- | ---------------------------------------- |
+| Applicable | Server Only |
| Meaning | Switch for allowing TDengine to collect and report service usage information |
| Value Range | 0: Not allowed; 1: Allowed |
-| Default Value | 1 |
+| Default Value | 1 |
## Query Parameters
-### queryBufferSize
+### queryPolicy
+
+| Attribute | Description |
+| -------- | ----------------------------- |
+| Applicable | Client only |
+| Meaning | Execution policy for query statements |
+| Unit | None |
+| Default | 1 |
+| Notes | 1: Run queries on vnodes and not on qnodes |
+
+2: Run subtasks without scan operators on qnodes and subtasks with scan operators on vnodes.
+
+3: Only run scan operators on vnodes; run all other operators on qnodes.
+
+### querySmaOptimize
+
+| Attribute | Description |
+| -------- | -------------------- |
+| Applicable | Client only |
+| 含义 | SMA index optimization policy |
+| Unit | None |
+| Default Value | 0 |
+| Notes |
-| Attribute | Description |
-| ------------- | ---------------------------------------------------------------------------------------- |
-| Applicable | Server Only |
-| Meaning | The total memory size reserved for all queries |
-| Unit | MB |
-| Default Value | None |
-| Note | It can be estimated by "maximum number of concurrent queries" _ "number of tables" _ 170 |
+0: Disable SMA indexing and perform all queries on non-indexed data.
-### ratioOfQueryCores
+1: Enable SMA indexing and perform queries from suitable statements on precomputation results.|
-| Attribute | Description |
-| ------------- | ----------------------------------------------------------------------------------------------------- |
-| Applicable | Server Only |
-| Meaning | Maximum number of query threads |
-| Default Value | 1 |
-| Note | value range: float number between [0, 2] 0: only 1 query thread; >0: the times of the number of cores |
### maxNumOfDistinctRes
-| Attribute | Description |
-| ------------- | -------------------------------------------- |
-| Applicable | Server Only |
+| Attribute | Description |
+| -------- | -------------------------------- | --- |
+| Applicable | Server Only |
| Meaning | The maximum number of distinct rows returned |
| Value Range | [100,000 - 100,000,000] |
| Default Value | 100,000 |
-| Note | After version 2.3.0.0 |
## Locale Parameters
### timezone
-| Attribute | Description |
-| ------------- | ------------------------------- |
-| Applicable | Server and Client |
+| Attribute | Description |
+| -------- | ------------------------------ |
+| Applicable | Server and Client |
| Meaning | TimeZone |
| Default Value | TimeZone configured in the host |
:::info
-To handle the data insertion and data query from multiple timezones, Unix Timestamp is used and stored in TDengine. The timestamp generated from any timezones at same time is same in Unix timestamp. To make sure the time on client side can be converted to Unix timestamp correctly, the timezone must be set properly.
+To handle the data insertion and data query from multiple timezones, Unix Timestamp is used and stored in TDengine. The timestamp generated from any timezones at same time is same in Unix timestamp. Note that Unix timestamps are converted and recorded on the client side. To make sure the time on client side can be converted to Unix timestamp correctly, the timezone must be set properly.
-On Linux system, TDengine clients automatically obtain timezone from the host. Alternatively, the timezone can be configured explicitly in configuration file `taos.cfg` like below.
+On Linux system, TDengine clients automatically obtain timezone from the host. Alternatively, the timezone can be configured explicitly in configuration file `taos.cfg` like below. For example:
```
-timezone UTC-7
+timezone UTC-8
timezone GMT-8
timezone Asia/Shanghai
```
@@ -240,11 +237,11 @@ To avoid the problems of using time strings, Unix timestamp can be used directly
| Default Value | Locale configured in host |
:::info
-A specific type "nchar" is provided in TDengine to store non-ASCII characters such as Chinese, Japanese, and Korean. The characters to be stored in nchar type are firstly encoded in UCS4-LE before sending to server side. To store non-ASCII characters correctly, the encoding format of the client side needs to be set properly.
+A specific type "nchar" is provided in TDengine to store non-ASCII characters such as Chinese, Japanese, and Korean. The characters to be stored in nchar type are firstly encoded in UCS4-LE before sending to server side. Note that the correct encoding is determined by the user. To store non-ASCII characters correctly, the encoding format of the client side needs to be set properly.
The characters input on the client side are encoded using the default system encoding, which is UTF-8 on Linux, or GB18030 or GBK on some systems in Chinese, POSIX in docker, CP936 on Windows in Chinese. The encoding of the operating system in use must be set correctly so that the characters in nchar type can be converted to UCS4-LE.
-The locale definition standard on Linux is: \_., for example, in "zh_CN.UTF-8", "zh" means Chinese, "CN" means China mainland, "UTF-8" means charset. On Linux and Mac OSX, the charset can be set by locale in the system. On Windows system another configuration parameter `charset` must be used to configure charset because the locale used on Windows is not POSIX standard. Of course, `charset` can also be used on Linux to specify the charset.
+The locale definition standard on Linux is: \_., for example, in "zh_CN.UTF-8", "zh" means Chinese, "CN" means China mainland, "UTF-8" means charset. The charset indicates how to display the characters. On Linux and Mac OSX, the charset can be set by locale in the system. On Windows system another configuration parameter `charset` must be used to configure charset because the locale used on Windows is not POSIX standard. Of course, `charset` can also be used on Linux to specify the charset.
:::
@@ -257,29 +254,37 @@ The locale definition standard on Linux is: \_., f
| Default Value | charset set in the system |
:::info
-On Linux, if `charset` is not set in `taos.cfg`, when `taos` is started, the charset is obtained from system locale. If obtaining charset from system locale fails, `taos` would fail to start. So on Linux system, if system locale is set properly, it's not necessary to set `charset` in `taos.cfg`. For example:
+On Linux, if `charset` is not set in `taos.cfg`, when `taos` is started, the charset is obtained from system locale. If obtaining charset from system locale fails, `taos` would fail to start.
+
+So on Linux system, if system locale is set properly, it's not necessary to set `charset` in `taos.cfg`. For example:
```
locale zh_CN.UTF-8
```
+On Windows system, it's not possible to obtain charset from system locale. If it's not set in configuration file `taos.cfg`, it would be default to CP936, same as set as below in `taos.cfg`. For example
+
+```
+charset CP936
+```
+
+Refer to the documentation for your operating system before changing the charset.
+
On a Linux system, if the charset contained in `locale` is not consistent with that set by `charset`, the later setting in the configuration file takes precedence.
-```title="Effective charset is GBK"
+```
locale zh_CN.UTF-8
charset GBK
```
-```title="Effective charset is UTF-8"
+The charset that takes effect is GBK.
+
+```
charset GBK
locale zh_CN.UTF-8
```
-On Windows system, it's not possible to obtain charset from system locale. If it's not set in configuration file `taos.cfg`, it would be default to CP936, same as set as below in `taos.cfg`. For example
-
-```
-charset CP936
-```
+The charset that takes effect is UTF-8.
:::
@@ -287,429 +292,98 @@ charset CP936
### dataDir
-| Attribute | Description |
-| ------------- | ------------------------------------------- |
+| Attribute | Description |
+| -------- | ------------------------------------------ |
| Applicable | Server Only |
| Meaning | All data files are stored in this directory |
| Default Value | /var/lib/taos |
-### cache
-
-| Attribute | Description |
-| ------------- | ----------------------------- |
-| Applicable | Server Only |
-| Meaning | The size of each memory block |
-| Unit | MB |
-| Default Value | 16 |
-
-### blocks
-
-| Attribute | Description |
-| ------------- | -------------------------------------------------------------- |
-| Applicable | Server Only |
-| Meaning | The number of memory blocks of size `cache` used by each vnode |
-| Default Value | 6 |
-
-### days
-
-| Attribute | Description |
-| ------------- | ----------------------------------------------------- |
-| Applicable | Server Only |
-| Meaning | The time range of the data stored in single data file |
-| Unit | day |
-| Default Value | 10 |
-
-### keep
-
-| Attribute | Description |
-| ------------- | -------------------------------------- |
-| Applicable | Server Only |
-| Meaning | The number of days for data to be kept |
-| Unit | day |
-| Default Value | 3650 |
-
-### minRows
-
-| Attribute | Description |
-| ------------- | ------------------------------------------ |
-| Applicable | Server Only |
-| Meaning | minimum number of rows in single data file |
-| Default Value | 100 |
-
-### maxRows
-
-| Attribute | Description |
-| ------------- | ------------------------------------------ |
-| Applicable | Server Only |
-| Meaning | maximum number of rows in single data file |
-| Default Value | 4096 |
-
-### walLevel
-
-| Attribute | Description |
-| ------------- | ---------------------------------------------------------------------------------- |
-| Applicable | Server Only |
-| Meaning | WAL level |
-| Value Range | 0: wal disabled 1: wal enabled without fsync 2: wal enabled with fsync |
-| Default Value | 1 |
-
-### fsync
-
-| Attribute | Description |
-| ------------- | --------------------------------------------------------------------------------------------------------------------- |
-| Applicable | Server Only |
-| Meaning | The waiting time for invoking fsync when walLevel is 2 |
-| Unit | millisecond |
-| Value Range | 0: no waiting time, fsync is performed immediately once WAL is written; maximum value is 180000, i.e. 3 minutes |
-| Default Value | 3000 |
-
-### update
-
-| Attribute | Description |
-| ------------- | ------------------------------------------------------------------------------------------------------ |
-| Applicable | Server Only |
-| Meaning | If it's allowed to update existing data |
-| Value Range | 0: not allowed 1: a row can only be updated as a whole 2: a part of columns can be updated |
-| Default Value | 0 |
-| Note | Not available from version 2.0.8.0 |
-
-### cacheLast
-
-| Attribute | Description |
-| ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| Applicable | Server Only |
-| Meaning | Whether to cache the latest rows of each sub table in memory |
-| Value Range | 0: not cached 1: the last row of each sub table is cached 2: the last non-null value of each column is cached 3: identical to both 1 and 2 are set |
-| Default Value | 0 |
-
### minimalTmpDirGB
-| Attribute | Description |
-| ------------- | ----------------------------------------------------------------------------------------------- |
-| Applicable | Server and Client |
+| Attribute | Description |
+| -------- | ------------------------------------------------ |
+| Applicable | Server and Client |
| Meaning | When the available disk space in tmpDir is below this threshold, writing to tmpDir is suspended |
-| Unit | GB |
-| Default Value | 1.0 |
+| Unit | GB |
+| Default Value | 1.0 |
### minimalDataDirGB
-| Attribute | Description |
-| ------------- | ------------------------------------------------------------------------------------------------ |
-| Applicable | Server Only |
-| Meaning | hen the available disk space in dataDir is below this threshold, writing to dataDir is suspended |
-| Unit | GB |
-| Default Value | 2.0 |
-
-### vnodeBak
-
-| Attribute | Description |
-| ------------- | --------------------------------------------------------------------------- |
-| Applicable | Server Only |
-| Meaning | Whether to backup the corresponding vnode directory when a vnode is deleted |
-| Value Range | 0: not backed up, 1: backup |
-| Default Value | 1 |
+| Attribute | Description |
+| -------- | ------------------------------------------------ |
+| Applicable | Server Only |
+| Meaning | When the available disk space in dataDir is below this threshold, writing to dataDir is suspended |
+| Unit | GB |
+| Default Value | 2.0 |
## Cluster Parameters
-### numOfMnodes
-
-| Attribute | Description |
-| ------------- | ------------------------------ |
-| Applicable | Server Only |
-| Meaning | The number of management nodes |
-| Default Value | 3 |
-
-### replica
-
-| Attribute | Description |
-| ------------- | -------------------------- |
-| Applicable | Server Only |
-| Meaning | The number of replications |
-| Value Range | 1-3 |
-| Default Value | 1 |
-
-### quorum
-
-| Attribute | Description |
-| ------------- | ------------------------------------------------------------------------------------------ |
-| Applicable | Server Only |
-| Meaning | The number of required confirmations for data replication in case of multiple replications |
-| Value Range | 1,2 |
-| Default Value | 1 |
-
-### role
-
-| Attribute | Description |
-| ------------- | --------------------------------------------------------------- |
-| Applicable | Server Only |
-| Meaning | The role of the dnode |
-| Value Range | 0: both mnode and vnode 1: mnode only 2: dnode only |
-| Default Value | 0 |
-
-### balance
-
-| Attribute | Description |
-| ------------- | ------------------------ |
-| Applicable | Server Only |
-| Meaning | Automatic load balancing |
-| Value Range | 0: disabled, 1: enabled |
-| Default Value | 1 |
-
-### balanceInterval
-
-| Attribute | Description |
-| ------------- | ----------------------------------------------- |
-| Applicable | Server Only |
-| Meaning | The interval for checking load balance by mnode |
-| Unit | second |
-| Value Range | 1-30000 |
-| Default Value | 300 |
-
-### arbitrator
+### supportVnodes
-| Attribute | Description |
-| ------------- | -------------------------------------------------- |
-| Applicable | Server Only |
-| Meaning | End point of arbitrator, format is same as firstEp |
-| Default Value | None |
+| Attribute | Description |
+| -------- | --------------------------- |
+| Applicable | Server Only |
+| Meaning | Maximum number of vnodes per dnode |
+| Value Range | 0-4096 |
+| Default Value | 256 |
## Time Parameters
-### precision
-
-| Attribute | Description |
-| ------------- | ------------------------------------------------- |
-| Applicable | Server only |
-| Meaning | Time precision used for each database |
-| Value Range | ms: millisecond; us: microsecond ; ns: nanosecond |
-| Default Value | ms |
-
-### rpcTimer
-
-| Attribute | Description |
-| ------------- | ------------------ |
-| Applicable | Server and Client |
-| Meaning | rpc retry interval |
-| Unit | milliseconds |
-| Value Range | 100-3000 |
-| Default Value | 300 |
-
-### rpcMaxTime
-
-| Attribute | Description |
-| ------------- | ---------------------------------- |
-| Applicable | Server and Client |
-| Meaning | maximum wait time for rpc response |
-| Unit | second |
-| Value Range | 100-7200 |
-| Default Value | 600 |
-
### statusInterval
-| Attribute | Description |
-| ------------- | ----------------------------------------------- |
-| Applicable | Server Only |
+| Attribute | Description |
+| -------- | --------------------------- |
+| Applicable | Server Only |
| Meaning | the interval of dnode reporting status to mnode |
| Unit | second |
-| Value Range | 1-10 |
-| Default Value | 1 |
+| Value Range | 1-10 |
+| Default Value | 1 |
### shellActivityTimer
-| Attribute | Description |
-| ------------- | ------------------------------------------------------ |
-| Applicable | Server and Client |
-| Meaning | The interval for taos shell to send heartbeat to mnode |
-| Unit | second |
-| Value Range | 1-120 |
-| Default Value | 3 |
-
-### tableMetaKeepTimer
-
-| Attribute | Description |
-| ------------- | -------------------------------------------------------------------------------------------------- |
-| Applicable | Server Only |
-| Meaning | The expiration time for metadata in cache, once it's reached the client would refresh the metadata |
-| Unit | second |
-| Value Range | 1-8640000 |
-| Default Value | 7200 |
-
-### maxTmrCtrl
-
-| Attribute | Description |
-| ------------- | ------------------------ |
-| Applicable | Server and Client |
-| Meaning | Maximum number of timers |
-| Unit | None |
-| Value Range | 8-2048 |
-| Default Value | 512 |
-
-### offlineThreshold
-
-| Attribute | Description |
-| ------------- | ----------------------------------------------------------------------------------------------------------------------------- |
-| Applicable | Server Only |
-| Meaning | The expiration time for dnode online status, once it's reached before receiving status from a node, the dnode becomes offline |
-| Unit | second |
-| Value Range | 5-7200000 |
-| Default Value | 86400\*10 (i.e. 10 days) |
-
-## Performance Optimization Parameters
-
-### numOfThreadsPerCore
-
-| Attribute | Description |
-| ------------- | ------------------------------------------- |
-| Applicable | Server and Client |
-| Meaning | The number of consumer threads per CPU core |
-| Default Value | 1.0 |
-
-### ratioOfQueryThreads
-
-| Attribute | Description |
-| ------------- | --------------------------------------------------------------------------------------------- |
-| Applicable | Server Only |
-| Meaning | Maximum number of query threads |
-| Value Range | 0: Only one query thread 1: Same as number of CPU cores 2: two times of CPU cores |
-| Default Value | 1 |
-| Note | This value can be a float number, 0.5 means half of the CPU cores |
-
-### maxVgroupsPerDb
-
-| Attribute | Description |
-| ------------- | ------------------------------------ |
-| Applicable | Server Only |
-| Meaning | Maximum number of vnodes for each DB |
-| Value Range | 0-8192 |
-| Default Value | |
-
-### maxTablesPerVnode
-
| Attribute | Description |
-| ------------- | -------------------------------------- |
-| Applicable | Server Only |
-| Meaning | Maximum number of tables in each vnode |
-| Default Value | 1000000 |
-
-### minTablesPerVnode
-
-| Attribute | Description |
-| ------------- | -------------------------------------- |
-| Applicable | Server Only |
-| Meaning | Minimum number of tables in each vnode |
-| Default Value | 1000 |
-
-### tableIncStepPerVnode
-
-| Attribute | Description |
-| ------------- | ------------------------------------------------------------------------------------------- |
-| Applicable | Server Only |
-| Meaning | When minTablesPerVnode is reached, the number of tables are allocated for a vnode each time |
-| Default Value | 1000 |
-
-### maxNumOfOrderedRes
-
-| Attribute | Description |
-| ------------- | ------------------------------------------- |
-| Applicable | Server and Client |
-| Meaning | Maximum number of rows ordered for a STable |
-| Default Value | 100,000 |
-
-### mnodeEqualVnodeNum
+| -------- | --------------------------------- |
+| Applicable | Server and Client |
+| Meaning | The interval for TDengine CLI to send heartbeat to mnode |
+| Unit | second |
+| Value Range | 1-120 |
+| Default Value | 3 |
-| Attribute | Description |
-| ------------- | ----------------------------------------------------------------------------------------------- |
-| Applicable | Server Only |
-| Meaning | The number of vnodes whose system resources consumption are considered as equal to single mnode |
-| Default Value | 4 |
+## Performance Optimization Parameters
### numOfCommitThreads
-| Attribute | Description |
-| ------------- | ----------------------------------------- |
-| Applicable | Server Only |
+| Attribute | Description |
+| -------- | ---------------------- |
+| Applicable | Server Only |
| Meaning | Maximum of threads for committing to disk |
-| Default Value | |
+| Default Value | |
## Compression Parameters
-### comp
-
-| Attribute | Description |
-| ------------- | ------------------------------------------------------------------- |
-| Applicable | Server Only |
-| Meaning | Whether data is compressed |
-| Value Range | 0: uncompressed, 1: One phase compression, 2: Two phase compression |
-| Default Value | 2 |
-
-### tsdbMetaCompactRatio
-
-| Attribute | Description |
-| ------------- | ------------------------------------------------------------------------------------------- |
-| Meaning | The threshold for percentage of redundant in meta file to trigger compression for meta file |
-| Value Range | 0: no compression forever, [1-100]: The threshold percentage |
-| Default Value | 0 |
-
### compressMsgSize
-| Attribute | Description |
-| ------------- | -------------------------------------------------------------------------------- |
-| Applicable | Server Only |
-| Meaning | The threshold for message size to compress the message.. |
+| Attribute | Description |
+| ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| Applicable | Server Only |
+| Meaning | The threshold for message size to compress the message. | Set the value to 64330 bytes for good message compression. |
| Unit | bytes |
| Value Range | 0: already compress; >0: compress when message exceeds it; -1: always uncompress |
-| Default Value | -1 |
+| Default Value | -1 |
### compressColData
-| Attribute | Description |
-| ------------- | ------------------------------------------------------------------------------------------------------------------- |
-| Applicable | Server Only |
-| Meaning | The threshold for size of column data to trigger compression for the query result |
+| Attribute | Description |
+| -------- | --------------------------------------------------------------------------------------- |
+| Applicable | Server Only |
+| Meaning | The threshold for size of column data to trigger compression for the query result |
| Unit | bytes |
| Value Range | 0: always compress; >0: only compress when the size of any column data exceeds the threshold; -1: always uncompress |
+| Default Value | -1 |
| Default Value | -1 |
-| Note | available from version 2.3.0.0 |
+| Note | available from version 2.3.0.0 | |
-### lossyColumns
-
-| Attribute | Description |
-| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
-| Applicable | Server Only |
-| Meaning | The floating number types for lossy compression |
-| Value Range | "": lossy compression is disabled float: only for float double: only for double float \| double: for both float and double |
-| Default Value | "" , i.e. disabled |
-
-### fPrecision
-
-| Attribute | Description |
-| ------------- | ----------------------------------------------------------- |
-| Applicable | Server Only |
-| Meaning | Compression precision for float type |
-| Value Range | 0.1 ~ 0.00000001 |
-| Default Value | 0.00000001 |
-| Note | The fractional part lower than this value will be discarded |
-
-### dPrecision
-
-| Attribute | Description |
-| ------------- | ----------------------------------------------------------- |
-| Applicable | Server Only |
-| Meaning | Compression precision for double type |
-| Value Range | 0.1 ~ 0.0000000000000001 |
-| Default Value | 0.0000000000000001 |
-| Note | The fractional part lower than this value will be discarded |
-
-## Continuous Query Parameters
-
-### stream
-
-| Attribute | Description |
-| ------------- | ---------------------------------- |
-| Applicable | Server Only |
-| Meaning | Whether to enable continuous query |
-| Value Range | 0: disabled 1: enabled |
-| Default Value | 1 |
+## Continuous Query Parameters |
### minSlidingTime
@@ -731,390 +405,444 @@ charset CP936
| Value Range | 1-1000000 |
| Default Value | 10 |
-### maxStreamCompDelay
-
-| Attribute | Description |
-| ------------- | ------------------------------------------------ |
-| Applicable | Server Only |
-| Meaning | Maximum delay before starting a continuous query |
-| Unit | millisecond |
-| Value Range | 10-1000000000 |
-| Default Value | 20000 |
-
-### maxFirstStreamCompDelay
-
-| Attribute | Description |
-| ------------- | -------------------------------------------------------------------- |
-| Applicable | Server Only |
-| Meaning | Maximum delay time before starting a continuous query the first time |
-| Unit | millisecond |
-| Value Range | 10-1000000000 |
-| Default Value | 10000 |
-
-### retryStreamCompDelay
-
-| Attribute | Description |
-| ------------- | --------------------------------------------- |
-| Applicable | Server Only |
-| Meaning | Delay time before retrying a continuous query |
-| Unit | millisecond |
-| Value Range | 10-1000000000 |
-| Default Value | 10 |
-
-### streamCompDelayRatio
-
-| Attribute | Description |
-| ------------- | ------------------------------------------------------------------------ |
-| Applicable | Server Only |
-| Meaning | The delay ratio, with time window size as the base, for continuous query |
-| Value Range | 0.1-0.9 |
-| Default Value | 0.1 |
-
:::info
To prevent system resource from being exhausted by multiple concurrent streams, a random delay is applied on each stream automatically. `maxFirstStreamCompDelay` is the maximum delay time before a continuous query is started the first time. `streamCompDelayRatio` is the ratio for calculating delay time, with the size of the time window as base. `maxStreamCompDelay` is the maximum delay time. The actual delay time is a random time not bigger than `maxStreamCompDelay`. If a continuous query fails, `retryStreamComDelay` is the delay time before retrying it, also not bigger than `maxStreamCompDelay`.
:::
-## HTTP Parameters
-
-:::note
-HTTP service was provided by `taosd` prior to version 2.4.0.0 and is provided by `taosAdapter` after version 2.4.0.0.
-The parameters described in this section are only application in versions prior to 2.4.0.0. If you are using any version from 2.4.0.0, please refer to [taosAdapter](/reference/taosadapter/).
-
-:::
-
-### http
-
-| Attribute | Description |
-| ------------- | ------------------------------ |
-| Applicable | Server Only |
-| Meaning | Whether to enable http service |
-| Value Range | 0: disabled, 1: enabled |
-| Default Value | 1 |
-
-### httpEnableRecordSql
-
-| Attribute | Description |
-| ------------- | ------------------------------------------------------------------------- |
-| Applicable | Server Only |
-| Meaning | Whether to record the SQL invocation through REST interface |
-| Default Value | 0: false; 1: true |
-| Note | The resulting files, i.e. httpnote.0/httpnote.1, are located under logDir |
-
-### httpMaxThreads
-
-| Attribute | Description |
-| ------------- | -------------------------------------------- |
-| Applicable | Server Only |
-| Meaning | The number of threads for RESTFul interface. |
-| Default Value | 2 |
-
-### restfulRowLimit
-
-| Attribute | Description |
-| ------------- | ------------------------------------------------------------ |
-| Applicable | Server Only |
-| Meaning | Maximum number of rows returned each time by REST interface. |
-| Default Value | 10240 |
-| Note | Maximum value is 10,000,000 |
-
-### httpDBNameMandatory
-
-| Attribute | Description |
-| ------------- | ---------------------------------------- |
-| Applicable | Server Only |
-| Meaning | Whether database name is required in URL |
-| Value Range | 0:not required, 1: required |
-| Default Value | 0 |
-| Note | From version 2.3.0.0 |
-
## Log Parameters
### logDir
-| Attribute | Description |
-| ------------- | ----------------------------------- |
-| Applicable | Server and Client |
+| Attribute | Description |
+| -------- | -------------------------------------------------- |
+| Applicable | Server and Client |
| Meaning | The directory for writing log files |
| Default Value | /var/log/taos |
### minimalLogDirGB
-| Attribute | Description |
-| ------------- | -------------------------------------------------------------------------------------------------- |
-| Applicable | Server and Client |
+| Attribute | Description |
+| -------- | -------------------------------------------- |
+| Applicable | Server and Client |
| Meaning | When the available disk space in logDir is below this threshold, writing to log files is suspended |
-| Unit | GB |
-| Default Value | 1.0 |
+| Unit | GB |
+| Default Value | 1.0 |
### numOfLogLines
-| Attribute | Description |
-| ------------- | ------------------------------------------ |
-| Applicable | Server and Client |
+| Attribute | Description |
+| -------- | ---------------------------- |
+| Applicable | Server and Client |
| Meaning | Maximum number of lines in single log file |
-| Default Value | 10,000,000 |
+| Default Value | 10000000 |
### asyncLog
-| Attribute | Description |
-| ------------- | ---------------------------- |
-| Applicable | Server and Client |
+| Attribute | Description |
+| -------- | -------------------- |
+| Applicable | Server and Client |
| Meaning | The mode of writing log file |
| Value Range | 0: sync way; 1: async way |
-| Default Value | 1 |
+| Default Value | 1 |
### logKeepDays
-| Attribute | Description |
-| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
-| Applicable | Server and Client |
+| Attribute | Description |
+| -------- | ----------------------------------------------------------------------------------- |
+| Applicable | Server and Client |
| Meaning | The number of days for log files to be kept |
-| Unit | day |
-| Default Value | 0 |
+| Unit | day |
+| Default Value | 0 |
| Note | When it's bigger than 0, the log file would be renamed to "taosdlog.xxx" in which "xxx" is the timestamp when the file is changed last time |
### debugFlag
-| Attribute | Description |
-| ------------- | --------------------------------------------------------- |
-| Applicable | Server and Client |
+| Attribute | Description |
+| -------- | ------------------------------------------------------------------------------------------------- |
+| Applicable | Server and Client |
| Meaning | Log level |
| Value Range | 131: INFO/WARNING/ERROR; 135: plus DEBUG; 143: plus TRACE |
| Default Value | 131 or 135, depending on the module |
-### mDebugFlag
+### tmrDebugFlag
-| Attribute | Description |
-| ------------- | ------------------ |
-| Applicable | Server Only |
-| Meaning | Log level of mnode |
+| Attribute | Description |
+| -------- | -------------------- |
+| Applicable | Server and Client |
+| Meaning | Log level of timer module |
| Value Range | same as debugFlag |
-| Default Value | 135 |
+| Default Value | |
-### dDebugFlag
+### uDebugFlag
-| Attribute | Description |
-| ------------- | ------------------ |
-| Applicable | Server and Client |
-| Meaning | Log level of dnode |
+| Attribute | Description |
+| -------- | ---------------------- |
+| Applicable | Server and Client |
+| Meaning | Log level of common module |
| Value Range | same as debugFlag |
-| Default Value | 135 |
-
-### sDebugFlag
-
-| Attribute | Description |
-| ------------- | ------------------------ |
-| Applicable | Server and Client |
-| Meaning | Log level of sync module |
-| Value Range | same as debugFlag |
-| Default Value | 135 |
-
-### wDebugFlag
-
-| Attribute | Description |
-| ------------- | ----------------------- |
-| Applicable | Server and Client |
-| Meaning | Log level of WAL module |
-| Value Range | same as debugFlag |
-| Default Value | 135 |
-
-### sdbDebugFlag
-
-| Attribute | Description |
-| ------------- | ---------------------- |
-| Applicable | Server and Client |
-| Meaning | logLevel of sdb module |
-| Value Range | same as debugFlag |
-| Default Value | 135 |
+| Default Value | |
### rpcDebugFlag
-| Attribute | Description |
-| ------------- | ----------------------- |
-| Applicable | Server and Client |
+| Attribute | Description |
+| -------- | -------------------- |
+| Applicable | Server and Client |
| Meaning | Log level of rpc module |
-| Value Range | Same as debugFlag |
-| Default Value | |
+| Value Range | same as debugFlag |
+| Default Value | |
-### tmrDebugFlag
+### jniDebugFlag
-| Attribute | Description |
-| ------------- | ------------------------- |
+| Attribute | Description |
+| -------- | ------------------ |
+| Applicable | Client Only |
+| Meaning | Log level of jni module |
+| Value Range | same as debugFlag |
+| Default Value | |
+
+### qDebugFlag
+
+| Attribute | Description |
+| -------- | -------------------- |
| Applicable | Server and Client |
-| Meaning | Log level of timer module |
-| Value Range | Same as debugFlag |
-| Default Value | |
+| Meaning | Log level of query module |
+| Value Range | same as debugFlag |
+| Default Value | |
### cDebugFlag
-| Attribute | Description |
-| ------------- | ------------------- |
+| Attribute | Description |
+| -------- | --------------------- |
| Applicable | Client Only |
| Meaning | Log level of Client |
-| Value Range | Same as debugFlag |
-| Default Value | |
-
-### jniDebugFlag
-
-| Attribute | Description |
-| ------------- | ----------------------- |
-| Applicable | Client Only |
-| Meaning | Log level of jni module |
-| Value Range | Same as debugFlag |
-| Default Value | |
-
-### odbcDebugFlag
-
-| Attribute | Description |
-| ------------- | ------------------------ |
-| Applicable | Client Only |
-| Meaning | Log level of odbc module |
-| Value Range | Same as debugFlag |
-| Default Value | |
+| Value Range | same as debugFlag |
+| Default Value | |
-### uDebugFlag
+### dDebugFlag
-| Attribute | Description |
-| ------------- | -------------------------- |
-| Applicable | Server and Client |
-| Meaning | Log level of common module |
-| Value Range | Same as debugFlag |
-| Default Value | |
+| Attribute | Description |
+| -------- | -------------------- |
+| Applicable | Server Only |
+| Meaning | Log level of dnode |
+| Value Range | same as debugFlag |
+| Default Value | 135 |
-### httpDebugFlag
+### vDebugFlag
-| Attribute | Description |
-| ------------- | ------------------------------------------- |
-| Applicable | Server Only |
-| Meaning | Log level of http module (prior to 2.4.0.0) |
-| Value Range | Same as debugFlag |
-| Default Value | |
+| Attribute | Description |
+| -------- | -------------------- |
+| Applicable | Server Only |
+| Meaning | Log level of vnode |
+| Value Range | same as debugFlag |
+| Default Value | |
-### mqttDebugFlag
+### mDebugFlag
-| Attribute | Description |
-| ------------- | ------------------------ |
-| Applicable | Server Only |
-| Meaning | Log level of mqtt module |
-| Value Range | Same as debugFlag |
-| Default Value | |
+| Attribute | Description |
+| -------- | -------------------- |
+| Applicable | Server Only |
+| Meaning | Log level of mnode module |
+| Value Range | same as debugFlag |
+| Default Value | 135 |
-### monitorDebugFlag
+### wDebugFlag
-| Attribute | Description |
-| ------------- | ------------------------------ |
-| Applicable | Server Only |
-| Meaning | Log level of monitoring module |
-| Value Range | Same as debugFlag |
-| Default Value | |
+| Attribute | Description |
+| -------- | ------------------ |
+| Applicable | Server Only |
+| Meaning | Log level of WAL module |
+| Value Range | same as debugFlag |
+| Default Value | 135 |
-### qDebugFlag
+### sDebugFlag
-| Attribute | Description |
-| ------------- | ------------------------- |
+| Attribute | Description |
+| -------- | -------------------- |
| Applicable | Server and Client |
-| Meaning | Log level of query module |
-| Value Range | Same as debugFlag |
-| Default Value | |
-
-### vDebugFlag
-
-| Attribute | Description |
-| ------------- | ------------------ |
-| Applicable | Server and Client |
-| Meaning | Log level of vnode |
-| Value Range | Same as debugFlag |
-| Default Value | |
+| Meaning | Log level of sync module |
+| Value Range | same as debugFlag |
+| Default Value | 135 |
### tsdbDebugFlag
-| Attribute | Description |
-| ------------- | ------------------------ |
-| Applicable | Server Only |
-| Meaning | Log level of TSDB module |
-| Value Range | Same as debugFlag |
-| Default Value | |
+| Attribute | Description |
+| -------- | ------------------- |
+| Applicable | Server Only |
+| Meaning | Log level of TSDB module |
+| Value Range | same as debugFlag |
+| Default Value | |
-### cqDebugFlag
+### tqDebugFlag
| Attribute | Description |
-| ------------- | ------------------------------------ |
-| Applicable | Server and Client |
-| Meaning | Log level of continuous query module |
-| Value Range | Same as debugFlag |
-| Default Value | |
+| -------- | ----------------- |
+| Applicable | Server only |
+| Meaning | Log level of TQ module |
+| Value Range | same as debugFlag |
+| Default Value | |
-## Client Only
+### fsDebugFlag
-### maxSQLLength
+| Attribute | Description |
+| -------- | ----------------- |
+| Applicable | Server only |
+| Meaning | Log level of FS module |
+| Value Range | same as debugFlag |
+| Default Value | |
+
+### udfDebugFlag
| Attribute | Description |
-| ------------- | -------------------------------------- |
-| Applicable | Client Only |
-| Meaning | Maximum length of single SQL statement |
-| Unit | bytes |
-| Value Range | 65480-1048576 |
-| Default Value | 1048576 |
+| -------- | ------------------ |
+| Applicable | Server Only |
+| Meaning | Log level of UDF module |
+| Value Range | same as debugFlag |
+| Default Value | |
+
+### smaDebugFlag
-### tscEnableRecordSql
+| Attribute | Description |
+| -------- | ------------------ |
+| Applicable | Server Only |
+| Meaning | Log level of SMA module |
+| Value Range | same as debugFlag |
+| Default Value | |
-| Attribute | Description |
-| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
-| Meaning | Whether to record SQL statements in file |
-| Value Range | 0: false, 1: true |
-| Default Value | 0 |
-| Note | The generated files are named as "tscnote-xxxx.0/tscnote-xxx.1" in which "xxxx" is the pid of the client, and located at same place as client log |
+### idxDebugFlag
-### maxBinaryDisplayWidth
+| Attribute | Description |
+| -------- | -------------------- |
+| Applicable | Server Only |
+| Meaning | Log level of index module |
+| Value Range | same as debugFlag |
+| Default Value | |
-| Attribute | Description |
-| ------------- | --------------------------------------------------------------------------------------------------- |
-| Meaning | Maximum display width of binary and nchar in taos shell. Anything beyond this limit would be hidden |
-| Value Range | 5 - |
-| Default Value | 30 |
+### tdbDebugFlag
-:::info
-If the length of value exceeds `maxBinaryDisplayWidth`, then the actual display width is max(column name, maxBinaryDisplayLength); otherwise the actual display width is max(length of column name, length of column value). This parameter can also be changed dynamically using `set max_binary_display_width ` in TDengine CLI `taos`.
+| Attribute | Description |
+| -------- | ------------------ |
+| Applicable | Server Only |
+| Meaning | Log level of TDB module |
+| Value Range | same as debugFlag |
+| Default Value | |
-:::
+## Schemaless Parameters
-### maxWildCardsLength
+### smlChildTableName
-| Attribute | Description |
-| ------------- | ----------------------------------------------------- |
-| Meaning | The maximum length for wildcard string used with LIKE |
-| Unit | bytes |
-| Value Range | 0-16384 |
-| Default Value | 100 |
-| Note | From version 2.1.6.1 |
+| Attribute | Description |
+| -------- | ------------------------- |
+| Applicable | Client only |
+| Meaning | Custom subtable name for schemaless writes |
+| Type | String |
+| Default Value | None |
-### clientMerge
+### smlTagName
-| Attribute | Description |
-| ------------- | --------------------------------------------------- |
-| Meaning | Whether to filter out duplicate data on client side |
-| Value Range | 0: false; 1: true |
-| Default Value | 0 |
-| Note | From version 2.3.0.0 |
+| Attribute | Description |
+| -------- | ------------------------------------ |
+| Applicable | Client only |
+| Meaning | Default tag for schemaless writes without tag value specified |
+| Type | String |
+| Default Value | _tag_null |
-### maxRegexStringLen
+### smlDataFormat
| Attribute | Description |
-| ------------- | ------------------------------------ |
-| Meaning | Maximum length of regular expression |
-| Value Range | [128, 16384] |
-| Default Value | 128 |
-| Note | From version 2.3.0.0 |
+| -------- | ----------------------------- |
+| Applicable | Client only |
+| Meaning | Whether schemaless columns are consistently ordered |
+| Value Range | 0: not consistent; 1: consistent. |
+| Default | 1 |
## Other Parameters
### enableCoreFile
-| Attribute | Description |
-| ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| Attribute | Description |
+| -------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| Applicable | Server and Client |
| Meaning | Whether to generate core file when server crashes |
| Value Range | 0: false, 1: true |
| Default Value | 1 |
| Note | The core file is generated under root directory `systemctl start taosd` is used to start, or under the working directory if `taosd` is started directly on Linux Shell. |
+
+### udf
+
+| Attribute | Description |
+| -------- | ------------------ |
+| Applicable | Server Only |
+| Meaning | Whether the UDF service is enabled |
+| Value Range | 0: disable UDF; 1: enabled UDF |
+| Default Value | 1 |
+
+## Parameter Comparison of TDengine 2.x and 3.0
+| # | **Parameter** | **In 2.x** | **In 3.0** |
+| --- | :-----------------: | --------------- | --------------- |
+| 1 | firstEp | Yes | Yes |
+| 2 | secondEp | Yes | Yes |
+| 3 | fqdn | Yes | Yes |
+| 4 | serverPort | Yes | Yes |
+| 5 | maxShellConns | Yes | Yes |
+| 6 | monitor | Yes | Yes |
+| 7 | monitorFqdn | No | Yes |
+| 8 | monitorPort | No | Yes |
+| 9 | monitorInterval | Yes | Yes |
+| 10 | monitorMaxLogs | No | Yes |
+| 11 | monitorComp | No | Yes |
+| 12 | telemetryReporting | Yes | Yes |
+| 13 | telemetryInterval | No | Yes |
+| 14 | telemetryServer | No | Yes |
+| 15 | telemetryPort | No | Yes |
+| 16 | queryPolicy | No | Yes |
+| 17 | querySmaOptimize | No | Yes |
+| 18 | queryBufferSize | Yes | Yes |
+| 19 | maxNumOfDistinctRes | Yes | Yes |
+| 20 | minSlidingTime | Yes | Yes |
+| 21 | minIntervalTime | Yes | Yes |
+| 22 | countAlwaysReturnValue | Yes | Yes |
+| 23 | dataDir | Yes | Yes |
+| 24 | minimalDataDirGB | Yes | Yes |
+| 25 | supportVnodes | No | Yes |
+| 26 | tempDir | Yes | Yes |
+| 27 | minimalTmpDirGB | Yes | Yes |
+| 28 | compressMsgSize | Yes | Yes |
+| 29 | compressColData | Yes | Yes |
+| 30 | smlChildTableName | Yes | Yes |
+| 31 | smlTagName | Yes | Yes |
+| 32 | smlDataFormat | No | Yes |
+| 33 | statusInterval | Yes | Yes |
+| 34 | shellActivityTimer | Yes | Yes |
+| 35 | transPullupInterval | No | Yes |
+| 36 | mqRebalanceInterval | No | Yes |
+| 37 | ttlUnit | No | Yes |
+| 38 | ttlPushInterval | No | Yes |
+| 39 | numOfTaskQueueThreads | No | Yes |
+| 40 | numOfRpcThreads | No | Yes |
+| 41 | numOfCommitThreads | Yes | Yes |
+| 42 | numOfMnodeReadThreads | No | Yes |
+| 43 | numOfVnodeQueryThreads | No | Yes |
+| 44 | numOfVnodeStreamThreads | No | Yes |
+| 45 | numOfVnodeFetchThreads | No | Yes |
+| 46 | numOfVnodeWriteThreads | No | Yes |
+| 47 | numOfVnodeSyncThreads | No | Yes |
+| 48 | numOfQnodeQueryThreads | No | Yes |
+| 49 | numOfQnodeFetchThreads | No | Yes |
+| 50 | numOfSnodeSharedThreads | No | Yes |
+| 51 | numOfSnodeUniqueThreads | No | Yes |
+| 52 | rpcQueueMemoryAllowed | No | Yes |
+| 53 | logDir | Yes | Yes |
+| 54 | minimalLogDirGB | Yes | Yes |
+| 55 | numOfLogLines | Yes | Yes |
+| 56 | asyncLog | Yes | Yes |
+| 57 | logKeepDays | Yes | Yes |
+| 58 | debugFlag | Yes | Yes |
+| 59 | tmrDebugFlag | Yes | Yes |
+| 60 | uDebugFlag | Yes | Yes |
+| 61 | rpcDebugFlag | Yes | Yes |
+| 62 | jniDebugFlag | Yes | Yes |
+| 63 | qDebugFlag | Yes | Yes |
+| 64 | cDebugFlag | Yes | Yes |
+| 65 | dDebugFlag | Yes | Yes |
+| 66 | vDebugFlag | Yes | Yes |
+| 67 | mDebugFlag | Yes | Yes |
+| 68 | wDebugFlag | Yes | Yes |
+| 69 | sDebugFlag | Yes | Yes |
+| 70 | tsdbDebugFlag | Yes | Yes |
+| 71 | tqDebugFlag | No | Yes |
+| 72 | fsDebugFlag | Yes | Yes |
+| 73 | udfDebugFlag | No | Yes |
+| 74 | smaDebugFlag | No | Yes |
+| 75 | idxDebugFlag | No | Yes |
+| 76 | tdbDebugFlag | No | Yes |
+| 77 | metaDebugFlag | No | Yes |
+| 78 | timezone | Yes | Yes |
+| 79 | locale | Yes | Yes |
+| 80 | charset | Yes | Yes |
+| 81 | udf | Yes | Yes |
+| 82 | enableCoreFile | Yes | Yes |
+| 83 | arbitrator | Yes | No |
+| 84 | numOfThreadsPerCore | Yes | No |
+| 85 | numOfMnodes | Yes | No |
+| 86 | vnodeBak | Yes | No |
+| 87 | balance | Yes | No |
+| 88 | balanceInterval | Yes | No |
+| 89 | offlineThreshold | Yes | No |
+| 90 | role | Yes | No |
+| 91 | dnodeNopLoop | Yes | No |
+| 92 | keepTimeOffset | Yes | No |
+| 93 | rpcTimer | Yes | No |
+| 94 | rpcMaxTime | Yes | No |
+| 95 | rpcForceTcp | Yes | No |
+| 96 | tcpConnTimeout | Yes | No |
+| 97 | syncCheckInterval | Yes | No |
+| 98 | maxTmrCtrl | Yes | No |
+| 99 | monitorReplica | Yes | No |
+| 100 | smlTagNullName | Yes | No |
+| 101 | keepColumnName | Yes | No |
+| 102 | ratioOfQueryCores | Yes | No |
+| 103 | maxStreamCompDelay | Yes | No |
+| 104 | maxFirstStreamCompDelay | Yes | No |
+| 105 | retryStreamCompDelay | Yes | No |
+| 106 | streamCompDelayRatio | Yes | No |
+| 107 | maxVgroupsPerDb | Yes | No |
+| 108 | maxTablesPerVnode | Yes | No |
+| 109 | minTablesPerVnode | Yes | No |
+| 110 | tableIncStepPerVnode | Yes | No |
+| 111 | cache | Yes | No |
+| 112 | blocks | Yes | No |
+| 113 | days | Yes | No |
+| 114 | keep | Yes | No |
+| 115 | minRows | Yes | No |
+| 116 | maxRows | Yes | No |
+| 117 | quorum | Yes | No |
+| 118 | comp | Yes | No |
+| 119 | walLevel | Yes | No |
+| 120 | fsync | Yes | No |
+| 121 | replica | Yes | No |
+| 122 | partitions | Yes | No |
+| 123 | quorum | Yes | No |
+| 124 | update | Yes | No |
+| 125 | cachelast | Yes | No |
+| 126 | maxSQLLength | Yes | No |
+| 127 | maxWildCardsLength | Yes | No |
+| 128 | maxRegexStringLen | Yes | No |
+| 129 | maxNumOfOrderedRes | Yes | No |
+| 130 | maxConnections | Yes | No |
+| 131 | mnodeEqualVnodeNum | Yes | No |
+| 132 | http | Yes | No |
+| 133 | httpEnableRecordSql | Yes | No |
+| 134 | httpMaxThreads | Yes | No |
+| 135 | restfulRowLimit | Yes | No |
+| 136 | httpDbNameMandatory | Yes | No |
+| 137 | httpKeepAlive | Yes | No |
+| 138 | enableRecordSql | Yes | No |
+| 139 | maxBinaryDisplayWidth | Yes | No |
+| 140 | stream | Yes | No |
+| 141 | retrieveBlockingModel | Yes | No |
+| 142 | tsdbMetaCompactRatio | Yes | No |
+| 143 | defaultJSONStrType | Yes | No |
+| 144 | walFlushSize | Yes | No |
+| 145 | keepTimeOffset | Yes | No |
+| 146 | flowctrl | Yes | No |
+| 147 | slaveQuery | Yes | No |
+| 148 | adjustMaster | Yes | No |
+| 149 | topicBinaryLen | Yes | No |
+| 150 | telegrafUseFieldNum | Yes | No |
+| 151 | deadLockKillQuery | Yes | No |
+| 152 | clientMerge | Yes | No |
+| 153 | sdbDebugFlag | Yes | No |
+| 154 | odbcDebugFlag | Yes | No |
+| 155 | httpDebugFlag | Yes | No |
+| 156 | monDebugFlag | Yes | No |
+| 157 | cqDebugFlag | Yes | No |
+| 158 | shortcutFlag | Yes | No |
+| 159 | probeSeconds | Yes | No |
+| 160 | probeKillSeconds | Yes | No |
+| 161 | probeInterval | Yes | No |
+| 162 | lossyColumns | Yes | No |
+| 163 | fPrecision | Yes | No |
+| 164 | dPrecision | Yes | No |
+| 165 | maxRange | Yes | No |
+| 166 | range | Yes | No |
diff --git a/docs/en/14-reference/12-directory.md b/docs/en/14-reference/12-directory.md
index 118bce8037fdae5b303b45988277d10a99aa5445..19b036418f18637bfd21fa286f24528c649d146d 100644
--- a/docs/en/14-reference/12-directory.md
+++ b/docs/en/14-reference/12-directory.md
@@ -29,10 +29,7 @@ All executable files of TDengine are in the _/usr/local/taos/bin_ directory by d
- _set_core.sh_: script for setting up the system to generate core dump files for easy debugging
- _taosd-dump-cfg.gdb_: script to facilitate debugging of taosd's gdb execution.
-:::note
-taosdump after version 2.4.0.0 require taosTools as a standalone installation. A new version of taosBenchmark is include in taosTools too.
-:::
-
:::tip
You can configure different data directories and log directories by modifying the system configuration file `taos.cfg`.
+
:::
diff --git a/docs/en/14-reference/13-schemaless/13-schemaless.md b/docs/en/14-reference/13-schemaless/13-schemaless.md
index 8b6a26ae52af42e339e2f5a8d0824a9e1be3f386..4f50c38cbbfda9d8d8567517f9109f18e2007988 100644
--- a/docs/en/14-reference/13-schemaless/13-schemaless.md
+++ b/docs/en/14-reference/13-schemaless/13-schemaless.md
@@ -1,9 +1,10 @@
---
title: Schemaless Writing
-description: "The Schemaless write method eliminates the need to create super tables/sub tables in advance and automatically creates the storage structure corresponding to the data, as it is written to the interface."
+description: 'The Schemaless write method eliminates the need to create super tables/sub tables in advance and automatically creates the storage structure corresponding to the data, as it is written to the interface.'
---
-In IoT applications, data is collected for many purposes such as intelligent control, business analysis, device monitoring and so on. Due to changes in business or functional requirements or changes in device hardware, the application logic and even the data collected may change. To provide the flexibility needed in such cases and in a rapidly changing IoT landscape, TDengine provides a series of interfaces for the schemaless writing method. These interfaces eliminate the need to create super tables and subtables in advance by automatically creating the storage structure corresponding to the data as the data is written to the interface. When necessary, schemaless writing will automatically add the required columns to ensure that the data written by the user is stored correctly.
+In IoT applications, data is collected for many purposes such as intelligent control, business analysis, device monitoring and so on. Due to changes in business or functional requirements or changes in device hardware, the application logic and even the data collected may change. Schemaless writing automatically creates storage structures for your data as it is being written to TDengine, so that you do not need to create supertables in advance. When necessary, schemaless writing
+will automatically add the required columns to ensure that the data written by the user is stored correctly.
The schemaless writing method creates super tables and their corresponding subtables. These are completely indistinguishable from the super tables and subtables created directly via SQL. You can write data directly to them via SQL statements. Note that the names of tables created by schemaless writing are based on fixed mapping rules for tag values, so they are not explicitly ideographic and they lack readability.
@@ -19,12 +20,12 @@ With the following formatting conventions, schemaless writing uses a single stri
measurement,tag_set field_set timestamp
```
-where :
+where:
- measurement will be used as the data table name. It will be separated from tag_set by a comma.
-- tag_set will be used as tag data in the format `=,=`, i.e. multiple tags' data can be separated by a comma. It is separated from field_set by space.
-- field_set will be used as normal column data in the format of `=,=`, again using a comma to separate multiple normal columns of data. It is separated from the timestamp by a space.
-- The timestamp is the primary key corresponding to the data in this row.
+- `tag_set` will be used as tags, with format like `=,=` Enter a space between `tag_set` and `field_set`.
+- `field_set`will be used as data columns, with format like `=,=` Enter a space between `field_set` and `timestamp`.
+- `timestamp` is the primary key timestamp corresponding to this row of data
All data in tag_set is automatically converted to the NCHAR data type and does not require double quotes (").
@@ -35,18 +36,20 @@ In the schemaless writing data line protocol, each data item in the field_set ne
- Spaces, equal signs (=), commas (,), and double quotes (") need to be escaped with a backslash (\\) in front. (All refer to the ASCII character)
- Numeric types will be distinguished from data types by the suffix.
-| **Serial number** | **Postfix** | **Mapping type** | **Size (bytes)** |
-| -------- | -------- | ------------ | -------------- |
-| 1 | none or f64 | double | 8 |
-| 2 | f32 | float | 4 |
-| 3 | i8/u8 | TinyInt/UTinyInt | 1 |
-| 4 | i16/u16 | SmallInt/USmallInt | 2 |
-| 5 | i32/u32 | Int/UInt | 4 |
-| 6 | i64/i/u64/u | Bigint/Bigint/UBigint/UBigint | 8 |
+| **Serial number** | **Postfix** | **Mapping type** | **Size (bytes)** |
+| ----------------- | ----------- | ----------------------------- | ---------------- |
+| 1 | None or f64 | double | 8 |
+| 2 | f32 | float | 4 |
+| 3 | i8/u8 | TinyInt/UTinyInt | 1 |
+| 4 | i16/u16 | SmallInt/USmallInt | 2 |
+| 5 | i32/u32 | Int/UInt | 4 |
+| 6 | i64/i/u64/u | BigInt/BigInt/UBigInt/UBigInt | 8 |
- `t`, `T`, `true`, `True`, `TRUE`, `f`, `F`, `false`, and `False` will be handled directly as BOOL types.
-For example, the following data rows indicate that the t1 label is "3" (NCHAR), the t2 label is "4" (NCHAR), and the t3 label is "t3" to the super table named `st` labeled "t3" (NCHAR), write c1 column as 3 (BIGINT), c2 column as false (BOOL), c3 column is "passit" (BINARY), c4 column is 4 (DOUBLE), and the primary key timestamp is 1626006833639000000 in one row.
+For example, the following data rows indicate that the t1 label is "3" (NCHAR), the t2 label is "4" (NCHAR), and the t3 label
+is "t3" to the super table named `st` labeled "t3" (NCHAR), write c1 column as 3 (BIGINT), c2 column as false (BOOL), c3 column
+is "passit" (BINARY), c4 column is 4 (DOUBLE), and the primary key timestamp is 1626006833639000000 in one row.
```json
st,t1=3,t2=4,t3=t3 c1=3i64,c3="passit",c2=false,c4=4f64 1626006833639000000
@@ -58,102 +61,105 @@ Note that if the wrong case is used when describing the data type suffix, or if
Schemaless writes process row data according to the following principles.
-1. You can use the following rules to generate the subtable names: first, combine the measurement name and the key and value of the label into the next string:
+1. You can use the following rules to generate the subtable names: first, combine the measurement name and the key and value of the label into the next string:
```json
"measurement,tag_key1=tag_value1,tag_key2=tag_value2"
```
Note that tag_key1, tag_key2 are not the original order of the tags entered by the user but the result of using the tag names in ascending order of the strings. Therefore, tag_key1 is not the first tag entered in the line protocol.
-The string's MD5 hash value "md5_val" is calculated after the ranking is completed. The calculation result is then combined with the string to generate the table name: "t_md5_val". "t*" is a fixed prefix that every table generated by this mapping relationship has.
+The string's MD5 hash value "md5_val" is calculated after the ranking is completed. The calculation result is then combined with the string to generate the table name: "t_md5_val". "t_" is a fixed prefix that every table generated by this mapping relationship has.
+You can configure smlChildTableName to specify table names, for example, `smlChildTableName=tname`. You can insert `st,tname=cpul,t1=4 c1=3 1626006833639000000` and the cpu1 table will be automatically created. Note that if multiple rows have the same tname but different tag_set values, the tag_set of the first row is used to create the table and the others are ignored.
2. If the super table obtained by parsing the line protocol does not exist, this super table is created.
-If the subtable obtained by the parse line protocol does not exist, Schemaless creates the sub-table according to the subtable name determined in steps 1 or 2.
+3. If the subtable obtained by the parse line protocol does not exist, Schemaless creates the sub-table according to the subtable name determined in steps 1 or 2.
4. If the specified tag or regular column in the data row does not exist, the corresponding tag or regular column is added to the super table (only incremental).
-5. If there are some tag columns or regular columns in the super table that are not specified to take values in a data row, then the values of these columns are set to NULL.
+5. If there are some tag columns or regular columns in the super table that are not specified to take values in a data row, then the values of these columns are set to
+ NULL.
6. For BINARY or NCHAR columns, if the length of the value provided in a data row exceeds the column type limit, the maximum length of characters allowed to be stored in the column is automatically increased (only incremented and not decremented) to ensure complete preservation of the data.
7. Errors encountered throughout the processing will interrupt the writing process and return an error code.
-8. In order to improve the efficiency of writing, it is assumed by default that the order of the fields in the same Super is the same (the first data contains all fields, and the following data is in this order). If the order is different, the parameter smlDataFormat needs to be configured to be false. Otherwise, the data is written in the same order, and the data in the library will be abnormal.
+8. It is assumed that the order of field_set in a supertable is consistent, meaning that the first record contains all fields and subsequent records store fields in the same order. If the order is not consistent, set smlDataFormat to false. Otherwise, data will be written out of order and a database error will occur.
:::tip
-All processing logic of schemaless will still follow TDengine's underlying restrictions on data structures, such as the total length of each row of data cannot exceed 16k bytes. See [TAOS SQL Boundary Limits](/taos-sql/limit) for specific constraints in this area.
+All processing logic of schemaless will still follow TDengine's underlying restrictions on data structures, such as the total length of each row of data cannot exceed
+16KB. See [TDengine SQL Boundary Limits](/taos-sql/limit) for specific constraints in this area.
+
:::
## Time resolution recognition
Three specified modes are supported in the schemaless writing process, as follows:
-| **Serial** | **Value** | **Description** |
-| -------- | ------------------- | ------------------------------- |
-| 1 | SML_LINE_PROTOCOL | InfluxDB Line Protocol |
-| 2 | SML_TELNET_PROTOCOL | OpenTSDB Text Line Protocol |
-| 3 | SML_JSON_PROTOCOL | JSON protocol format |
-
-In the SML_LINE_PROTOCOL parsing mode, the user is required to specify the time resolution of the input timestamp. The available time resolutions are shown in the following table.
+| **Serial** | **Value** | **Description** |
+| ---------- | ------------------- | ---------------------- |
+| 1 | SML_LINE_PROTOCOL | InfluxDB Line Protocol |
+| 2 | SML_TELNET_PROTOCOL | OpenTSDB file protocol |
+| 3 | SML_JSON_PROTOCOL | OpenTSDB JSON protocol |
-| **Serial Number** | **Time Resolution Definition** | **Meaning** |
-| -------- | --------------------------------- | -------------- |
-| 1 | TSDB_SML_TIMESTAMP_NOT_CONFIGURED | Not defined (invalid) |
-| 2 | TSDB_SML_TIMESTAMP_HOURS | hour |
-| 3 | TSDB_SML_TIMESTAMP_MINUTES | MINUTES
-| 4 | TSDB_SML_TIMESTAMP_SECONDS | SECONDS
-| 5 | TSDB_SML_TIMESTAMP_MILLI_SECONDS | milliseconds
-| 6 | TSDB_SML_TIMESTAMP_MICRO_SECONDS | microseconds
-| 7 | TSDB_SML_TIMESTAMP_NANO_SECONDS | nanoseconds |
+In InfluxDB line protocol mode, you must specify the precision of the input timestamp. Valid precisions are described in the following table.
-In SML_TELNET_PROTOCOL and SML_JSON_PROTOCOL modes, the time precision is determined based on the length of the timestamp (in the same way as the OpenTSDB standard operation), and the user-specified time resolution is ignored at this point.
+| **No.** | **Precision** | **Description** |
+| ------- | --------------------------------- | --------------------- |
+| 1 | TSDB_SML_TIMESTAMP_NOT_CONFIGURED | Not defined (invalid) |
+| 2 | TSDB_SML_TIMESTAMP_HOURS | Hours |
+| 3 | TSDB_SML_TIMESTAMP_MINUTES | Minutes |
+| 4 | TSDB_SML_TIMESTAMP_SECONDS | Seconds |
+| 5 | TSDB_SML_TIMESTAMP_MILLI_SECONDS | Milliseconds |
+| 6 | TSDB_SML_TIMESTAMP_MICRO_SECONDS | Microseconds |
+| 7 | TSDB_SML_TIMESTAMP_NANO_SECONDS | Nanoseconds |
-## Data schema mapping rules
+In OpenTSDB file and JSON protocol modes, the precision of the timestamp is determined from its length in the standard OpenTSDB manner. User input is ignored.
-This section describes how data for line protocols are mapped to data with a schema. The data measurement in each line protocol is mapped as follows:
-- The tag name in tag_set is the name of the tag in the data schema
-- The name in field_set is the column's name.
+## Data Model Mapping
-The following data is used as an example to illustrate the mapping rules.
+This section describes how data in line protocol is mapped to a schema. The data measurement in each line is mapped to a
+supertable name. The tag name in tag_set is the tag name in the schema, and the name in field_set is the column name in the schema. The following example shows how data is mapped:
```json
st,t1=3,t2=4,t3=t3 c1=3i64,c3="passit",c2=false,c4=4f64 1626006833639000000
```
-The row data mapping generates a super table: `st`, which contains three labels of type NCHAR: t1, t2, t3. Five data columns are ts (timestamp), c1 (bigint), c3 (binary), c2 (bool), c4 (bigint). The mapping becomes the following SQL statement.
+This row is mapped to a supertable: `st` contains three NCHAR tags: t1, t2, and t3. Five columns are created: ts (timestamp), c1 (bigint), c3 (binary), c2 (bool), and c4 (bigint). The following SQL statement is generated:
```json
create stable st (_ts timestamp, c1 bigint, c2 bool, c3 binary(6), c4 bigint) tags(t1 nchar(1), t2 nchar(1), t3 nchar(2))
```
-## Data schema change handling
+## Processing Schema Changes
-This section describes the impact on the data schema for different line protocol data writing cases.
+This section describes the impact on the schema caused by different data being written.
-When writing to an explicitly identified field type using the line protocol, subsequent changes to the field's type definition will result in an explicit data schema error, i.e., will trigger a write API report error. As shown below, the
+If you use line protocol to write to a specific tag field and then later change the field type, a schema error will ocur. This triggers an error on the write API. This is shown as follows:
```json
-st,t1=3,t2=4,t3=t3 c1=3i64,c3="passit",c2=false,c4=4 1626006833639000000
-st,t1=3,t2=4,t3=t3 c1=3i64,c3="passit",c2=false,c4=4i 1626006833640000000
+st,t1=3,t2=4,t3=t3 c1=3i64,c3="passit",c2=false,c4=4 1626006833639000000
+st,t1=3,t2=4,t3=t3 c1=3i64,c3="passit",c2=false,c4=4i 1626006833640000000
```
-The data type mapping in the first row defines column c4 as DOUBLE, but the data in the second row is declared as BIGINT by the numeric suffix, which triggers a parsing error with schemaless writing.
+The first row defines c4 as a double. However, in the second row, the suffix indicates that the value of c4 is a bigint. This causes schemaless writing to throw an error.
-If the line protocol before the column declares the data column as BINARY, the subsequent one requires a longer binary length, which triggers a super table schema change.
+An error also occurs if data input into a binary column exceeds the defined length of the column.
```json
-st,t1=3,t2=4,t3=t3 c1=3i64,c5="pass" 1626006833639000000
-st,t1=3,t2=4,t3=t3 c1=3i64,c5="passit" 1626006833640000000
+st,t1=3,t2=4,t3=t3 c1=3i64,c5="pass" 1626006833639000000
+st,t1=3,t2=4,t3=t3 c1=3i64,c5="passit" 1626006833640000000
```
-The first line of the line protocol parsing will declare column c5 is a BINARY(4) field. The second line data write will parse column c5 as a BINARY column. But in the second line, c5's width is 6 so you need to increase the width of the BINARY field to be able to accommodate the new string.
+The first row defines c5 as a binary(4). but the second row writes 6 bytes to it. This means that the length of the binary column must be expanded to contain the data.
```json
-st,t1=3,t2=4,t3=t3 c1=3i64 1626006833639000000
-st,t1=3,t2=4,t3=t3 c1=3i64,c6="passit" 1626006833640000000
+st,t1=3,t2=4,t3=t3 c1=3i64 1626006833639000000
+st,t1=3,t2=4,t3=t3 c1=3i64,c6="passit" 1626006833640000000
```
-The second line of data has an additional column c6 of type BINARY(6) compared to the first row. Then a column c6 of type BINARY(6) is automatically added at this point.
+The preceding data includes a new entry, c6, with type binary(6). When this occurs, a new column c6 with type binary(6) is added automatically.
-## Write integrity
+## Write Integrity
-TDengine provides idempotency guarantees for data writing, i.e., you can repeatedly call the API to write data with errors. However, it does not give atomicity guarantees for writing multiple rows of data. During the process of writing numerous rows of data in one batch, some data will be written successfully, and some data will fail.
+TDengine guarantees the idempotency of data writes. This means that you can repeatedly call the API to perform write operations with bad data. However, TDengine does not guarantee the atomicity of multi-row writes. In a multi-row write, some data may be written successfully and other data unsuccessfully.
-## Error code
+##: Error Codes
-If it is an error in the data itself during the schemaless writing process, the application will get `TSDB_CODE_TSC_LINE_SYNTAX_ERROR` error message, which indicates that the error occurred in writing. The other error codes are consistent with the TDengine and can be obtained via the `taos_errstr()` to get the specific cause of the error.
+The TSDB_CODE_TSC_LINE_SYNTAX_ERROR indicates an error in the schemaless writing component.
+This error occurs when writing text. For other errors, schemaless writing uses the standard TDengine error codes
+found in taos_errstr.
diff --git a/docs/en/14-reference/14-taosKeeper.md b/docs/en/14-reference/14-taosKeeper.md
new file mode 100644
index 0000000000000000000000000000000000000000..665bc75380d4f59666d792d074fb37c65c810264
--- /dev/null
+++ b/docs/en/14-reference/14-taosKeeper.md
@@ -0,0 +1,143 @@
+---
+sidebar_label: taosKeeper
+title: taosKeeper
+description: exports TDengine monitoring metrics.
+---
+
+## Introduction
+
+taosKeeper is a tool for TDengine that exports monitoring metrics. With taosKeeper, you can easily monitor the operational status of your TDengine deployment. taosKeeper uses the TDengine REST API. It is not necessary to install TDengine Client to use taosKeeper.
+
+## Installation
+
+
+Methods of installing taosKeeper:
+
+
+
+- You can compile taosKeeper separately and install it. Please refer to the [taosKeeper](https://github.com/taosdata/taoskeeper) repository for details. -->
+You can compile taosKeeper separately and install it. Please refer to the [taosKeeper](https://github.com/taosdata/taoskeeper) repository for details.
+
+## Run
+
+### Configuration and running methods
+
+taosKeeper needs to be executed on the terminal of the operating system, it supports three configuration methods: [Command-line arguments](#command-line-arguments-in-detail), [environment variable](#environment-variable-in-detail) and [configuration file](#configuration-file-parameters-in-detail). The precedence of those is Command-line, environment variable and configuration file.
+
+**Make sure that the TDengine cluster is running correctly before running taosKeeper. ** Ensure that the monitoring service in TDengine has been started. For more information, see [TDengine Monitoring Configuration](../config/#monitoring).
+
+### Command-Line Parameters
+
+You can use command-line parameters to run taosKeeper and control its behavior:
+
+```shell
+$ taosKeeper
+```
+### Environment variable
+
+You can use Environment variable to run taosKeeper and control its behavior:
+
+```shell
+$ export TAOS_KEEPER_TDENGINE_HOST=192.168.64.3
+
+$ taoskeeper
+```
+
+you can run `taoskeeper -h` for more detail.
+
+### Configuration File
+
+You can quickly launch taosKeeper with the following commands. If you do not specify a configuration file, `/etc/taos/keeper.toml` is used by default. If this file does not specify configurations, the default values are used.
+
+```shell
+$ taoskeeper -c
+```
+
+**Sample configuration files**
+```toml
+# enable debug in gin framework
+debug = false
+
+# listen to server port, default 6043
+port = 6043
+
+# set log level to panic, error, info, debug, or trace
+loglevel = "info"
+
+# set pool size
+gopoolsize = 50000
+
+# query rotation period for TDengine monitoring data
+RotationInterval = "15s"
+
+[tdengine]
+host = "127.0.0.1"
+port = 6041
+username = "root"
+password = "taosdata"
+
+# set taosAdapter to monitor
+[taosAdapter]
+address = ["127.0.0.1:6041","192.168.1.95:6041"]
+
+[metrics]
+# monitoring metric prefix
+prefix = "taos"
+
+# cluster data identifier
+cluster = "production"
+
+# database to store monitoring data
+database = "log"
+
+# standard tables to monitor
+tables = ["normal_table"]
+```
+
+### Obtain Monitoring Metrics
+
+taosKeeper records monitoring metrics generated by TDengine in a specified database and provides an interface through which you can export the data.
+
+#### View Monitoring Results
+
+```shell
+$ taos
+# the log database is used in this example
+> use log;
+> select * from cluster_info limit 1;
+```
+
+Example result set:
+
+```shell
+ ts | first_ep | first_ep_dnode_id | version | master_uptime | monitor_interval | dbs_total | tbs_total | stbs_total | dnodes_total | dnodes_alive | mnodes_total | mnodes_alive | vgroups_total | vgroups_alive | vnodes_total | vnodes_alive | connections_total | protocol | cluster_id |
+===============================================================================================================================================================================================================================================================================================================================================================================
+ 2022-08-16 17:37:01.629 | hlb:6030 | 1 | 3.0.0.0 | 0.27250 | 15 | 2 | 27 | 38 | 1 | 1 | 1 | 1 | 4 | 4 | 4 | 4 | 14 | 1 | 5981392874047724755 |
+Query OK, 1 rows in database (0.036162s)
+```
+
+#### Export Monitoring Metrics
+
+```shell
+$ curl http://127.0.0.1:6043/metrics
+```
+
+Sample result set (excerpt):
+
+```shell
+# HELP taos_cluster_info_connections_total
+# TYPE taos_cluster_info_connections_total counter
+taos_cluster_info_connections_total{cluster_id="5981392874047724755"} 16
+# HELP taos_cluster_info_dbs_total
+# TYPE taos_cluster_info_dbs_total counter
+taos_cluster_info_dbs_total{cluster_id="5981392874047724755"} 2
+# HELP taos_cluster_info_dnodes_alive
+# TYPE taos_cluster_info_dnodes_alive counter
+taos_cluster_info_dnodes_alive{cluster_id="5981392874047724755"} 1
+# HELP taos_cluster_info_dnodes_total
+# TYPE taos_cluster_info_dnodes_total counter
+taos_cluster_info_dnodes_total{cluster_id="5981392874047724755"} 1
+# HELP taos_cluster_info_first_ep
+# TYPE taos_cluster_info_first_ep gauge
+taos_cluster_info_first_ep{cluster_id="5981392874047724755",value="hlb:6030"} 1
+```
\ No newline at end of file
diff --git a/docs/en/14-reference/_category_.yml b/docs/en/14-reference/_category_.yml
index 5f5466532be79153d42da0907df6336439593601..1fb42e60a7c2872dbf9f66096ea9a38c8aa4a295 100644
--- a/docs/en/14-reference/_category_.yml
+++ b/docs/en/14-reference/_category_.yml
@@ -1 +1 @@
-label: Reference
+label: Reference
\ No newline at end of file
diff --git a/docs/en/14-reference/index.md b/docs/en/14-reference/index.md
index f350eebfc1a1ca2feaedc18c4b4fa798742e31b4..f3a64913d065d1d8e321ce7433c9d605ef70bd13 100644
--- a/docs/en/14-reference/index.md
+++ b/docs/en/14-reference/index.md
@@ -2,11 +2,11 @@
title: Reference
---
-The reference guide is a detailed introduction to TDengine including various TDengine connectors in different languages, and the tools that come with TDengine.
+This section describes the TDengine connectors and utilities.
```mdx-code-block
import DocCardList from '@theme/DocCardList';
import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
-```
+```
\ No newline at end of file
diff --git a/docs/en/20-third-party/01-grafana.mdx b/docs/en/20-third-party/01-grafana.mdx
index 5dbeb31a231464e48b4f977420f03f0ede81e78e..e0fbefd5a8634d2001f2cc0601afa110aff33632 100644
--- a/docs/en/20-third-party/01-grafana.mdx
+++ b/docs/en/20-third-party/01-grafana.mdx
@@ -6,9 +6,7 @@ title: Grafana
import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";
-TDengine can be quickly integrated with the open-source data visualization system [Grafana](https://www.grafana.com/) to build a data monitoring and alerting system. The whole process does not require any code development. And you can visualize the contents of the data tables in TDengine on a dashboard.
-
-You can learn more about using the TDengine plugin on [GitHub](https://github.com/taosdata/grafanaplugin/blob/master/README.md).
+TDengine can be quickly integrated with the open-source data visualization system [Grafana](https://www.grafana.com/) to build a data monitoring and alerting system. The whole process does not require any code development. And you can visualize the contents of the data tables in TDengine on a dashboard. You can learn more about using the TDengine plugin on [GitHub](https://github.com/taosdata/grafanaplugin/blob/master/README.md).
## Prerequisites
@@ -65,7 +63,6 @@ Restart Grafana service and open Grafana in web-browser, usually
-
Follow the installation steps in [Grafana](https://grafana.com/grafana/plugins/tdengine-datasource/?tab=installation) with the [``grafana-cli`` command-line tool](https://grafana.com/docs/grafana/latest/administration/cli/) for plugin installation.
@@ -76,7 +73,7 @@ grafana-cli plugins install tdengine-datasource
sudo -u grafana grafana-cli plugins install tdengine-datasource
```
-Alternatively, you can manually download the .zip file from [GitHub](https://github.com/taosdata/grafanaplugin/releases/tag/latest) or [Grafana](https://grafana.com/grafana/plugins/tdengine-datasource/?tab=installation) and unpack it into your grafana plugins directory.
+You can also download zip files from [GitHub](https://github.com/taosdata/grafanaplugin/releases/tag/latest) or [Grafana](https://grafana.com/grafana/plugins/tdengine-datasource/?tab=installation) and install manually. The commands are as follows:
```bash
GF_VERSION=3.2.2
@@ -131,7 +128,7 @@ docker run -d \
grafana/grafana
```
-You can setup a zero-configuration stack for TDengine + Grafana by [docker-compose](https://docs.docker.com/compose/) and [Grafana provisioning](https://grafana.com/docs/grafana/latest/administration/provisioning/) file:
+You can setup a zero-configuration stack for TDengine + Grafana by [docker-compose](https://docs.docker.com/compose/) and [Grafana provisioning](https://grafana.com/docs/grafana/latest/administration/provisioning/) file:
1. Save the provisioning configuration file to `tdengine.yml`.
@@ -196,7 +193,7 @@ Go back to the main interface to create a dashboard and click Add Query to enter
As shown above, select the `TDengine` data source in the `Query` and enter the corresponding SQL in the query box below for query.
-- INPUT SQL: enter the statement to be queried (the result set of the SQL statement should be two columns and multiple rows), for example: `select avg(mem_system) from log.dn where ts >= $from and ts < $to interval($interval)`, where, from, to and interval are built-in variables of the TDengine plugin, indicating the range and time interval of queries fetched from the Grafana plugin panel. In addition to the built-in variables, custom template variables are also supported.
+- INPUT SQL: Enter the desired query (the results being two columns and multiple rows), such as `select _wstart, avg(mem_system) from log.dnodes_info where ts >= $from and ts < $to interval($interval)`. In this statement, $from, $to, and $interval are variables that Grafana replaces with the query time range and interval. In addition to the built-in variables, custom template variables are also supported.
- ALIAS BY: This allows you to set the current query alias.
- GENERATE SQL: Clicking this button will automatically replace the corresponding variables and generate the final executed statement.
@@ -208,7 +205,11 @@ Follow the default prompt to query the average system memory usage for the speci
### Importing the Dashboard
-You can install TDinsight dashboard in data source configuration page (like `http://localhost:3000/datasources/edit/1/dashboards`) as a monitoring visualization tool for TDengine cluster. The dashboard is published in Grafana as [Dashboard 15167 - TDinsight](https://grafana.com/grafana/dashboards/15167). Check the [TDinsight User Manual](/reference/tdinsight/) for the details.
+You can install TDinsight dashboard in data source configuration page (like `http://localhost:3000/datasources/edit/1/dashboards`) as a monitoring visualization tool for TDengine cluster. Ensure that you use TDinsight for 3.x.
+
+
+
+A dashboard for TDengine 2.x has been published on Grafana: [Dashboard 15167 - TDinsight](https://grafana.com/grafana/dashboards/15167)) 。 Check the [TDinsight User Manual](/reference/tdinsight/) for the details.
For more dashboards using TDengine data source, [search here in Grafana](https://grafana.com/grafana/dashboards/?dataSource=tdengine-datasource). Here is a sub list:
diff --git a/docs/en/20-third-party/06-statsd.md b/docs/en/20-third-party/06-statsd.md
index 40e927b9fd1d2eca9d454a987ac51d533eb75005..32b1bbb97acafd2494c7fadb8af3d06cf69219ea 100644
--- a/docs/en/20-third-party/06-statsd.md
+++ b/docs/en/20-third-party/06-statsd.md
@@ -1,6 +1,6 @@
---
sidebar_label: StatsD
-title: StatsD writing
+title: StatsD Writing
---
import StatsD from "../14-reference/_statsd.mdx"
@@ -12,8 +12,8 @@ You can write StatsD data to TDengine by simply modifying the configuration file
## Prerequisites
To write StatsD data to TDengine requires the following preparations.
-- The TDengine cluster has been deployed and is working properly
-- taosAdapter is installed and running properly. Please refer to the [taosAdapter manual](/reference/taosadapter) for details.
+1. The TDengine cluster is deployed and functioning properly
+2. taosAdapter is installed and running properly. Please refer to the taosAdapter manual for details.
- StatsD has been installed. To install StatsD, please refer to [official documentation](https://github.com/statsd/statsd)
## Configuration steps
@@ -39,9 +39,6 @@ $ echo "foo:1|c" | nc -u -w0 127.0.0.1 8125
Use the TDengine CLI to verify that StatsD data is written to TDengine and can read out correctly.
```
-Welcome to the TDengine shell from Linux, Client Version:2.4.0.0
-Copyright (c) 2020 by TAOS Data, Inc. All rights reserved.
-
taos> show databases;
name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status |
====================================================================================================================================================================================================================================================================================
diff --git a/docs/en/20-third-party/09-emq-broker.md b/docs/en/20-third-party/09-emq-broker.md
index 0900dd3d7571dc0ab8d93174aa2d7b5eccf1fbf5..2ead1bbaf40f06fec2a5cbf85e46fdfdcc5216df 100644
--- a/docs/en/20-third-party/09-emq-broker.md
+++ b/docs/en/20-third-party/09-emq-broker.md
@@ -9,7 +9,7 @@ MQTT is a popular IoT data transfer protocol. [EMQX](https://github.com/emqx/emq
The following preparations are required for EMQX to add TDengine data sources correctly.
- The TDengine cluster is deployed and working properly
-- taosAdapter is installed and running properly. Please refer to the [taosAdapter manual](/reference/taosadapter) for details.
+- taosAdapter is installed and running properly. Please refer to the [taosAdapter manual](../../reference/taosadapter) for details.
- If you use the emulated writers described later, you need to install the appropriate version of Node.js. V12 is recommended.
## Install and start EMQX
@@ -28,8 +28,6 @@ USE test;
CREATE TABLE sensor_data (ts TIMESTAMP, temperature FLOAT, humidity FLOAT, volume FLOAT, pm10 FLOAT, pm25 FLOAT, so2 FLOAT, no2 FLOAT, co FLOAT, sensor_id NCHAR(255), area TINYINT, coll_time TIMESTAMP);
```
-Note: The table schema is based on the blog [(In Chinese) Data Transfer, Storage, Presentation, EMQX + TDengine Build MQTT IoT Data Visualization Platform](https://www.taosdata.com/blog/2020/08/04/1722.html) as an example. Subsequent operations are carried out with this blog scenario too. Please modify it according to your actual application scenario.
-
## Configuring EMQX Rules
Since the configuration interface of EMQX differs from version to version, here is v4.4.5 as an example. For other versions, please refer to the corresponding official documentation.
@@ -137,5 +135,5 @@ Use the TDengine CLI program to log in and query the appropriate databases and t

-Please refer to the [TDengine official documentation](https://docs.taosdata.com/) for more details on how to use TDengine.
+Please refer to the [TDengine official documentation](https://docs.tdengine.com/) for more details on how to use TDengine.
EMQX Please refer to the [EMQX official documentation](https://www.emqx.io/docs/en/v4.4/rule/rule-engine.html) for details on how to use EMQX.
diff --git a/docs/en/20-third-party/10-hive-mq-broker.md b/docs/en/20-third-party/10-hive-mq-broker.md
index 333e00fa0e9b724ffbb067a83ad07d0b846b1a23..828a62ac5b336766d5c3770cc42cd3a61cfd8d5d 100644
--- a/docs/en/20-third-party/10-hive-mq-broker.md
+++ b/docs/en/20-third-party/10-hive-mq-broker.md
@@ -1,6 +1,6 @@
---
sidebar_label: HiveMQ Broker
-title: HiveMQ Broker writing
+title: HiveMQ Broker Writing
---
-[HiveMQ](https://www.hivemq.com/) is an MQTT broker that provides community and enterprise editions. HiveMQ is mainly for enterprise emerging machine-to-machine M2M communication and internal transport, meeting scalability, ease of management, and security features. HiveMQ provides an open-source plug-in development kit. MQTT data can be saved to TDengine via TDengine extension for HiveMQ. Please refer to the [HiveMQ extension - TDengine documentation](https://github.com/huskar-t/hivemq-tdengine-extension/blob/b62a26ecc164a310104df57691691b237e091c89/README_EN.md) for details on how to use it.
\ No newline at end of file
+[HiveMQ](https://www.hivemq.com/) is an MQTT broker that provides community and enterprise editions. HiveMQ is mainly for enterprise emerging machine-to-machine M2M communication and internal transport, meeting scalability, ease of management, and security features. HiveMQ provides an open-source plug-in development kit. MQTT data can be saved to TDengine via TDengine extension for HiveMQ. For more information, see [HiveMQ TDengine Extension](https://github.com/huskar-t/hivemq-tdengine-extension/blob/b62a26ecc164a310104df57691691b237e091c89/README_EN.md).
diff --git a/docs/en/20-third-party/12-google-data-studio.md b/docs/en/20-third-party/12-google-data-studio.md
new file mode 100644
index 0000000000000000000000000000000000000000..fc94f98056bbeeeec88ca7ea12a4a6a7e6f15dc5
--- /dev/null
+++ b/docs/en/20-third-party/12-google-data-studio.md
@@ -0,0 +1,36 @@
+---
+sidebar_label: Google Data Studio
+title: Use Google Data Studio to access TDengine
+---
+
+Data Studio is a powerful tool for reporting and visualization, offering a wide variety of charts and connectors and making it easy to generate reports based on predefined templates. Its ease of use and robust ecosystem have made it one of the first choices for people working in data analysis.
+
+TDengine is a high-performance, scalable time-series database that supports SQL. Many businesses and developers in fields spanning from IoT and Industry Internet to IT and finance are using TDengine as their time-series database management solution.
+
+The TDengine team immediately saw the benefits of using TDengine to process time-series data with Data Studio to analyze it, and they got to work to create a connector for Data Studio.
+
+With the release of the TDengine connector in Data Studio, you can now get even more out of your data. To obtain the connector, first go to the Data Studio Connector Gallery, click Connect to Data, and search for “TDengine”.
+
+
+
+Select the TDengine connector and click Authorize.
+
+
+
+Then sign in to your Google Account and click Allow to enable the connection to TDengine.
+
+
+
+In the Enter URL field, type the hostname and port of the server running the TDengine REST service. In the following fields, type your username, password, database name, table name, and the start and end times of your query range. Then, click Connect.
+
+
+
+After the connection is established, you can use Data Studio to process your data and create reports.
+
+
+
+In Data Studio, TDengine timestamps and tags are considered dimensions, and all other items are considered metrics. You can create all kinds of custom charts with your data – some examples are shown below.
+
+
+
+With the ability to process petabytes of data per day and provide monitoring and alerting in real time, TDengine is a great solution for time-series data management. Now, with the Data Studio connector, we’re sure you’ll be able to gain new insights and obtain even more value from your data.
diff --git a/docs/en/20-third-party/emqx/client-num.webp b/docs/en/20-third-party/emqx/client-num.webp
index a151b184843607d67b649babb3145bfb3e329cda..a8ac6fb4c036b1db697d537472732ca854e583c8 100644
Binary files a/docs/en/20-third-party/emqx/client-num.webp and b/docs/en/20-third-party/emqx/client-num.webp differ
diff --git a/docs/en/20-third-party/gds/gds-01.webp b/docs/en/20-third-party/gds/gds-01.webp
new file mode 100644
index 0000000000000000000000000000000000000000..2e5f9e4ff5db1e37718e2397c9a13a9f0e05602d
Binary files /dev/null and b/docs/en/20-third-party/gds/gds-01.webp differ
diff --git a/docs/en/20-third-party/gds/gds-02.png.webp b/docs/en/20-third-party/gds/gds-02.png.webp
new file mode 100644
index 0000000000000000000000000000000000000000..3b3537f5a488019482f94452e70bd1bd79867ab5
Binary files /dev/null and b/docs/en/20-third-party/gds/gds-02.png.webp differ
diff --git a/docs/en/20-third-party/gds/gds-03.png.webp b/docs/en/20-third-party/gds/gds-03.png.webp
new file mode 100644
index 0000000000000000000000000000000000000000..5719436d5b2f21aa861067b966511e4b34d17dce
Binary files /dev/null and b/docs/en/20-third-party/gds/gds-03.png.webp differ
diff --git a/docs/en/20-third-party/gds/gds-04.png.webp b/docs/en/20-third-party/gds/gds-04.png.webp
new file mode 100644
index 0000000000000000000000000000000000000000..ddaae5c1a63b6b4db692e12491df55b88dcaadee
Binary files /dev/null and b/docs/en/20-third-party/gds/gds-04.png.webp differ
diff --git a/docs/en/20-third-party/gds/gds-05.png.webp b/docs/en/20-third-party/gds/gds-05.png.webp
new file mode 100644
index 0000000000000000000000000000000000000000..9a917678fc7e60f0a739fa1e2b0f4fa010d12708
Binary files /dev/null and b/docs/en/20-third-party/gds/gds-05.png.webp differ
diff --git a/docs/en/20-third-party/gds/gds-06.png.webp b/docs/en/20-third-party/gds/gds-06.png.webp
new file mode 100644
index 0000000000000000000000000000000000000000..c76b68d32b5907bd5ba4e4010456f2ca5303448f
Binary files /dev/null and b/docs/en/20-third-party/gds/gds-06.png.webp differ
diff --git a/docs/en/20-third-party/gds/gds-07.png.webp b/docs/en/20-third-party/gds/gds-07.png.webp
new file mode 100644
index 0000000000000000000000000000000000000000..1386ae9c4db4f2465dd071afc5a047658b47031c
Binary files /dev/null and b/docs/en/20-third-party/gds/gds-07.png.webp differ
diff --git a/docs/en/20-third-party/gds/gds-08.png.webp b/docs/en/20-third-party/gds/gds-08.png.webp
new file mode 100644
index 0000000000000000000000000000000000000000..59dcf8b31df8bde8d4073ee0c7b1c7bdd7bd439d
Binary files /dev/null and b/docs/en/20-third-party/gds/gds-08.png.webp differ
diff --git a/docs/en/20-third-party/gds/gds-09.png.webp b/docs/en/20-third-party/gds/gds-09.png.webp
new file mode 100644
index 0000000000000000000000000000000000000000..b94439f211a814f66d41231c9386c57f3ffe8322
Binary files /dev/null and b/docs/en/20-third-party/gds/gds-09.png.webp differ
diff --git a/docs/en/20-third-party/gds/gds-10.png.webp b/docs/en/20-third-party/gds/gds-10.png.webp
new file mode 100644
index 0000000000000000000000000000000000000000..a63cad9e9a3d412b1132359506530498fb1a0e57
Binary files /dev/null and b/docs/en/20-third-party/gds/gds-10.png.webp differ
diff --git a/docs/en/20-third-party/gds/gds-11.png.webp b/docs/en/20-third-party/gds/gds-11.png.webp
new file mode 100644
index 0000000000000000000000000000000000000000..fc38cd9a29c00afa48238741c33b439f737a7b8f
Binary files /dev/null and b/docs/en/20-third-party/gds/gds-11.png.webp differ
diff --git a/docs/en/20-third-party/import_dashboard.webp b/docs/en/20-third-party/import_dashboard.webp
new file mode 100644
index 0000000000000000000000000000000000000000..164e3f4690a5a55f937a3c29e1e8ca026648e6b1
Binary files /dev/null and b/docs/en/20-third-party/import_dashboard.webp differ
diff --git a/docs/en/20-third-party/import_dashboard1.webp b/docs/en/20-third-party/import_dashboard1.webp
new file mode 100644
index 0000000000000000000000000000000000000000..d4fb374ce8bb75c8a0fbdbb9cab5b30eb29ab06d
Binary files /dev/null and b/docs/en/20-third-party/import_dashboard1.webp differ
diff --git a/docs/en/20-third-party/import_dashboard2.webp b/docs/en/20-third-party/import_dashboard2.webp
new file mode 100644
index 0000000000000000000000000000000000000000..9f74dc96be20ab64b5fb555aaccdaa1c1139b35c
Binary files /dev/null and b/docs/en/20-third-party/import_dashboard2.webp differ
diff --git a/docs/en/21-tdinternal/01-arch.md b/docs/en/21-tdinternal/01-arch.md
index 44651c0496481c410640e577aaad5781f846e302..2f876adffc2543bb9f117e5812ccc5241d7a6d99 100644
--- a/docs/en/21-tdinternal/01-arch.md
+++ b/docs/en/21-tdinternal/01-arch.md
@@ -12,6 +12,7 @@ The design of TDengine is based on the assumption that any hardware or software
Logical structure diagram of TDengine's distributed architecture is as follows:

+
Figure 1: TDengine architecture diagram
A complete TDengine system runs on one or more physical nodes. Logically, it includes data node (dnode), TDengine client driver (TAOSC) and application (app). There are one or more data nodes in the system, which form a cluster. The application interacts with the TDengine cluster through TAOSC's API. The following is a brief introduction to each logical unit.
@@ -38,15 +39,16 @@ A complete TDengine system runs on one or more physical nodes. Logically, it inc
**Cluster external connection**: TDengine cluster can accommodate a single, multiple or even thousands of data nodes. The application only needs to initiate a connection to any data node in the cluster. The network parameter required for connection is the End Point (FQDN plus configured port number) of a data node. When starting the application taos through CLI, the FQDN of the data node can be specified through the option `-h`, and the configured port number can be specified through `-p`. If the port is not configured, the system configuration parameter “serverPort” of TDengine will be adopted.
-**Inter-cluster communication**: Data nodes connect with each other through TCP/UDP. When a data node starts, it will obtain the EP information of the dnode where the mnode is located, and then establish a connection with the mnode in the system to exchange information. There are three steps to obtain EP information of the mnode:
+**Inter-cluster communication**: Data nodes connect with each other through TCP/UDP. When a data node starts, it will obtain the EP information of the dnode where the mnode is located, and then establish a connection with the mnode in the system to exchange information. There are three steps to obtain EP information of the mnode:
-1. Check whether the mnodeEpList file exists, if it does not exist or cannot be opened normally to obtain EP information of the mnode, skip to the second step;
+1. Check whether the mnodeEpList file exists, if it does not exist or cannot be opened normally to obtain EP information of the mnode, skip to the second step;
2. Check the system configuration file taos.cfg to obtain node configuration parameters “firstEp” and “secondEp” (the node specified by these two parameters can be a normal node without mnode, in this case, the node will try to redirect to the mnode node when connected). If these two configuration parameters do not exist or do not exist in taos.cfg, or are invalid, skip to the third step;
3. Set your own EP as a mnode EP and run it independently. After obtaining the mnode EP list, the data node initiates the connection. It will successfully join the working cluster after connection. If not successful, it will try the next item in the mnode EP list. If all attempts are made, but the connection still fails, sleep for a few seconds before trying again.
**The choice of MNODE**: TDengine logically has a management node, but there is no separate execution code. The server-side only has one set of execution code, taosd. So which data node will be the management node? This is determined automatically by the system without any manual intervention. The principle is as follows: when a data node starts, it will check its End Point and compare it with the obtained mnode EP List. If its EP exists in it, the data node shall start the mnode module and become a mnode. If your own EP is not in the mnode EP List, the mnode module will not start. During the system operation, due to load balancing, downtime and other reasons, mnode may migrate to the new dnode, totally transparently and without manual intervention. The modification of configuration parameters is the decision made by mnode itself according to resources usage.
-**Add new data nodes:** After the system has a data node, it has become a working system. There are two steps to add a new node into the cluster.
+**Add new data nodes:** After the system has a data node, it has become a working system. There are two steps to add a new node into the cluster.
+
- Step1: Connect to the existing working data node using TDengine CLI, and then add the End Point of the new data node with the command "create dnode"
- Step 2: In the system configuration parameter file taos.cfg of the new data node, set the “firstEp” and “secondEp” parameters to the EP of any two data nodes in the existing cluster. Please refer to the user tutorial for detailed steps. In this way, the cluster will be established step by step.
@@ -57,6 +59,7 @@ A complete TDengine system runs on one or more physical nodes. Logically, it inc
To explain the relationship between vnode, mnode, TAOSC and application and their respective roles, the following is an analysis of a typical data writing process.

+
Figure 2: Typical process of TDengine
1. Application initiates a request to insert data through JDBC, ODBC, or other APIs.
@@ -121,16 +124,17 @@ The load balancing process does not require any manual intervention, and it is t
If a database has N replicas, a virtual node group has N virtual nodes. But only one is the Leader and all others are slaves. When the application writes a new record to system, only the Leader vnode can accept the writing request. If a follower vnode receives a writing request, the system will notifies TAOSC to redirect.
-### Leader vnode Writing Process
+### Leader vnode Writing Process
Leader Vnode uses a writing process as follows:

+
Figure 3: TDengine Leader writing process
1. Leader vnode receives the application data insertion request, verifies, and moves to next step;
2. If the system configuration parameter `“walLevel”` is greater than 0, vnode will write the original request packet into database log file WAL. If walLevel is set to 2 and fsync is set to 0, TDengine will make WAL data written immediately to ensure that even system goes down, all data can be recovered from database log file;
-3. If there are multiple replicas, vnode will forward data packet to follower vnodes in the same virtual node group, and the forwarded packet has a version number with data;
+3. If there are multiple replicas, vnode will forward data packet to follower vnodes in the same virtual node group, and the forwarded packet has a version number with data;
4. Write into memory and add the record to “skip list”;
5. Leader vnode returns a confirmation message to the application, indicating a successful write.
6. If any of Step 2, 3 or 4 fails, the error will directly return to the application.
@@ -140,6 +144,7 @@ Leader Vnode uses a writing process as follows:
For a follower vnode, the write process as follows:

+
Figure 4: TDengine Follower Writing Process
1. Follower vnode receives a data insertion request forwarded by Leader vnode;
@@ -212,6 +217,7 @@ When data is written to disk, the system decideswhether to compress the data bas
By default, TDengine saves all data in /var/lib/taos directory, and the data files of each vnode are saved in a different directory under this directory. In order to expand the storage space, minimize the bottleneck of file reading and improve the data throughput rate, TDengine can configure the system parameter “dataDir” to allow multiple mounted hard disks to be used by system at the same time. In addition, TDengine also provides the function of tiered data storage, i.e. storage on different storage media according to the time stamps of data files. For example, the latest data is stored on SSD, the data older than a week is stored on local hard disk, and data older than four weeks is stored on network storage device. This reduces storage costs and ensures efficient data access. The movement of data on different storage media is automatically done by the system and is completely transparent to applications. Tiered storage of data is also configured through the system parameter “dataDir”.
dataDir format is as follows:
+
```
dataDir data_path [tier_level]
```
@@ -270,6 +276,7 @@ For the data collected by device D1001, the number of records per hour is counte
TDengine creates a separate table for each data collection point, but in practical applications, it is often necessary to aggregate data from different data collection points. In order to perform aggregation operations efficiently, TDengine introduces the concept of STable (super table). STable is used to represent a specific type of data collection point. It is a table set containing multiple tables. The schema of each table in the set is the same, but each table has its own static tag. There can be multiple tags which can be added, deleted and modified at any time. Applications can aggregate or statistically operate on all or a subset of tables under a STABLE by specifying tag filters. This greatly simplifies the development of applications. The process is shown in the following figure:

+
Figure 5: Diagram of multi-table aggregation query
1. Application sends a query condition to system;
@@ -279,9 +286,8 @@ TDengine creates a separate table for each data collection point, but in practic
5. Each vnode first finds the set of tables within its own node that meet the tag filters from memory, then scans the stored time-series data, completes corresponding aggregation calculations, and returns result to TAOSC;
6. TAOSC finally aggregates the results returned by multiple data nodes and send them back to application.
-Since TDengine stores tag data and time-series data separately in vnode, by filtering tag data in memory, the set of tables that need to participate in aggregation operation is first found, which reduces the volume of data to be scanned and improves aggregation speed. At the same time, because the data is distributed in multiple vnodes/dnodes, the aggregation operation is carried out concurrently in multiple vnodes, which further improves the aggregation speed. Aggregation functions for ordinary tables and most operations are applicable to STables. The syntax is exactly the same. Please see TAOS SQL for details.
+Since TDengine stores tag data and time-series data separately in vnode, by filtering tag data in memory, the set of tables that need to participate in aggregation operation is first found, which reduces the volume of data to be scanned and improves aggregation speed. At the same time, because the data is distributed in multiple vnodes/dnodes, the aggregation operation is carried out concurrently in multiple vnodes, which further improves the aggregation speed. Aggregation functions for ordinary tables and most operations are applicable to STables. The syntax is exactly the same. Please see TDengine SQL for details.
### Precomputation
In order to effectively improve the performance of query processing, based-on the unchangeable feature of IoT data, statistical information of data stored in data block is recorded in the head of data block, including max value, min value, and sum. We call it a precomputing unit. If the query processing involves all the data of a whole data block, the pre-calculated results are directly used, and no need to read the data block contents at all. Since the amount of pre-calculated data is much smaller than the actual size of data block stored on disk, for query processing with disk IO as bottleneck, the use of pre-calculated results can greatly reduce the pressure of reading IO and accelerate the query process. The precomputation mechanism is similar to the BRIN (Block Range Index) of PostgreSQL.
-
diff --git a/docs/en/10-cluster/03-high-availability.md b/docs/en/21-tdinternal/03-high-availability.md
similarity index 100%
rename from docs/en/10-cluster/03-high-availability.md
rename to docs/en/21-tdinternal/03-high-availability.md
diff --git a/docs/en/10-cluster/04-load-balance.md b/docs/en/21-tdinternal/04-load-balance.md
similarity index 100%
rename from docs/en/10-cluster/04-load-balance.md
rename to docs/en/21-tdinternal/04-load-balance.md
diff --git a/docs/en/25-application/01-telegraf.md b/docs/en/25-application/01-telegraf.md
index d30a23fe1b942e1411e8b5f1320e1c54ae2b407f..59491152bcda3e26ec12aaa59ac1041ef23c4e7e 100644
--- a/docs/en/25-application/01-telegraf.md
+++ b/docs/en/25-application/01-telegraf.md
@@ -34,7 +34,7 @@ Please refer to the [official documentation](https://grafana.com/grafana/downloa
### TDengine
-Download the latest TDengine-server 2.4.0.x or above from the [Downloads](http://taosdata.com/cn/all-downloads/) page on the TAOSData website and install it.
+Download the latest TDengine-server from the [Downloads](http://tdengine.com/en/all-downloads/) page on the TAOSData website and install it.
## Data Connection Setup
@@ -79,5 +79,5 @@ Click on the plus icon on the left and select `Import` to get the data from `htt
## Wrap-up
-The above demonstrates how to quickly build a IT DevOps visualization system. Thanks to the new schemaless protocol parsing feature in TDengine version 2.4.0.0 and ability to integrate easily with a large software ecosystem, users can build an efficient and easy-to-use IT DevOps visualization system in just a few minutes.
+The above demonstrates how to quickly build a IT DevOps visualization system. Thanks to the schemaless protocol parsing feature in TDengine and ability to integrate easily with a large software ecosystem, users can build an efficient and easy-to-use IT DevOps visualization system in just a few minutes.
Please refer to the official documentation and product implementation cases for other features.
diff --git a/docs/en/25-application/02-collectd.md b/docs/en/25-application/02-collectd.md
index 1733ed1b1af8c9375c3773d1ca86831396499a78..692cd8d929f04a03e4433bd0b71f84101bc362cb 100644
--- a/docs/en/25-application/02-collectd.md
+++ b/docs/en/25-application/02-collectd.md
@@ -37,7 +37,7 @@ Please refer to the [official documentation](https://grafana.com/grafana/downloa
### Install TDengine
-Download the latest TDengine-server 2.4.0.x or above from the [Downloads](http://taosdata.com/cn/all-downloads/) page on the TAOSData website and install it.
+Download the latest TDengine-server from the [Downloads](http://tdengine.com/en/all-downloads/) page on the TAOSData website and install it.
## Data Connection Setup
@@ -99,6 +99,6 @@ Download the dashboard json from `https://github.com/taosdata/grafanaplugin/blob
## Wrap-up
-TDengine, as an emerging time-series big data platform, has the advantages of high performance, high reliability, easy management and easy maintenance. Thanks to the new schemaless protocol parsing feature in TDengine version 2.4.0.0 and ability to integrate easily with a large software ecosystem, users can build an efficient and easy-to-use IT DevOps visualization system, or adapt an existing system, in just a few minutes.
+TDengine, as an emerging time-series big data platform, has the advantages of high performance, high reliability, easy management and easy maintenance. Thanks to the new schemaless protocol parsing feature in TDengine and ability to integrate easily with a large software ecosystem, users can build an efficient and easy-to-use IT DevOps visualization system, or adapt an existing system, in just a few minutes.
For TDengine's powerful data writing and querying performance and other features, please refer to the official documentation and successful product implementation cases.
diff --git a/docs/en/25-application/03-immigrate.md b/docs/en/25-application/03-immigrate.md
index fe67f973894d460fb017de0e1a2099b8441a4abe..1aabaa43e77660d72bca00d7d59cdee69b1a7c92 100644
--- a/docs/en/25-application/03-immigrate.md
+++ b/docs/en/25-application/03-immigrate.md
@@ -41,7 +41,7 @@ The agents deployed in the application nodes are responsible for providing opera
- **TDengine installation and deployment**
-First of all, please install TDengine. Download the latest stable version of TDengine from the official website and install it. For help with using various installation packages, please refer to the blog ["Installation and Uninstallation of TDengine Multiple Installation Packages"](https://www.taosdata.com/blog/2019/08/09/566.html).
+First of all, please install TDengine. Download the latest stable version of TDengine from the official website and install it. For help with using various installation packages, please refer to [Install TDengine](../../get-started/package)
Note that once the installation is complete, do not start the `taosd` service before properly configuring the parameters.
@@ -51,7 +51,7 @@ TDengine version 2.4 and later version includes `taosAdapter`. taosAdapter is a
Users can flexibly deploy taosAdapter instances, based on their requirements, to improve data writing throughput and provide guarantees for data writes in different application scenarios.
-Through taosAdapter, users can directly write the data collected by `collectd` or `StatsD` to TDengine to achieve easy, convenient and seamless migration in application scenarios. taosAdapter also supports Telegraf, Icinga, TCollector, and node_exporter data. For more details, please refer to [taosAdapter](/reference/taosadapter/).
+Through taosAdapter, users can directly write the data collected by `collectd` or `StatsD` to TDengine to achieve easy, convenient and seamless migration in application scenarios. taosAdapter also supports Telegraf, Icinga, TCollector, and node_exporter data. For more details, please refer to [taosAdapter](../../reference/taosadapter/).
If using collectd, modify the configuration file in its default location `/etc/collectd/collectd.conf` to point to the IP address and port of the node where to deploy taosAdapter. For example, assuming the taosAdapter IP address is 192.168.1.130 and port 6046, configure it as follows.
@@ -411,7 +411,7 @@ TDengine provides a wealth of help documents to explain many aspects of cluster
### Cluster Deployment
-The first is TDengine installation. Download the latest stable version of TDengine from the official website, and install it. Please refer to the blog ["Installation and Uninstallation of Various Installation Packages of TDengine"](https://www.taosdata.com/blog/2019/08/09/566.html) for the various installation package formats.
+The first is TDengine installation. Download the latest stable version of TDengine from the official website, and install it. Please refer to [Install TDengine](../../get-started/package) for more details.
Note that once the installation is complete, do not immediately start the `taosd` service, but start it after correctly configuring the parameters.
@@ -419,11 +419,11 @@ Note that once the installation is complete, do not immediately start the `taosd
To ensure that the system can obtain the necessary information for regular operation. Please set the following vital parameters correctly on the server:
-FQDN, firstEp, secondEP, dataDir, logDir, tmpDir, serverPort. For the specific meaning and setting requirements of each parameter, please refer to the document "[TDengine Cluster Installation and Management](/cluster/)"
+FQDN, firstEp, secondEP, dataDir, logDir, tmpDir, serverPort. For the specific meaning and setting requirements of each parameter, please refer to the document "[TDengine Cluster Deployment](../../deployment)"
Follow the same steps to set parameters on the other nodes, start the taosd service, and then add Dnodes to the cluster.
-Finally, start `taos` and execute the `show dnodes` command. If you can see all the nodes that have joined the cluster, the cluster building process was successfully completed. For specific operation procedures and precautions, please refer to the document "[TDengine Cluster Installation and Management](/cluster/)".
+Finally, start `taos` and execute the `show dnodes` command. If you can see all the nodes that have joined the cluster, the cluster building process was successfully completed. For specific operation procedures and precautions, please refer to the document "[TDengine Cluster Deployment](../../deployment)".
## Appendix 4: Super Table Names
@@ -431,5 +431,5 @@ Since OpenTSDB's metric name has a dot (".") in it, for example, a metric with a
## Appendix 5: Reference Articles
-1. [Using TDengine + collectd/StatsD + Grafana to quickly build an IT operation and maintenance monitoring system](/application/collectd/)
-2. [Write collected data directly to TDengine through collectd](/third-party/collectd/)
+1. [Using TDengine + collectd/StatsD + Grafana to quickly build an IT operation and maintenance monitoring system](../collectd/)
+2. [Write collected data directly to TDengine through collectd](../collectd/)
diff --git a/docs/en/25-application/IT-DevOps-Solutions-Collectd-StatsD.webp b/docs/en/25-application/IT-DevOps-Solutions-Collectd-StatsD.webp
index 147a65b17bff2aa0e44faa206618bdce5664e1ca..a8b52f3b2d6efe2b83c087d81b98c89fa941f263 100644
Binary files a/docs/en/25-application/IT-DevOps-Solutions-Collectd-StatsD.webp and b/docs/en/25-application/IT-DevOps-Solutions-Collectd-StatsD.webp differ
diff --git a/docs/en/25-application/IT-DevOps-Solutions-Telegraf.webp b/docs/en/25-application/IT-DevOps-Solutions-Telegraf.webp
index fd5461ec9b37be66cac4c17fb1f81fec76158330..fac96f4eb63232c405bfb5e09eda7ed00901a7b5 100644
Binary files a/docs/en/25-application/IT-DevOps-Solutions-Telegraf.webp and b/docs/en/25-application/IT-DevOps-Solutions-Telegraf.webp differ
diff --git a/docs/en/25-application/IT-DevOps-Solutions-telegraf-dashboard.webp b/docs/en/25-application/IT-DevOps-Solutions-telegraf-dashboard.webp
index 105afcdb8312b23675f62ff6339d5e737b5cd958..fac96f4eb63232c405bfb5e09eda7ed00901a7b5 100644
Binary files a/docs/en/25-application/IT-DevOps-Solutions-telegraf-dashboard.webp and b/docs/en/25-application/IT-DevOps-Solutions-telegraf-dashboard.webp differ
diff --git a/docs/en/27-train-faq/01-faq.md b/docs/en/27-train-faq/01-faq.md
index c10bca1d05edd8cebe451901b3abb91923618a26..733b4184741ec3bdcea5ae5ef4b236493a03be35 100644
--- a/docs/en/27-train-faq/01-faq.md
+++ b/docs/en/27-train-faq/01-faq.md
@@ -1,114 +1,163 @@
---
-sidebar_label: FAQ
title: Frequently Asked Questions
---
## Submit an Issue
-If the tips in FAQ don't help much, please submit an issue on [GitHub](https://github.com/taosdata/TDengine) to describe your problem. In your description please include the TDengine version, hardware and OS information, the steps to reproduce the problem and any other relevant information. It would be very helpful if you can package the contents in `/var/log/taos` and `/etc/taos` and upload. These two are the default directories used by TDengine. If you have changed the default directories in your configuration, please package the files in your configured directories. We recommended setting `debugFlag` to 135 in `taos.cfg`, restarting `taosd`, then reproducing the problem and collecting the logs. If you don't want to restart, an alternative way of setting `debugFlag` is executing `alter dnode debugFlag 135` command in TDengine CLI `taos`. During normal running, however, please make sure `debugFlag` is set to 131.
+If your issue could not be resolved by reviewing this documentation, you can submit your issue on GitHub and receive support from the TDengine Team. When you submit an issue, attach the following directories from your TDengine deployment:
-## Frequently Asked Questions
+1. The directory containing TDengine logs (`/var/log/taos` by default)
+2. The directory containing TDengine configuration files (`/etc/taos` by default)
-### 1. How to upgrade to TDengine 2.0 from older version?
+In your GitHub issue, provide the version of TDengine and the operating system and environment for your deployment, the operations that you performed when the issue occurred, and the time of occurrence and affected tables.
-version 2.x is not compatible with version 1.x. With regard to the configuration and data files, please perform the following steps before upgrading. Please follow data integrity, security, backup and other relevant SOPs, best practices before removing/deleting any data.
+To obtain more debugging information, open `taos.cfg` and set the `debugFlag` parameter to `135`. Then restart TDengine Server and reproduce the issue. The debug-level logs generated help the TDengine Team to resolve your issue. If it is not possible to restart TDengine Server, you can run the following command in the TDengine CLI to set the debug flag:
-1. Delete configuration files: `sudo rm -rf /etc/taos/taos.cfg`
-2. Delete log files: `sudo rm -rf /var/log/taos/`
-3. Delete data files if the data doesn't need to be kept: `sudo rm -rf /var/lib/taos/`
-4. Install latest 2.x version
-5. If the data needs to be kept and migrated to newer version, please contact professional service at TDengine for assistance.
+```
+ alter dnode 'debugFlag' '135';
+```
-### 2. How to handle "Unable to establish connection"?
+You can run the `SHOW DNODES` command to determine the dnode ID.
-When the client is unable to connect to the server, you can try the following ways to troubleshoot and resolve the problem.
+When debugging information is no longer needed, set `debugFlag` to 131.
-1. Check the network
+## Frequently Asked Questions
- - Check if the hosts where the client and server are running are accessible to each other, for example by `ping` command.
- - Check if the TCP/UDP on port 6030-6042 are open for access if firewall is enabled. If possible, disable the firewall for diagnostics, but please ensure that you are following security and other relevant protocols.
- - Check if the FQDN and serverPort are configured correctly in `taos.cfg` used by the server side.
- - Check if the `firstEp` is set properly in the `taos.cfg` used by the client side.
+### 1. What are the best practices for upgrading a previous version of TDengine to version 3.0?
-2. Make sure the client version and server version are same.
+TDengine 3.0 is not compatible with the configuration and data files from previous versions. Before upgrading, perform the following steps:
-3. On server side, check the running status of `taosd` by executing `systemctl status taosd` . If your server is started using another way instead of `systemctl`, use the proper method to check whether the server process is running normally.
+1. Run `sudo rm -rf /etc/taos/taos.cfg` to delete your configuration file.
+2. Run `sudo rm -rf /var/log/taos/` to delete your log files.
+3. Run `sudo rm -rf /var/lib/taos/` to delete your data files.
+4. Install TDengine 3.0.
+5. For assistance in migrating data to TDengine 3.0, contact [TDengine Support](https://tdengine.com/support).
-4. If using connector of Python, Java, Go, Rust, C#, node.JS on Linux to connect to the server, please make sure `libtaos.so` is in directory `/usr/local/taos/driver` and `/usr/local/taos/driver` is in system lib search environment variable `LD_LIBRARY_PATH`.
+### 4. How can I resolve the "Unable to establish connection" error?
-5. If using connector on Windows, please make sure `C:\TDengine\driver\taos.dll` is in your system lib search path. We recommend putting `taos.dll` under `C:\Windows\System32`.
+This error indicates that the client could not connect to the server. Perform the following troubleshooting steps:
-6. Some advanced network diagnostics tools
+1. Check the network.
- - On Linux system tool `nc` can be used to check whether the TCP/UDP can be accessible on a specified port
- Check whether a UDP port is open: `nc -vuz {hostIP} {port} `
- Check whether a TCP port on server side is open: `nc -l {port}`
- Check whether a TCP port on client side is open: `nc {hostIP} {port}`
+ - For machines deployed in the cloud, verify that your security group can access ports 6030 and 6031 (TCP and UDP).
+ - For virtual machines deployed locally, verify that the hosts where the client and server are running are accessible to each other. Do not use localhost as the hostname.
+ - For machines deployed on a corporate network, verify that your NAT configuration allows the server to respond to the client.
- - On Windows system `Test-NetConnection -ComputerName {fqdn} -Port {port}` on PowerShell can be used to check whether the port on server side is open for access.
+2. Verify that the client and server are running the same version of TDengine.
-7. TDengine CLI `taos` can also be used to check network, please refer to [TDengine CLI](/reference/taos-shell).
+3. On the server, run `systemctl status taosd` to verify that taosd is running normally. If taosd is stopped, run `systemctl start taosd`.
-### 3. How to handle "Unexpected generic error in RPC" or "Unable to resolve FQDN" ?
+4. Verify that the client is configured with the correct FQDN for the server.
-This error is caused because the FQDN can't be resolved. Please try following ways:
+5. If the server cannot be reached with the `ping` command, verify that network and DNS or hosts file settings are correct. For a TDengine cluster, the client must be able to ping the FQDN of every node in the cluster.
-1. Check whether the FQDN is configured properly on the server side
-2. If DSN server is configured in the network, please check whether it works; otherwise, check `/etc/hosts` to see whether the FQDN is configured with correct IP
-3. If the network configuration on the server side is OK, try to ping the server from the client side.
-4. If TDengine has been used before with an old hostname then the hostname has been changed, please check `/var/lib/taos/taos/dnode/dnodeEps.json`. Before setting up a new TDengine cluster, it's better to cleanup the directories configured.
+6. Verify that your firewall settings allow all hosts in the cluster to communicate on ports 6030 and 6041 (TCP and UDP). You can run `ufw status` (Ubuntu) or `firewall-cmd --list-port` (CentOS) to check the configuration.
-### 4. "Invalid SQL" is returned even though the Syntax is correct
+7. If you are using the Python, Java, Go, Rust, C#, or Node.js connector on Linux to connect to the server, verify that `libtaos.so` is in the `/usr/local/taos/driver` directory and `/usr/local/taos/driver` is in the `LD_LIBRARY_PATH` environment variable.
-"Invalid SQL" is returned when the length of SQL statement exceeds maximum allowed length or the syntax is not correct.
+8. If you are using Windows, verify that `C:\TDengine\driver\taos.dll` is in the `PATH` environment variable. If possible, move `taos.dll` to the `C:\Windows\System32` directory.
-### 5. Whether validation queries are supported?
+9. On Linux systems, you can use the `nc` tool to check whether a port is accessible:
+ - To check whether a UDP port is open, run `nc -vuz {hostIP} {port}`.
+ - To check whether a TCP port on the server side is open, run `nc -l {port}`.
+ - To check whether a TCP port on client side is open, run `nc {hostIP} {port}`.
-It's suggested to use a builtin database named as `log` to monitor.
+10. On Windows systems, you can run `Test-NetConnection -ComputerName {fqdn} -Port {port}` in PowerShell to check whether a port on the server side is accessible.
-
+11. You can also use the TDengine CLI to diagnose network issues. For more information, see [Problem Diagnostics](https://docs.tdengine.com/operation/diagnose/).
-### 6. Can I delete a record?
+### 5. How can I resolve the "Unable to resolve FQDN" error?
-From version 2.6.0.0 Enterprise version, deleting data can be supported.
+Clients and dnodes must be able to resolve the FQDN of each required node. You can confirm your configuration as follows:
-### 7. How to create a table of over 1024 columns?
+1. Verify that the FQDN is configured properly on the server.
+2. If your network has a DNS server, verify that it is operational.
+3. If your network does not have a DNS server, verify that the FQDNs in the `hosts` file are correct.
+4. On the client, use the `ping` command to test your connection to the server. If you cannot ping an FQDN, TDengine cannot reach it.
+5. If TDengine has been previously installed and the `hostname` was modified, open `dnode.json` in the `data` folder and verify that the endpoint configuration is correct. The default location of the dnode file is `/var/lib/taos/dnode`. Ensure that you clean up previous installations before reinstalling TDengine.
+6. Confirm whether FQDNs are preconfigured in `/etc/hosts` and `/etc/hostname`.
-From version 2.1.7.0, at most 4096 columns can be defined for a table.
+### 6. What is the most effective way to write data to TDengine?
-### 8. How to improve the efficiency of inserting data?
+Writing data in batches provides higher efficiency in most situations. You can insert one or more data records into one or more tables in a single SQL statement.
-Inserting data in batch is a good practice. Single SQL statement can insert data for one or multiple tables in batch.
+### 9. Why are table names not fully displayed?
-### 9. JDBC Error: the executed SQL is not a DML or a DDL?
+The number of columns in the TDengine CLI terminal display is limited. This can cause table names to be cut off, and if you use an incomplete name in a statement, the "Table does not exist" error will occur. You can increase the display size with the `maxBinaryDisplayWidth` parameter or the SQL statement `set max_binary_display_width`. You can also append `\G` to your SQL statement to bypass this limitation.
-Please upgrade to latest JDBC driver, for details please refer to [Java Connector](/reference/connector/java)
+### 10. How can I migrate data?
-### 10. Failed to connect with error "invalid timestamp"
+In TDengine, the `hostname` uniquely identifies a machine. When you move data files to a new machine, you must configure the new machine to have the same `host name` as the original machine.
-The most common reason is that the time setting is not aligned on the client side and the server side. On Linux system, please use `ntpdate` command. On Windows system, please enable automatic sync in system time setting.
+:::note
-### 11. Table name is not shown in full
+The data structure of previous versions of TDengine is not compatible with version 3.0. To migrate from TDengine 1.x or 2.x to 3.0, you must export data from your older deployment and import it back into TDengine 3.0.
-There is a display width setting in TDengine CLI `taos`. It can be controlled by configuration parameter `maxBinaryDisplayWidth`, or can be set using SQL command `set max_binary_display_width`. A more convenient way is to append `\G` in a SQL command to bypass this limitation.
+:::
-### 12. How to change log level temporarily?
+### 11. How can I temporary change the log level from the TDengine Client?
-Below SQL command can be used to adjust log level temporarily
+To change the log level for debugging purposes, you can use the following command:
```sql
-ALTER LOCAL flag_name flag_value;
+ALTER LOCAL local_option
+
+local_option: {
+ 'resetLog'
+ | 'rpcDebugFlag' value
+ | 'tmrDebugFlag' value
+ | 'cDebugFlag' value
+ | 'uDebugFlag' value
+ | 'debugFlag' value
+}
```
- - flag_name can be: debugFlag,cDebugFlag,tmrDebugFlag,uDebugFlag,rpcDebugFlag
- - flag_value can be: 131 (INFO/WARNING/ERROR), 135 (plus DEBUG), 143 (plus TRACE)
-
+Use `resetlog` to remove all logs generated on the local client. Use the other parameters to specify a log level for a specific component.
-### 13. What to do if go compilation fails?
+For each parameter, you can set the value to `131` (error and warning), `135` (error, warning, and debug), or `143` (error, warning, debug, and trace).
-From version 2.3.0.0, a new component named `taosAdapter` is introduced. Its' developed in Go. If you want to compile from source code and meet go compilation problems, try to do below steps to resolve Go environment problems.
+### Why do TDengine components written in Go fail to compile?
-```sh
-go env -w GO111MODULE=on
-go env -w GOPROXY=https://goproxy.cn,direct
-```
+TDengine includes taosAdapter, an independent component written in Go. This component provides the REST API as well as data access for other products such as Prometheus and Telegraf.
+When using the develop branch, you must run `git submodule update --init --recursive` to download the taosAdapter repository and then compile it.
+
+TDengine Go components require Go version 1.14 or later.
+
+### 13. How can I query the storage space being used by my data?
+
+The TDengine data files are stored in `/var/lib/taos` by default. Log files are stored in `/var/log/taos`.
+
+To see how much space your data files occupy, run `du -sh /var/lib/taos/vnode --exclude='wal'`. This excludes the write-ahead log (WAL) because its size is relatively fixed while writes are occurring, and it is written to disk and cleared when you shut down TDengine.
+
+If you want to see how much space is occupied by a single database, first determine which vgroup is storing the database by running `show vgroups`. Then check `/var/lib/taos/vnode` for the files associated with the vgroup ID.
+
+### 15. How is timezone information processed for timestamps?
+
+TDengine uses the timezone of the client for timestamps. The server timezone does not affect timestamps. The client converts Unix timestamps in SQL statements to UTC before sending them to the server. When you query data on the server, it provides timestamps in UTC to the client, which converts them to its local time.
+
+Timestamps are processed as follows:
+
+1. The client uses its system timezone unless it has been configured otherwise.
+2. A timezone configured in `taos.cfg` takes precedence over the system timezone.
+3. A timezone explicitly specified when establishing a connection to TDengine through a connector takes precedence over `taos.cfg` and the system timezone. For example, the Java connector allows you to specify a timezone in the JDBC URL.
+4. If you use an RFC 3339 timestamp (2013-04-12T15:52:01.123+08:00), or an ISO 8601 timestamp (2013-04-12T15:52:01.123+0800), the timezone specified in the timestamp is used instead of the timestamps configured using any other method.
+
+### 16. Which network ports are required by TDengine?
+
+See [serverPort](https://docs.tdengine.com/reference/config/#serverport) in Configuration Parameters.
+
+Note that ports are specified using 6030 as the default first port. If you change this port, all other ports change as well.
+
+### 17. Why do applications such as Grafana fail to connect to TDengine over the REST API?
+
+In TDengine, the REST API is provided by taosAdapter. Ensure that taosAdapter is running before you connect an application to TDengine over the REST API. You can run `systemctl start taosadapter` to start the service.
+
+Note that the log path for taosAdapter must be configured separately. The default path is `/var/log/taos`. You can choose one of eight log levels. The default is `info`. You can set the log level to `panic` to disable log output. You can modify the taosAdapter configuration file to change these settings. The default location is `/etc/taos/taosadapter.toml`.
+
+For more information, see [taosAdapter](https://docs.tdengine.com/reference/taosadapter/).
+
+### 18. How can I resolve out-of-memory (OOM) errors?
+
+OOM errors are thrown by the operating system when its memory, including swap, becomes insufficient and it needs to terminate processes to remain operational. Most OOM errors in TDengine occur for one of the following reasons: free memory is less than the value of `vm.min_free_kbytes` or free memory is less than the size of the request. If TDengine occupies reserved memory, an OOM error can occur even when free memory is sufficient.
+
+TDengine preallocates memory to each vnode. The number of vnodes per database is determined by the `vgroups` parameter, and the amount of memory per vnode is determined by the `buffer` parameter. To prevent OOM errors from occurring, ensure that you prepare sufficient memory on your hosts to support the number of vnodes that your deployment requires. Configure an appropriately sized swap space. If you continue to receive OOM errors, your SQL statements may be querying too much data for your system. TDengine Enterprise Edition includes optimized memory management that increases stability for enterprise customers.
diff --git a/docs/en/27-train-faq/03-docker.md b/docs/en/27-train-faq/03-docker.md
deleted file mode 100644
index 0378fffb8bdbc4cae8d4d2176ec3d745a548c2fe..0000000000000000000000000000000000000000
--- a/docs/en/27-train-faq/03-docker.md
+++ /dev/null
@@ -1,285 +0,0 @@
----
-sidebar_label: TDengine in Docker
-title: Deploy TDengine in Docker
----
-
-We do not recommend deploying TDengine using Docker in a production system. However, Docker is still very useful in a development environment, especially when your host is not Linux. From version 2.0.14.0, the official image of TDengine can support X86-64, X86, arm64, and rm32 .
-
-In this chapter we introduce a simple step by step guide to use TDengine in Docker.
-
-## Install Docker
-
-To install Docker please refer to [Get Docker](https://docs.docker.com/get-docker/).
-
-After Docker is installed, you can check whether Docker is installed properly by displaying Docker version.
-
-```bash
-$ docker -v
-Docker version 20.10.3, build 48d30b5
-```
-
-## Launch TDengine in Docker
-
-### Launch TDengine Server
-
-```bash
-$ docker run -d -p 6030-6049:6030-6049 -p 6030-6049:6030-6049/udp tdengine/tdengine
-526aa188da767ae94b244226a2b2eec2b5f17dd8eff592893d9ec0cd0f3a1ccd
-```
-
-In the above command, a docker container is started to run TDengine server, the port range 6030-6049 of the container is mapped to host port range 6030-6049. If port range 6030-6049 has been occupied on the host, please change to an available host port range. For port requirements on the host, please refer to [Port Configuration](/reference/config/#serverport).
-
-- **docker run**: Launch a docker container
-- **-d**: the container will run in background mode
-- **-p**: port mapping
-- **tdengine/tdengine**: The image from which to launch the container
-- **526aa188da767ae94b244226a2b2eec2b5f17dd8eff592893d9ec0cd0f3a1ccd**: the container ID if successfully launched.
-
-Furthermore, `--name` can be used with `docker run` to specify name for the container, `--hostname` can be used to specify hostname for the container, `-v` can be used to mount local volumes to the container so that the data generated inside the container can be persisted to disk on the host.
-
-```bash
-docker run -d --name tdengine --hostname="tdengine-server" -v ~/work/taos/log:/var/log/taos -v ~/work/taos/data:/var/lib/taos -p 6030-6049:6030-6049 -p 6030-6049:6030-6049/udp tdengine/tdengine
-```
-
-- **--name tdengine**: specify the name of the container, the name can be used to specify the container later
-- **--hostname=tdengine-server**: specify the hostname inside the container, the hostname can be used inside the container without worrying the container IP may vary
-- **-v**: volume mapping between host and container
-
-### Check the container
-
-```bash
-docker ps
-```
-
-The output is like below:
-
-```
-CONTAINER ID IMAGE COMMAND CREATED STATUS ···
-c452519b0f9b tdengine/tdengine "taosd" 14 minutes ago Up 14 minutes ···
-```
-
-- **docker ps**: List all the containers
-- **CONTAINER ID**: Container ID
-- **IMAGE**: The image used for the container
-- **COMMAND**: The command used when launching the container
-- **CREATED**: When the container was created
-- **STATUS**: Status of the container
-
-### Access TDengine inside container
-
-```bash
-$ docker exec -it tdengine /bin/bash
-root@tdengine-server:~/TDengine-server-2.4.0.4#
-```
-
-- **docker exec**: Attach to the container
-- **-i**: Interactive mode
-- **-t**: Use terminal
-- **tdengine**: Container name, up to the output of `docker ps`
-- **/bin/bash**: The command to execute once the container is attached
-
-Inside the container, start TDengine CLI `taos`
-
-```bash
-root@tdengine-server:~/TDengine-server-2.4.0.4# taos
-
-Welcome to the TDengine shell from Linux, Client Version:2.4.0.4
-Copyright (c) 2020 by TAOS Data, Inc. All rights reserved.
-
-taos>
-```
-
-The above example is for a successful connection. If `taos` fails to connect to the server side, error information would be shown.
-
-In TDengine CLI, SQL commands can be executed to create/drop databases, tables, STables, and insert or query data. For details please refer to [TAOS SQL](/taos-sql/).
-
-### Access TDengine from host
-
-If option `-p` used to map ports properly between host and container, it's also able to access TDengine in container from the host as long as `firstEp` is configured correctly for the client on host.
-
-```
-$ taos
-
-Welcome to the TDengine shell from Linux, Client Version:2.4.0.4
-Copyright (c) 2020 by TAOS Data, Inc. All rights reserved.
-
-taos>
-```
-
-It's also able to access the REST interface provided by TDengine in container from the host.
-
-```
-curl -L -u root:taosdata -d "show databases" 127.0.0.1:6041/rest/sql
-```
-
-Output is like below:
-
-```
-{"status":"succ","head":["name","created_time","ntables","vgroups","replica","quorum","days","keep0,keep1,keep(D)","cache(MB)","blocks","minrows","maxrows","wallevel","fsync","comp","cachelast","precision","update","status"],"column_meta":[["name",8,32],["created_time",9,8],["ntables",4,4],["vgroups",4,4],["replica",3,2],["quorum",3,2],["days",3,2],["keep0,keep1,keep(D)",8,24],["cache(MB)",4,4],["blocks",4,4],["minrows",4,4],["maxrows",4,4],["wallevel",2,1],["fsync",4,4],["comp",2,1],["cachelast",2,1],["precision",8,3],["update",2,1],["status",8,10]],"data":[["test","2021-08-18 06:01:11.021",10000,4,1,1,10,"3650,3650,3650",16,6,100,4096,1,3000,2,0,"ms",0,"ready"],["log","2021-08-18 05:51:51.065",4,1,1,1,10,"30,30,30",1,3,100,4096,1,3000,2,0,"us",0,"ready"]],"rows":2}
-```
-
-For details of REST API please refer to [REST API](/reference/rest-api/).
-
-### Run TDengine server and taosAdapter inside container
-
-From version 2.4.0.0, in the TDengine Docker image, `taosAdapter` is enabled by default, but can be disabled using environment variable `TAOS_DISABLE_ADAPTER=true` . `taosAdapter` can also be run alone without `taosd` when launching a container.
-
-For the port mapping of `taosAdapter`, please refer to [taosAdapter](/reference/taosadapter/).
-
-- Run both `taosd` and `taosAdapter` (by default) in docker container:
-
-```bash
-docker run -d --name tdengine-all -p 6030-6049:6030-6049 -p 6030-6049:6030-6049/udp tdengine/tdengine:2.4.0.4
-```
-
-- Run `taosAdapter` only in docker container, `TAOS_FIRST_EP` environment variable needs to be used to specify the container name in which `taosd` is running:
-
-```bash
-docker run -d --name tdengine-taosa -p 6041-6049:6041-6049 -p 6041-6049:6041-6049/udp -e TAOS_FIRST_EP=tdengine-all tdengine/tdengine:2.4.0.4 taosadapter
-```
-
-- Run `taosd` only in docker container:
-
-```bash
-docker run -d --name tdengine-taosd -p 6030-6042:6030-6042 -p 6030-6042:6030-6042/udp -e TAOS_DISABLE_ADAPTER=true tdengine/tdengine:2.4.0.4
-```
-
-- Verify the REST interface:
-
-```bash
-curl -L -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -d "show databases;" 127.0.0.1:6041/rest/sql
-```
-
-Below is an example output:
-
-```
-{"status":"succ","head":["name","created_time","ntables","vgroups","replica","quorum","days","keep","cache(MB)","blocks","minrows","maxrows","wallevel","fsync","comp","cachelast","precision","update","status"],"column_meta":[["name",8,32],["created_time",9,8],["ntables",4,4],["vgroups",4,4],["replica",3,2],["quorum",3,2],["days",3,2],["keep",8,24],["cache(MB)",4,4],["blocks",4,4],["minrows",4,4],["maxrows",4,4],["wallevel",2,1],["fsync",4,4],["comp",2,1],["cachelast",2,1],["precision",8,3],["update",2,1],["status",8,10]],"data":[["log","2021-12-28 09:18:55.765",10,1,1,1,10,"30",1,3,100,4096,1,3000,2,0,"us",0,"ready"]],"rows":1}
-```
-
-### Use taosBenchmark on host to access TDengine server in container
-
-1. Run `taosBenchmark`, named as `taosdemo` previously, on the host:
-
- ```bash
- $ taosBenchmark
-
- taosBenchmark is simulating data generated by power equipments monitoring...
-
- host: 127.0.0.1:6030
- user: root
- password: taosdata
- configDir:
- resultFile: ./output.txt
- thread num of insert data: 10
- thread num of create table: 10
- top insert interval: 0
- number of records per req: 30000
- max sql length: 1048576
- database count: 1
- database[0]:
- database[0] name: test
- drop: yes
- replica: 1
- precision: ms
- super table count: 1
- super table[0]:
- stbName: meters
- autoCreateTable: no
- childTblExists: no
- childTblCount: 10000
- childTblPrefix: d
- dataSource: rand
- iface: taosc
- insertRows: 10000
- interlaceRows: 0
- disorderRange: 1000
- disorderRatio: 0
- maxSqlLen: 1048576
- timeStampStep: 1
- startTimestamp: 2017-07-14 10:40:00.000
- sampleFormat:
- sampleFile:
- tagsFile:
- columnCount: 3
- column[0]:FLOAT column[1]:INT column[2]:FLOAT
- tagCount: 2
- tag[0]:INT tag[1]:BINARY(16)
-
- Press enter key to continue or Ctrl-C to stop
- ```
-
- Once the execution is finished, a database `test` is created, a STable `meters` is created in database `test`, 10,000 sub tables are created using `meters` as template, named as "d0" to "d9999", while 10,000 rows are inserted into each table, so totally 100,000,000 rows are inserted.
-
-2. Check the data
-
- - **Check database**
-
- ```bash
- $ taos> show databases;
- name | created_time | ntables | vgroups | ···
- test | 2021-08-18 06:01:11.021 | 10000 | 6 | ···
- log | 2021-08-18 05:51:51.065 | 4 | 1 | ···
-
- ```
-
- - **Check STable**
-
- ```bash
- $ taos> use test;
- Database changed.
-
- $ taos> show stables;
- name | created_time | columns | tags | tables |
- ============================================================================================
- meters | 2021-08-18 06:01:11.116 | 4 | 2 | 10000 |
- Query OK, 1 row(s) in set (0.003259s)
-
- ```
-
- - **Check Tables**
-
- ```bash
- $ taos> select * from test.t0 limit 10;
-
- DB error: Table does not exist (0.002857s)
- taos> select * from test.d0 limit 10;
- ts | current | voltage | phase |
- ======================================================================================
- 2017-07-14 10:40:00.000 | 10.12072 | 223 | 0.34167 |
- 2017-07-14 10:40:00.001 | 10.16103 | 224 | 0.34445 |
- 2017-07-14 10:40:00.002 | 10.00204 | 220 | 0.33334 |
- 2017-07-14 10:40:00.003 | 10.00030 | 220 | 0.33333 |
- 2017-07-14 10:40:00.004 | 9.84029 | 216 | 0.32222 |
- 2017-07-14 10:40:00.005 | 9.88028 | 217 | 0.32500 |
- 2017-07-14 10:40:00.006 | 9.88110 | 217 | 0.32500 |
- 2017-07-14 10:40:00.007 | 10.08137 | 222 | 0.33889 |
- 2017-07-14 10:40:00.008 | 10.12063 | 223 | 0.34167 |
- 2017-07-14 10:40:00.009 | 10.16086 | 224 | 0.34445 |
- Query OK, 10 row(s) in set (0.016791s)
-
- ```
-
- - **Check tag values of table d0**
-
- ```bash
- $ taos> select groupid, location from test.d0;
- groupid | location |
- =================================
- 0 | California.SanDiego |
- Query OK, 1 row(s) in set (0.003490s)
- ```
-
-### Access TDengine from 3rd party tools
-
-A lot of 3rd party tools can be used to write data into TDengine through `taosAdapter`, for details please refer to [3rd party tools](/third-party/).
-
-There is nothing different from the 3rd party side to access TDengine server inside a container, as long as the end point is specified correctly, the end point should be the FQDN and the mapped port of the host.
-
-## Stop TDengine inside container
-
-```bash
-docker stop tdengine
-```
-
-- **docker stop**: stop a container
-- **tdengine**: container name
diff --git a/docs/en/28-releases.md b/docs/en/28-releases.md
new file mode 100644
index 0000000000000000000000000000000000000000..a0c9eb119999571fb973b5e2243f237b8833b167
--- /dev/null
+++ b/docs/en/28-releases.md
@@ -0,0 +1,9 @@
+---
+sidebar_label: Releases
+title: Released Versions
+---
+
+import Release from "/components/ReleaseV3";
+
+
+
diff --git a/docs/examples/c/tmq_example.c b/docs/examples/c/tmq_example.c
new file mode 100644
index 0000000000000000000000000000000000000000..19adaad116ef65673f5541b5216ce12d2d9151c7
--- /dev/null
+++ b/docs/examples/c/tmq_example.c
@@ -0,0 +1,275 @@
+/*
+ * Copyright (c) 2019 TAOS Data, Inc.
+ *
+ * This program is free software: you can use, redistribute, and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3
+ * or later ("AGPL"), as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include "taos.h"
+
+static int running = 1;
+static char dbName[64] = "tmqdb";
+static char stbName[64] = "stb";
+static char topicName[64] = "topicname";
+
+static int32_t msg_process(TAOS_RES* msg) {
+ char buf[1024];
+ int32_t rows = 0;
+
+ const char* topicName = tmq_get_topic_name(msg);
+ const char* dbName = tmq_get_db_name(msg);
+ int32_t vgroupId = tmq_get_vgroup_id(msg);
+
+ printf("topic: %s\n", topicName);
+ printf("db: %s\n", dbName);
+ printf("vgroup id: %d\n", vgroupId);
+
+ while (1) {
+ TAOS_ROW row = taos_fetch_row(msg);
+ if (row == NULL) break;
+
+ TAOS_FIELD* fields = taos_fetch_fields(msg);
+ int32_t numOfFields = taos_field_count(msg);
+ int32_t* length = taos_fetch_lengths(msg);
+ int32_t precision = taos_result_precision(msg);
+ rows++;
+ taos_print_row(buf, row, fields, numOfFields);
+ printf("row content: %s\n", buf);
+ }
+
+ return rows;
+}
+
+static int32_t init_env() {
+ TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
+ if (pConn == NULL) {
+ return -1;
+ }
+
+ TAOS_RES* pRes;
+ // drop database if exists
+ printf("create database\n");
+ pRes = taos_query(pConn, "drop database if exists tmqdb");
+ if (taos_errno(pRes) != 0) {
+ printf("error in drop tmqdb, reason:%s\n", taos_errstr(pRes));
+ return -1;
+ }
+ taos_free_result(pRes);
+
+ // create database
+ pRes = taos_query(pConn, "create database tmqdb");
+ if (taos_errno(pRes) != 0) {
+ printf("error in create tmqdb, reason:%s\n", taos_errstr(pRes));
+ return -1;
+ }
+ taos_free_result(pRes);
+
+ // create super table
+ printf("create super table\n");
+ pRes = taos_query(
+ pConn, "create table tmqdb.stb (ts timestamp, c1 int, c2 float, c3 varchar(16)) tags(t1 int, t3 varchar(16))");
+ if (taos_errno(pRes) != 0) {
+ printf("failed to create super table stb, reason:%s\n", taos_errstr(pRes));
+ return -1;
+ }
+ taos_free_result(pRes);
+
+ // create sub tables
+ printf("create sub tables\n");
+ pRes = taos_query(pConn, "create table tmqdb.ctb0 using tmqdb.stb tags(0, 'subtable0')");
+ if (taos_errno(pRes) != 0) {
+ printf("failed to create super table ctb0, reason:%s\n", taos_errstr(pRes));
+ return -1;
+ }
+ taos_free_result(pRes);
+
+ pRes = taos_query(pConn, "create table tmqdb.ctb1 using tmqdb.stb tags(1, 'subtable1')");
+ if (taos_errno(pRes) != 0) {
+ printf("failed to create super table ctb1, reason:%s\n", taos_errstr(pRes));
+ return -1;
+ }
+ taos_free_result(pRes);
+
+ pRes = taos_query(pConn, "create table tmqdb.ctb2 using tmqdb.stb tags(2, 'subtable2')");
+ if (taos_errno(pRes) != 0) {
+ printf("failed to create super table ctb2, reason:%s\n", taos_errstr(pRes));
+ return -1;
+ }
+ taos_free_result(pRes);
+
+ pRes = taos_query(pConn, "create table tmqdb.ctb3 using tmqdb.stb tags(3, 'subtable3')");
+ if (taos_errno(pRes) != 0) {
+ printf("failed to create super table ctb3, reason:%s\n", taos_errstr(pRes));
+ return -1;
+ }
+ taos_free_result(pRes);
+
+ // insert data
+ printf("insert data into sub tables\n");
+ pRes = taos_query(pConn, "insert into tmqdb.ctb0 values(now, 0, 0, 'a0')(now+1s, 0, 0, 'a00')");
+ if (taos_errno(pRes) != 0) {
+ printf("failed to insert into ctb0, reason:%s\n", taos_errstr(pRes));
+ return -1;
+ }
+ taos_free_result(pRes);
+
+ pRes = taos_query(pConn, "insert into tmqdb.ctb1 values(now, 1, 1, 'a1')(now+1s, 11, 11, 'a11')");
+ if (taos_errno(pRes) != 0) {
+ printf("failed to insert into ctb0, reason:%s\n", taos_errstr(pRes));
+ return -1;
+ }
+ taos_free_result(pRes);
+
+ pRes = taos_query(pConn, "insert into tmqdb.ctb2 values(now, 2, 2, 'a1')(now+1s, 22, 22, 'a22')");
+ if (taos_errno(pRes) != 0) {
+ printf("failed to insert into ctb0, reason:%s\n", taos_errstr(pRes));
+ return -1;
+ }
+ taos_free_result(pRes);
+
+ pRes = taos_query(pConn, "insert into tmqdb.ctb3 values(now, 3, 3, 'a1')(now+1s, 33, 33, 'a33')");
+ if (taos_errno(pRes) != 0) {
+ printf("failed to insert into ctb0, reason:%s\n", taos_errstr(pRes));
+ return -1;
+ }
+ taos_free_result(pRes);
+
+ taos_close(pConn);
+ return 0;
+}
+
+int32_t create_topic() {
+ printf("create topic\n");
+ TAOS_RES* pRes;
+ TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
+ if (pConn == NULL) {
+ return -1;
+ }
+
+ pRes = taos_query(pConn, "use tmqdb");
+ if (taos_errno(pRes) != 0) {
+ printf("error in use tmqdb, reason:%s\n", taos_errstr(pRes));
+ return -1;
+ }
+ taos_free_result(pRes);
+
+ pRes = taos_query(pConn, "create topic topicname as select ts, c1, c2, c3, tbname from tmqdb.stb where c1 > 1");
+ if (taos_errno(pRes) != 0) {
+ printf("failed to create topic topicname, reason:%s\n", taos_errstr(pRes));
+ return -1;
+ }
+ taos_free_result(pRes);
+
+ taos_close(pConn);
+ return 0;
+}
+
+void tmq_commit_cb_print(tmq_t* tmq, int32_t code, void* param) {
+ printf("tmq_commit_cb_print() code: %d, tmq: %p, param: %p\n", code, tmq, param);
+}
+
+tmq_t* build_consumer() {
+ tmq_conf_res_t code;
+ tmq_conf_t* conf = tmq_conf_new();
+ code = tmq_conf_set(conf, "enable.auto.commit", "true");
+ if (TMQ_CONF_OK != code) return NULL;
+ code = tmq_conf_set(conf, "auto.commit.interval.ms", "1000");
+ if (TMQ_CONF_OK != code) return NULL;
+ code = tmq_conf_set(conf, "group.id", "cgrpName");
+ if (TMQ_CONF_OK != code) return NULL;
+ code = tmq_conf_set(conf, "client.id", "user defined name");
+ if (TMQ_CONF_OK != code) return NULL;
+ code = tmq_conf_set(conf, "td.connect.user", "root");
+ if (TMQ_CONF_OK != code) return NULL;
+ code = tmq_conf_set(conf, "td.connect.pass", "taosdata");
+ if (TMQ_CONF_OK != code) return NULL;
+ code = tmq_conf_set(conf, "auto.offset.reset", "earliest");
+ if (TMQ_CONF_OK != code) return NULL;
+ code = tmq_conf_set(conf, "experimental.snapshot.enable", "false");
+ if (TMQ_CONF_OK != code) return NULL;
+
+ tmq_conf_set_auto_commit_cb(conf, tmq_commit_cb_print, NULL);
+
+ tmq_t* tmq = tmq_consumer_new(conf, NULL, 0);
+ tmq_conf_destroy(conf);
+ return tmq;
+}
+
+tmq_list_t* build_topic_list() {
+ tmq_list_t* topicList = tmq_list_new();
+ int32_t code = tmq_list_append(topicList, "topicname");
+ if (code) {
+ return NULL;
+ }
+ return topicList;
+}
+
+void basic_consume_loop(tmq_t* tmq) {
+ int32_t totalRows = 0;
+ int32_t msgCnt = 0;
+ int32_t timeout = 5000;
+ while (running) {
+ TAOS_RES* tmqmsg = tmq_consumer_poll(tmq, timeout);
+ if (tmqmsg) {
+ msgCnt++;
+ totalRows += msg_process(tmqmsg);
+ taos_free_result(tmqmsg);
+ } else {
+ break;
+ }
+ }
+
+ fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows);
+}
+
+int main(int argc, char* argv[]) {
+ int32_t code;
+
+ if (init_env() < 0) {
+ return -1;
+ }
+
+ if (create_topic() < 0) {
+ return -1;
+ }
+
+ tmq_t* tmq = build_consumer();
+ if (NULL == tmq) {
+ fprintf(stderr, "%% build_consumer() fail!\n");
+ return -1;
+ }
+
+ tmq_list_t* topic_list = build_topic_list();
+ if (NULL == topic_list) {
+ return -1;
+ }
+
+ if ((code = tmq_subscribe(tmq, topic_list))) {
+ fprintf(stderr, "%% Failed to tmq_subscribe(): %s\n", tmq_err2str(code));
+ }
+ tmq_list_destroy(topic_list);
+
+ basic_consume_loop(tmq);
+
+ code = tmq_consumer_close(tmq);
+ if (code) {
+ fprintf(stderr, "%% Failed to close consumer: %s\n", tmq_err2str(code));
+ } else {
+ fprintf(stderr, "%% Consumer closed\n");
+ }
+
+ return 0;
+}
diff --git a/docs/examples/java/pom.xml b/docs/examples/java/pom.xml
index a48ba398da92f401235819d067aa2ba6f8b173ea..634c3f75a8386db4caab5c1d598f89dc93926c54 100644
--- a/docs/examples/java/pom.xml
+++ b/docs/examples/java/pom.xml
@@ -21,7 +21,7 @@
com.taosdata.jdbctaos-jdbcdriver
- 2.0.38
+ 3.0.0
diff --git a/docs/examples/java/src/main/java/com/taos/example/Meters.java b/docs/examples/java/src/main/java/com/taos/example/Meters.java
new file mode 100644
index 0000000000000000000000000000000000000000..0f1eadd55b5b197c8e9ecbc415e78fc28e2cb61b
--- /dev/null
+++ b/docs/examples/java/src/main/java/com/taos/example/Meters.java
@@ -0,0 +1,62 @@
+package com.taos.example;
+
+import java.sql.Timestamp;
+
+public class Meters {
+ private Timestamp ts;
+ private float current;
+ private int voltage;
+ private int groupid;
+ private String location;
+
+ public Timestamp getTs() {
+ return ts;
+ }
+
+ public void setTs(Timestamp ts) {
+ this.ts = ts;
+ }
+
+ public float getCurrent() {
+ return current;
+ }
+
+ public void setCurrent(float current) {
+ this.current = current;
+ }
+
+ public int getVoltage() {
+ return voltage;
+ }
+
+ public void setVoltage(int voltage) {
+ this.voltage = voltage;
+ }
+
+ public int getGroupid() {
+ return groupid;
+ }
+
+ public void setGroupid(int groupid) {
+ this.groupid = groupid;
+ }
+
+ public String getLocation() {
+ return location;
+ }
+
+ public void setLocation(String location) {
+ this.location = location;
+ }
+
+ @Override
+ public String toString() {
+ return "Meters{" +
+ "ts=" + ts +
+ ", current=" + current +
+ ", voltage=" + voltage +
+ ", groupid=" + groupid +
+ ", location='" + location + '\'' +
+ '}';
+ }
+}
diff --git a/docs/examples/java/src/main/java/com/taos/example/MetersDeserializer.java b/docs/examples/java/src/main/java/com/taos/example/MetersDeserializer.java
new file mode 100644
index 0000000000000000000000000000000000000000..9b7fa35e90fb4f66d2885af0b2a2f1a429a97127
--- /dev/null
+++ b/docs/examples/java/src/main/java/com/taos/example/MetersDeserializer.java
@@ -0,0 +1,6 @@
+package com.taos.example;
+
+import com.taosdata.jdbc.tmq.ReferenceDeserializer;
+
+public class MetersDeserializer extends ReferenceDeserializer {
+}
\ No newline at end of file
diff --git a/docs/examples/java/src/main/java/com/taos/example/RestInsertExample.java b/docs/examples/java/src/main/java/com/taos/example/RestInsertExample.java
index af97fe4373ca964260e5614f133f359e229b0e15..9d85bf2a94abda71bcdab89d46008b70e52ce437 100644
--- a/docs/examples/java/src/main/java/com/taos/example/RestInsertExample.java
+++ b/docs/examples/java/src/main/java/com/taos/example/RestInsertExample.java
@@ -16,14 +16,14 @@ public class RestInsertExample {
private static List getRawData() {
return Arrays.asList(
- "d1001,2018-10-03 14:38:05.000,10.30000,219,0.31000,California.SanFrancisco,2",
- "d1001,2018-10-03 14:38:15.000,12.60000,218,0.33000,California.SanFrancisco,2",
- "d1001,2018-10-03 14:38:16.800,12.30000,221,0.31000,California.SanFrancisco,2",
- "d1002,2018-10-03 14:38:16.650,10.30000,218,0.25000,California.SanFrancisco,3",
- "d1003,2018-10-03 14:38:05.500,11.80000,221,0.28000,California.LosAngeles,2",
- "d1003,2018-10-03 14:38:16.600,13.40000,223,0.29000,California.LosAngeles,2",
- "d1004,2018-10-03 14:38:05.000,10.80000,223,0.29000,California.LosAngeles,3",
- "d1004,2018-10-03 14:38:06.500,11.50000,221,0.35000,California.LosAngeles,3"
+ "d1001,2018-10-03 14:38:05.000,10.30000,219,0.31000,'California.SanFrancisco',2",
+ "d1001,2018-10-03 14:38:15.000,12.60000,218,0.33000,'California.SanFrancisco',2",
+ "d1001,2018-10-03 14:38:16.800,12.30000,221,0.31000,'California.SanFrancisco',2",
+ "d1002,2018-10-03 14:38:16.650,10.30000,218,0.25000,'California.SanFrancisco',3",
+ "d1003,2018-10-03 14:38:05.500,11.80000,221,0.28000,'California.LosAngeles',2",
+ "d1003,2018-10-03 14:38:16.600,13.40000,223,0.29000,'California.LosAngeles',2",
+ "d1004,2018-10-03 14:38:05.000,10.80000,223,0.29000,'California.LosAngeles',3",
+ "d1004,2018-10-03 14:38:06.500,11.50000,221,0.35000,'California.LosAngeles',3"
);
}
diff --git a/docs/examples/java/src/main/java/com/taos/example/SubscribeDemo.java b/docs/examples/java/src/main/java/com/taos/example/SubscribeDemo.java
index d82d03b9de561e3ea6a8e7d40a48ce9dd3f2a20d..179e6e6911185631901b79e34a343967e73c4936 100644
--- a/docs/examples/java/src/main/java/com/taos/example/SubscribeDemo.java
+++ b/docs/examples/java/src/main/java/com/taos/example/SubscribeDemo.java
@@ -1,65 +1,78 @@
package com.taos.example;
-import com.taosdata.jdbc.TSDBConnection;
-import com.taosdata.jdbc.TSDBDriver;
-import com.taosdata.jdbc.TSDBResultSet;
-import com.taosdata.jdbc.TSDBSubscribe;
+import com.taosdata.jdbc.tmq.ConsumerRecords;
+import com.taosdata.jdbc.tmq.TMQConstants;
+import com.taosdata.jdbc.tmq.TaosConsumer;
import java.sql.Connection;
import java.sql.DriverManager;
-import java.sql.ResultSetMetaData;
import java.sql.SQLException;
+import java.sql.Statement;
+import java.time.Duration;
+import java.util.Collections;
import java.util.Properties;
-import java.util.concurrent.TimeUnit;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.concurrent.atomic.AtomicBoolean;
public class SubscribeDemo {
- private static final String topic = "topic-meter-current-bg-10";
- private static final String sql = "select * from meters where current > 10";
+ private static final String TOPIC = "tmq_topic";
+ private static final String DB_NAME = "meters";
+ private static final AtomicBoolean shutdown = new AtomicBoolean(false);
public static void main(String[] args) {
- Connection connection = null;
- TSDBSubscribe subscribe = null;
-
+ Timer timer = new Timer();
+ timer.schedule(new TimerTask() {
+ public void run() {
+ shutdown.set(true);
+ }
+ }, 3_000);
try {
+ // prepare
Class.forName("com.taosdata.jdbc.TSDBDriver");
+ String jdbcUrl = "jdbc:TAOS://127.0.0.1:6030/?user=root&password=taosdata";
+ Connection connection = DriverManager.getConnection(jdbcUrl);
+ try (Statement statement = connection.createStatement()) {
+ statement.executeUpdate("drop topic if exists " + TOPIC);
+ statement.executeUpdate("drop database if exists " + DB_NAME);
+ statement.executeUpdate("create database " + DB_NAME);
+ statement.executeUpdate("use " + DB_NAME);
+ statement.executeUpdate(
+ "CREATE TABLE `meters` (`ts` TIMESTAMP, `current` FLOAT, `voltage` INT) TAGS (`groupid` INT, `location` BINARY(16))");
+ statement.executeUpdate("CREATE TABLE `d0` USING `meters` TAGS(0, 'Los Angles')");
+ statement.executeUpdate("INSERT INTO `d0` values(now - 10s, 0.32, 116)");
+ statement.executeUpdate("INSERT INTO `d0` values(now - 8s, NULL, NULL)");
+ statement.executeUpdate(
+ "INSERT INTO `d1` USING `meters` TAGS(1, 'San Francisco') values(now - 9s, 10.1, 119)");
+ statement.executeUpdate(
+ "INSERT INTO `d1` values (now-8s, 10, 120) (now - 6s, 10, 119) (now - 4s, 11.2, 118)");
+ // create topic
+ statement.executeUpdate("create topic " + TOPIC + " as select * from meters");
+ }
+
+ // create consumer
Properties properties = new Properties();
- properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8");
- properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8");
- String jdbcUrl = "jdbc:TAOS://127.0.0.1:6030/power?user=root&password=taosdata";
- connection = DriverManager.getConnection(jdbcUrl, properties);
- // create subscribe
- subscribe = ((TSDBConnection) connection).subscribe(topic, sql, true);
- int count = 0;
- while (count < 10) {
- // wait 1 second to avoid frequent calls to consume
- TimeUnit.SECONDS.sleep(1);
- // consume
- TSDBResultSet resultSet = subscribe.consume();
- if (resultSet == null) {
- continue;
- }
- ResultSetMetaData metaData = resultSet.getMetaData();
- while (resultSet.next()) {
- int columnCount = metaData.getColumnCount();
- for (int i = 1; i <= columnCount; i++) {
- System.out.print(metaData.getColumnLabel(i) + ": " + resultSet.getString(i) + "\t");
+ properties.setProperty(TMQConstants.BOOTSTRAP_SERVERS, "127.0.0.1:6030");
+ properties.setProperty(TMQConstants.MSG_WITH_TABLE_NAME, "true");
+ properties.setProperty(TMQConstants.ENABLE_AUTO_COMMIT, "true");
+ properties.setProperty(TMQConstants.GROUP_ID, "test");
+ properties.setProperty(TMQConstants.VALUE_DESERIALIZER,
+ "com.taos.example.MetersDeserializer");
+
+ // poll data
+ try (TaosConsumer consumer = new TaosConsumer<>(properties)) {
+ consumer.subscribe(Collections.singletonList(TOPIC));
+ while (!shutdown.get()) {
+ ConsumerRecords meters = consumer.poll(Duration.ofMillis(100));
+ for (Meters meter : meters) {
+ System.out.println(meter);
}
- System.out.println();
- count++;
}
+ consumer.unsubscribe();
}
- } catch (Exception e) {
+ } catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
- } finally {
- try {
- if (null != subscribe)
- // close subscribe
- subscribe.close(true);
- if (connection != null)
- connection.close();
- } catch (SQLException throwable) {
- throwable.printStackTrace();
- }
}
+ timer.cancel();
}
}
\ No newline at end of file
diff --git a/docs/examples/java/src/main/java/com/taos/example/highvolume/DataBaseMonitor.java b/docs/examples/java/src/main/java/com/taos/example/highvolume/DataBaseMonitor.java
new file mode 100644
index 0000000000000000000000000000000000000000..04b149a4b96441ecfd1b0bdde54c9ed71349cab2
--- /dev/null
+++ b/docs/examples/java/src/main/java/com/taos/example/highvolume/DataBaseMonitor.java
@@ -0,0 +1,63 @@
+package com.taos.example.highvolume;
+
+import java.sql.*;
+
+/**
+ * Prepare target database.
+ * Count total records in database periodically so that we can estimate the writing speed.
+ */
+public class DataBaseMonitor {
+ private Connection conn;
+ private Statement stmt;
+
+ public DataBaseMonitor init() throws SQLException {
+ if (conn == null) {
+ String jdbcURL = System.getenv("TDENGINE_JDBC_URL");
+ conn = DriverManager.getConnection(jdbcURL);
+ stmt = conn.createStatement();
+ }
+ return this;
+ }
+
+ public void close() {
+ try {
+ stmt.close();
+ } catch (SQLException e) {
+ }
+ try {
+ conn.close();
+ } catch (SQLException e) {
+ }
+ }
+
+ public void prepareDatabase() throws SQLException {
+ stmt.execute("DROP DATABASE IF EXISTS test");
+ stmt.execute("CREATE DATABASE test");
+ stmt.execute("CREATE STABLE test.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)");
+ }
+
+ public Long count() throws SQLException {
+ if (!stmt.isClosed()) {
+ ResultSet result = stmt.executeQuery("SELECT count(*) from test.meters");
+ result.next();
+ return result.getLong(1);
+ }
+ return null;
+ }
+
+ /**
+ * show test.stables;
+ *
+ * name | created_time | columns | tags | tables |
+ * ============================================================================================
+ * meters | 2022-07-20 08:39:30.902 | 4 | 2 | 620000 |
+ */
+ public Long getTableCount() throws SQLException {
+ if (!stmt.isClosed()) {
+ ResultSet result = stmt.executeQuery("show test.stables");
+ result.next();
+ return result.getLong(5);
+ }
+ return null;
+ }
+}
\ No newline at end of file
diff --git a/docs/examples/java/src/main/java/com/taos/example/highvolume/FastWriteExample.java b/docs/examples/java/src/main/java/com/taos/example/highvolume/FastWriteExample.java
new file mode 100644
index 0000000000000000000000000000000000000000..41b59551ca69a4056c2f2b572d169bd08dc4fcfe
--- /dev/null
+++ b/docs/examples/java/src/main/java/com/taos/example/highvolume/FastWriteExample.java
@@ -0,0 +1,70 @@
+package com.taos.example.highvolume;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.sql.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.BlockingQueue;
+
+
+public class FastWriteExample {
+ final static Logger logger = LoggerFactory.getLogger(FastWriteExample.class);
+
+ final static int taskQueueCapacity = 1000000;
+ final static List> taskQueues = new ArrayList<>();
+ final static List readTasks = new ArrayList<>();
+ final static List writeTasks = new ArrayList<>();
+ final static DataBaseMonitor databaseMonitor = new DataBaseMonitor();
+
+ public static void stopAll() {
+ logger.info("shutting down");
+ readTasks.forEach(task -> task.stop());
+ writeTasks.forEach(task -> task.stop());
+ databaseMonitor.close();
+ }
+
+ public static void main(String[] args) throws InterruptedException, SQLException {
+ int readTaskCount = args.length > 0 ? Integer.parseInt(args[0]) : 1;
+ int writeTaskCount = args.length > 1 ? Integer.parseInt(args[1]) : 3;
+ int tableCount = args.length > 2 ? Integer.parseInt(args[2]) : 1000;
+ int maxBatchSize = args.length > 3 ? Integer.parseInt(args[3]) : 3000;
+
+ logger.info("readTaskCount={}, writeTaskCount={} tableCount={} maxBatchSize={}",
+ readTaskCount, writeTaskCount, tableCount, maxBatchSize);
+
+ databaseMonitor.init().prepareDatabase();
+
+ // Create task queues, whiting tasks and start writing threads.
+ for (int i = 0; i < writeTaskCount; ++i) {
+ BlockingQueue queue = new ArrayBlockingQueue<>(taskQueueCapacity);
+ taskQueues.add(queue);
+ WriteTask task = new WriteTask(queue, maxBatchSize);
+ Thread t = new Thread(task);
+ t.setName("WriteThread-" + i);
+ t.start();
+ }
+
+ // create reading tasks and start reading threads
+ int tableCountPerTask = tableCount / readTaskCount;
+ for (int i = 0; i < readTaskCount; ++i) {
+ ReadTask task = new ReadTask(i, taskQueues, tableCountPerTask);
+ Thread t = new Thread(task);
+ t.setName("ReadThread-" + i);
+ t.start();
+ }
+
+ Runtime.getRuntime().addShutdownHook(new Thread(FastWriteExample::stopAll));
+
+ long lastCount = 0;
+ while (true) {
+ Thread.sleep(10000);
+ long numberOfTable = databaseMonitor.getTableCount();
+ long count = databaseMonitor.count();
+ logger.info("numberOfTable={} count={} speed={}", numberOfTable, count, (count - lastCount) / 10);
+ lastCount = count;
+ }
+ }
+}
\ No newline at end of file
diff --git a/docs/examples/java/src/main/java/com/taos/example/highvolume/MockDataSource.java b/docs/examples/java/src/main/java/com/taos/example/highvolume/MockDataSource.java
new file mode 100644
index 0000000000000000000000000000000000000000..6fe83f002ebcb9d82e026e9a32886fd22bfefbe9
--- /dev/null
+++ b/docs/examples/java/src/main/java/com/taos/example/highvolume/MockDataSource.java
@@ -0,0 +1,53 @@
+package com.taos.example.highvolume;
+
+import java.util.Iterator;
+
+/**
+ * Generate test data
+ */
+class MockDataSource implements Iterator {
+ private String tbNamePrefix;
+ private int tableCount;
+ private long maxRowsPerTable = 1000000000L;
+
+ // 100 milliseconds between two neighbouring rows.
+ long startMs = System.currentTimeMillis() - maxRowsPerTable * 100;
+ private int currentRow = 0;
+ private int currentTbId = -1;
+
+ // mock values
+ String[] location = {"LosAngeles", "SanDiego", "Hollywood", "Compton", "San Francisco"};
+ float[] current = {8.8f, 10.7f, 9.9f, 8.9f, 9.4f};
+ int[] voltage = {119, 116, 111, 113, 118};
+ float[] phase = {0.32f, 0.34f, 0.33f, 0.329f, 0.141f};
+
+ public MockDataSource(String tbNamePrefix, int tableCount) {
+ this.tbNamePrefix = tbNamePrefix;
+ this.tableCount = tableCount;
+ }
+
+ @Override
+ public boolean hasNext() {
+ currentTbId += 1;
+ if (currentTbId == tableCount) {
+ currentTbId = 0;
+ currentRow += 1;
+ }
+ return currentRow < maxRowsPerTable;
+ }
+
+ @Override
+ public String next() {
+ long ts = startMs + 100 * currentRow;
+ int groupId = currentTbId % 5 == 0 ? currentTbId / 5 : currentTbId / 5 + 1;
+ StringBuilder sb = new StringBuilder(tbNamePrefix + "_" + currentTbId + ","); // tbName
+ sb.append(ts).append(','); // ts
+ sb.append(current[currentRow % 5]).append(','); // current
+ sb.append(voltage[currentRow % 5]).append(','); // voltage
+ sb.append(phase[currentRow % 5]).append(','); // phase
+ sb.append(location[currentRow % 5]).append(','); // location
+ sb.append(groupId); // groupID
+
+ return sb.toString();
+ }
+}
\ No newline at end of file
diff --git a/docs/examples/java/src/main/java/com/taos/example/highvolume/ReadTask.java b/docs/examples/java/src/main/java/com/taos/example/highvolume/ReadTask.java
new file mode 100644
index 0000000000000000000000000000000000000000..a6fcfed1d28281d46aff493ef9783972858ebe62
--- /dev/null
+++ b/docs/examples/java/src/main/java/com/taos/example/highvolume/ReadTask.java
@@ -0,0 +1,58 @@
+package com.taos.example.highvolume;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.BlockingQueue;
+
+class ReadTask implements Runnable {
+ private final static Logger logger = LoggerFactory.getLogger(ReadTask.class);
+ private final int taskId;
+ private final List> taskQueues;
+ private final int queueCount;
+ private final int tableCount;
+ private boolean active = true;
+
+ public ReadTask(int readTaskId, List> queues, int tableCount) {
+ this.taskId = readTaskId;
+ this.taskQueues = queues;
+ this.queueCount = queues.size();
+ this.tableCount = tableCount;
+ }
+
+ /**
+ * Assign data received to different queues.
+ * Here we use the suffix number in table name.
+ * You are expected to define your own rule in practice.
+ *
+ * @param line record received
+ * @return which queue to use
+ */
+ public int getQueueId(String line) {
+ String tbName = line.substring(0, line.indexOf(',')); // For example: tb1_101
+ String suffixNumber = tbName.split("_")[1];
+ return Integer.parseInt(suffixNumber) % this.queueCount;
+ }
+
+ @Override
+ public void run() {
+ logger.info("started");
+ Iterator it = new MockDataSource("tb" + this.taskId, tableCount);
+ try {
+ while (it.hasNext() && active) {
+ String line = it.next();
+ int queueId = getQueueId(line);
+ taskQueues.get(queueId).put(line);
+ }
+ } catch (Exception e) {
+ logger.error("Read Task Error", e);
+ }
+ }
+
+ public void stop() {
+ logger.info("stop");
+ this.active = false;
+ }
+}
\ No newline at end of file
diff --git a/docs/examples/java/src/main/java/com/taos/example/highvolume/SQLWriter.java b/docs/examples/java/src/main/java/com/taos/example/highvolume/SQLWriter.java
new file mode 100644
index 0000000000000000000000000000000000000000..c2989acdbe3d0f56d7451ac86051a55955ce14de
--- /dev/null
+++ b/docs/examples/java/src/main/java/com/taos/example/highvolume/SQLWriter.java
@@ -0,0 +1,205 @@
+package com.taos.example.highvolume;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.sql.*;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A helper class encapsulate the logic of writing using SQL.
+ *
+ * The main interfaces are two methods:
+ *
+ *
{@link SQLWriter#processLine}, which receive raw lines from WriteTask and group them by table names.
+ *
{@link SQLWriter#flush}, which assemble INSERT statement and execute it.
+ *
+ *
+ * There is a technical skill worth mentioning: we create table as needed when "table does not exist" error occur instead of creating table automatically using syntax "INSET INTO tb USING stb".
+ * This ensure that checking table existence is a one-time-only operation.
+ *
+ *
+ *
+ */
+public class SQLWriter {
+ final static Logger logger = LoggerFactory.getLogger(SQLWriter.class);
+
+ private Connection conn;
+ private Statement stmt;
+
+ /**
+ * current number of buffered records
+ */
+ private int bufferedCount = 0;
+ /**
+ * Maximum number of buffered records.
+ * Flush action will be triggered if bufferedCount reached this value,
+ */
+ private int maxBatchSize;
+
+
+ /**
+ * Maximum SQL length.
+ */
+ private int maxSQLLength;
+
+ /**
+ * Map from table name to column values. For example:
+ * "tb001" -> "(1648432611249,2.1,114,0.09) (1648432611250,2.2,135,0.2)"
+ */
+ private Map tbValues = new HashMap<>();
+
+ /**
+ * Map from table name to tag values in the same order as creating stable.
+ * Used for creating table.
+ */
+ private Map tbTags = new HashMap<>();
+
+ public SQLWriter(int maxBatchSize) {
+ this.maxBatchSize = maxBatchSize;
+ }
+
+
+ /**
+ * Get Database Connection
+ *
+ * @return Connection
+ * @throws SQLException
+ */
+ private static Connection getConnection() throws SQLException {
+ String jdbcURL = System.getenv("TDENGINE_JDBC_URL");
+ return DriverManager.getConnection(jdbcURL);
+ }
+
+ /**
+ * Create Connection and Statement
+ *
+ * @throws SQLException
+ */
+ public void init() throws SQLException {
+ conn = getConnection();
+ stmt = conn.createStatement();
+ stmt.execute("use test");
+ ResultSet rs = stmt.executeQuery("show variables");
+ while (rs.next()) {
+ String configName = rs.getString(1);
+ if ("maxSQLLength".equals(configName)) {
+ maxSQLLength = Integer.parseInt(rs.getString(2));
+ logger.info("maxSQLLength={}", maxSQLLength);
+ }
+ }
+ }
+
+ /**
+ * Convert raw data to SQL fragments, group them by table name and cache them in a HashMap.
+ * Trigger writing when number of buffered records reached maxBachSize.
+ *
+ * @param line raw data get from task queue in format: tbName,ts,current,voltage,phase,location,groupId
+ */
+ public void processLine(String line) throws SQLException {
+ bufferedCount += 1;
+ int firstComma = line.indexOf(',');
+ String tbName = line.substring(0, firstComma);
+ int lastComma = line.lastIndexOf(',');
+ int secondLastComma = line.lastIndexOf(',', lastComma - 1);
+ String value = "(" + line.substring(firstComma + 1, secondLastComma) + ") ";
+ if (tbValues.containsKey(tbName)) {
+ tbValues.put(tbName, tbValues.get(tbName) + value);
+ } else {
+ tbValues.put(tbName, value);
+ }
+ if (!tbTags.containsKey(tbName)) {
+ String location = line.substring(secondLastComma + 1, lastComma);
+ String groupId = line.substring(lastComma + 1);
+ String tagValues = "('" + location + "'," + groupId + ')';
+ tbTags.put(tbName, tagValues);
+ }
+ if (bufferedCount == maxBatchSize) {
+ flush();
+ }
+ }
+
+
+ /**
+ * Assemble INSERT statement using buffered SQL fragments in Map {@link SQLWriter#tbValues} and execute it.
+ * In case of "Table does not exit" exception, create all tables in the sql and retry the sql.
+ */
+ public void flush() throws SQLException {
+ StringBuilder sb = new StringBuilder("INSERT INTO ");
+ for (Map.Entry entry : tbValues.entrySet()) {
+ String tableName = entry.getKey();
+ String values = entry.getValue();
+ String q = tableName + " values " + values + " ";
+ if (sb.length() + q.length() > maxSQLLength) {
+ executeSQL(sb.toString());
+ logger.warn("increase maxSQLLength or decrease maxBatchSize to gain better performance");
+ sb = new StringBuilder("INSERT INTO ");
+ }
+ sb.append(q);
+ }
+ executeSQL(sb.toString());
+ tbValues.clear();
+ bufferedCount = 0;
+ }
+
+ private void executeSQL(String sql) throws SQLException {
+ try {
+ stmt.executeUpdate(sql);
+ } catch (SQLException e) {
+ // convert to error code defined in taoserror.h
+ int errorCode = e.getErrorCode() & 0xffff;
+ if (errorCode == 0x362 || errorCode == 0x218) {
+ // Table does not exist
+ createTables();
+ executeSQL(sql);
+ } else {
+ logger.error("Execute SQL: {}", sql);
+ throw e;
+ }
+ } catch (Throwable throwable) {
+ logger.error("Execute SQL: {}", sql);
+ throw throwable;
+ }
+ }
+
+ /**
+ * Create tables in batch using syntax:
+ *
+ * CREATE TABLE [IF NOT EXISTS] tb_name1 USING stb_name TAGS (tag_value1, ...) [IF NOT EXISTS] tb_name2 USING stb_name TAGS (tag_value2, ...) ...;
+ *
+ */
+ private void createTables() throws SQLException {
+ StringBuilder sb = new StringBuilder("CREATE TABLE ");
+ for (String tbName : tbValues.keySet()) {
+ String tagValues = tbTags.get(tbName);
+ sb.append("IF NOT EXISTS ").append(tbName).append(" USING meters TAGS ").append(tagValues).append(" ");
+ }
+ String sql = sb.toString();
+ try {
+ stmt.executeUpdate(sql);
+ } catch (Throwable throwable) {
+ logger.error("Execute SQL: {}", sql);
+ throw throwable;
+ }
+ }
+
+ public boolean hasBufferedValues() {
+ return bufferedCount > 0;
+ }
+
+ public int getBufferedCount() {
+ return bufferedCount;
+ }
+
+ public void close() {
+ try {
+ stmt.close();
+ } catch (SQLException e) {
+ }
+ try {
+ conn.close();
+ } catch (SQLException e) {
+ }
+ }
+}
\ No newline at end of file
diff --git a/docs/examples/java/src/main/java/com/taos/example/highvolume/StmtWriter.java b/docs/examples/java/src/main/java/com/taos/example/highvolume/StmtWriter.java
new file mode 100644
index 0000000000000000000000000000000000000000..8ade06625d708a112c85d5657aa00bcd0e605ff4
--- /dev/null
+++ b/docs/examples/java/src/main/java/com/taos/example/highvolume/StmtWriter.java
@@ -0,0 +1,4 @@
+package com.taos.example.highvolume;
+
+public class StmtWriter {
+}
diff --git a/docs/examples/java/src/main/java/com/taos/example/highvolume/WriteTask.java b/docs/examples/java/src/main/java/com/taos/example/highvolume/WriteTask.java
new file mode 100644
index 0000000000000000000000000000000000000000..de9e5463d7dc59478f991e4783aacaae527b4c4b
--- /dev/null
+++ b/docs/examples/java/src/main/java/com/taos/example/highvolume/WriteTask.java
@@ -0,0 +1,58 @@
+package com.taos.example.highvolume;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.concurrent.BlockingQueue;
+
+class WriteTask implements Runnable {
+ private final static Logger logger = LoggerFactory.getLogger(WriteTask.class);
+ private final int maxBatchSize;
+
+ // the queue from which this writing task get raw data.
+ private final BlockingQueue queue;
+
+ // A flag indicate whether to continue.
+ private boolean active = true;
+
+ public WriteTask(BlockingQueue taskQueue, int maxBatchSize) {
+ this.queue = taskQueue;
+ this.maxBatchSize = maxBatchSize;
+ }
+
+ @Override
+ public void run() {
+ logger.info("started");
+ String line = null; // data getting from the queue just now.
+ SQLWriter writer = new SQLWriter(maxBatchSize);
+ try {
+ writer.init();
+ while (active) {
+ line = queue.poll();
+ if (line != null) {
+ // parse raw data and buffer the data.
+ writer.processLine(line);
+ } else if (writer.hasBufferedValues()) {
+ // write data immediately if no more data in the queue
+ writer.flush();
+ } else {
+ // sleep a while to avoid high CPU usage if no more data in the queue and no buffered records, .
+ Thread.sleep(100);
+ }
+ }
+ if (writer.hasBufferedValues()) {
+ writer.flush();
+ }
+ } catch (Exception e) {
+ String msg = String.format("line=%s, bufferedCount=%s", line, writer.getBufferedCount());
+ logger.error(msg, e);
+ } finally {
+ writer.close();
+ }
+ }
+
+ public void stop() {
+ logger.info("stop");
+ this.active = false;
+ }
+}
\ No newline at end of file
diff --git a/docs/examples/java/src/test/java/com/taos/test/TestAll.java b/docs/examples/java/src/test/java/com/taos/test/TestAll.java
index 42db24485afec05298159f7b0c3a4e15835d98ed..8d201da0745e1d2d36220c9d78383fc37d4a813a 100644
--- a/docs/examples/java/src/test/java/com/taos/test/TestAll.java
+++ b/docs/examples/java/src/test/java/com/taos/test/TestAll.java
@@ -23,16 +23,16 @@ public class TestAll {
String jdbcUrl = "jdbc:TAOS://localhost:6030?user=root&password=taosdata";
try (Connection conn = DriverManager.getConnection(jdbcUrl)) {
try (Statement stmt = conn.createStatement()) {
- String sql = "INSERT INTO power.d1001 USING power.meters TAGS(California.SanFrancisco, 2) VALUES('2018-10-03 14:38:05.000',10.30000,219,0.31000)\n" +
- " power.d1001 USING power.meters TAGS(California.SanFrancisco, 2) VALUES('2018-10-03 15:38:15.000',12.60000,218,0.33000)\n" +
- " power.d1001 USING power.meters TAGS(California.SanFrancisco, 2) VALUES('2018-10-03 15:38:16.800',12.30000,221,0.31000)\n" +
- " power.d1002 USING power.meters TAGS(California.SanFrancisco, 3) VALUES('2018-10-03 15:38:16.650',10.30000,218,0.25000)\n" +
- " power.d1003 USING power.meters TAGS(California.LosAngeles, 2) VALUES('2018-10-03 15:38:05.500',11.80000,221,0.28000)\n" +
- " power.d1003 USING power.meters TAGS(California.LosAngeles, 2) VALUES('2018-10-03 15:38:16.600',13.40000,223,0.29000)\n" +
- " power.d1004 USING power.meters TAGS(California.LosAngeles, 3) VALUES('2018-10-03 15:38:05.000',10.80000,223,0.29000)\n" +
- " power.d1004 USING power.meters TAGS(California.LosAngeles, 3) VALUES('2018-10-03 15:38:06.000',10.80000,223,0.29000)\n" +
- " power.d1004 USING power.meters TAGS(California.LosAngeles, 3) VALUES('2018-10-03 15:38:07.000',10.80000,223,0.29000)\n" +
- " power.d1004 USING power.meters TAGS(California.LosAngeles, 3) VALUES('2018-10-03 15:38:08.500',11.50000,221,0.35000)";
+ String sql = "INSERT INTO power.d1001 USING power.meters TAGS('California.SanFrancisco', 2) VALUES('2018-10-03 14:38:05.000',10.30000,219,0.31000)\n" +
+ " power.d1001 USING power.meters TAGS('California.SanFrancisco', 2) VALUES('2018-10-03 15:38:15.000',12.60000,218,0.33000)\n" +
+ " power.d1001 USING power.meters TAGS('California.SanFrancisco', 2) VALUES('2018-10-03 15:38:16.800',12.30000,221,0.31000)\n" +
+ " power.d1002 USING power.meters TAGS('California.SanFrancisco', 3) VALUES('2018-10-03 15:38:16.650',10.30000,218,0.25000)\n" +
+ " power.d1003 USING power.meters TAGS('California.LosAngeles', 2) VALUES('2018-10-03 15:38:05.500',11.80000,221,0.28000)\n" +
+ " power.d1003 USING power.meters TAGS('California.LosAngeles', 2) VALUES('2018-10-03 15:38:16.600',13.40000,223,0.29000)\n" +
+ " power.d1004 USING power.meters TAGS('California.LosAngeles', 3) VALUES('2018-10-03 15:38:05.000',10.80000,223,0.29000)\n" +
+ " power.d1004 USING power.meters TAGS('California.LosAngeles', 3) VALUES('2018-10-03 15:38:06.000',10.80000,223,0.29000)\n" +
+ " power.d1004 USING power.meters TAGS('California.LosAngeles', 3) VALUES('2018-10-03 15:38:07.000',10.80000,223,0.29000)\n" +
+ " power.d1004 USING power.meters TAGS('California.LosAngeles', 3) VALUES('2018-10-03 15:38:08.500',11.50000,221,0.35000)";
stmt.execute(sql);
}
diff --git a/docs/examples/node/nativeexample/subscribe_demo.js b/docs/examples/node/nativeexample/subscribe_demo.js
index c4f7e6df84933f8f8541814cabd231fcf5c2db68..53cbe55d264a0e83b4d4b441b0b912872bbb7018 100644
--- a/docs/examples/node/nativeexample/subscribe_demo.js
+++ b/docs/examples/node/nativeexample/subscribe_demo.js
@@ -48,4 +48,4 @@ try {
cursor.close();
conn.close();
}, 2000);
-}
\ No newline at end of file
+}
diff --git a/docs/examples/node/package.json b/docs/examples/node/package.json
index 36d3f016b5262472d5c63a2c98cc9704e57a59fe..d00d71d99fdff89af68f31a50416681733a08274 100644
--- a/docs/examples/node/package.json
+++ b/docs/examples/node/package.json
@@ -4,7 +4,7 @@
"main": "index.js",
"license": "MIT",
"dependencies": {
- "@tdengine/client": "^3.0.0",
+ "@tdengine/client": "^3.0.1",
"@tdengine/rest": "^3.0.0"
}
}
diff --git a/docs/examples/python/connect_native_reference.py b/docs/examples/python/connect_native_reference.py
index c17e9795b58724f6646b8d7c0f84047098a93d69..09b0685acef8c68b30153da5a1761d36b1cf9aae 100644
--- a/docs/examples/python/connect_native_reference.py
+++ b/docs/examples/python/connect_native_reference.py
@@ -11,10 +11,10 @@ conn: taos.TaosConnection = taos.connect(host="localhost",
server_version = conn.server_info
print("server_version", server_version)
client_version = conn.client_info
-print("client_version", client_version) # 2.4.0.16
+print("client_version", client_version) # 3.0.0.0
conn.close()
# possible output:
-# 2.4.0.16
-# 2.4.0.16
+# 3.0.0.0
+# 3.0.0.0
diff --git a/docs/examples/python/fast_write_example.py b/docs/examples/python/fast_write_example.py
new file mode 100644
index 0000000000000000000000000000000000000000..c9d606388fdecd85f1468f24cc497ecc5941f035
--- /dev/null
+++ b/docs/examples/python/fast_write_example.py
@@ -0,0 +1,180 @@
+# install dependencies:
+# recommend python >= 3.8
+# pip3 install faster-fifo
+#
+
+import logging
+import math
+import sys
+import time
+import os
+from multiprocessing import Process
+from faster_fifo import Queue
+from mockdatasource import MockDataSource
+from queue import Empty
+from typing import List
+
+logging.basicConfig(stream=sys.stdout, level=logging.DEBUG, format="%(asctime)s [%(name)s] - %(message)s")
+
+READ_TASK_COUNT = 1
+WRITE_TASK_COUNT = 1
+TABLE_COUNT = 1000
+QUEUE_SIZE = 1000000
+MAX_BATCH_SIZE = 3000
+
+read_processes = []
+write_processes = []
+
+
+def get_connection():
+ """
+ If variable TDENGINE_FIRST_EP is provided then it will be used. If not, firstEP in /etc/taos/taos.cfg will be used.
+ You can also override the default username and password by supply variable TDENGINE_USER and TDENGINE_PASSWORD
+ """
+ import taos
+ firstEP = os.environ.get("TDENGINE_FIRST_EP")
+ if firstEP:
+ host, port = firstEP.split(":")
+ else:
+ host, port = None, 0
+ user = os.environ.get("TDENGINE_USER", "root")
+ password = os.environ.get("TDENGINE_PASSWORD", "taosdata")
+ return taos.connect(host=host, port=int(port), user=user, password=password)
+
+
+# ANCHOR: read
+
+def run_read_task(task_id: int, task_queues: List[Queue]):
+ table_count_per_task = TABLE_COUNT // READ_TASK_COUNT
+ data_source = MockDataSource(f"tb{task_id}", table_count_per_task)
+ try:
+ for batch in data_source:
+ for table_id, rows in batch:
+ # hash data to different queue
+ i = table_id % len(task_queues)
+ # block putting forever when the queue is full
+ task_queues[i].put_many(rows, block=True, timeout=-1)
+ except KeyboardInterrupt:
+ pass
+
+
+# ANCHOR_END: read
+
+# ANCHOR: write
+def run_write_task(task_id: int, queue: Queue):
+ from sql_writer import SQLWriter
+ log = logging.getLogger(f"WriteTask-{task_id}")
+ writer = SQLWriter(get_connection)
+ lines = None
+ try:
+ while True:
+ try:
+ # get as many as possible
+ lines = queue.get_many(block=False, max_messages_to_get=MAX_BATCH_SIZE)
+ writer.process_lines(lines)
+ except Empty:
+ time.sleep(0.01)
+ except KeyboardInterrupt:
+ pass
+ except BaseException as e:
+ log.debug(f"lines={lines}")
+ raise e
+
+
+# ANCHOR_END: write
+
+def set_global_config():
+ argc = len(sys.argv)
+ if argc > 1:
+ global READ_TASK_COUNT
+ READ_TASK_COUNT = int(sys.argv[1])
+ if argc > 2:
+ global WRITE_TASK_COUNT
+ WRITE_TASK_COUNT = int(sys.argv[2])
+ if argc > 3:
+ global TABLE_COUNT
+ TABLE_COUNT = int(sys.argv[3])
+ if argc > 4:
+ global QUEUE_SIZE
+ QUEUE_SIZE = int(sys.argv[4])
+ if argc > 5:
+ global MAX_BATCH_SIZE
+ MAX_BATCH_SIZE = int(sys.argv[5])
+
+
+# ANCHOR: monitor
+def run_monitor_process():
+ log = logging.getLogger("DataBaseMonitor")
+ conn = get_connection()
+ conn.execute("DROP DATABASE IF EXISTS test")
+ conn.execute("CREATE DATABASE test")
+ conn.execute("CREATE STABLE test.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) "
+ "TAGS (location BINARY(64), groupId INT)")
+
+ def get_count():
+ res = conn.query("SELECT count(*) FROM test.meters")
+ rows = res.fetch_all()
+ return rows[0][0] if rows else 0
+
+ last_count = 0
+ while True:
+ time.sleep(10)
+ count = get_count()
+ log.info(f"count={count} speed={(count - last_count) / 10}")
+ last_count = count
+
+
+# ANCHOR_END: monitor
+# ANCHOR: main
+def main():
+ set_global_config()
+ logging.info(f"READ_TASK_COUNT={READ_TASK_COUNT}, WRITE_TASK_COUNT={WRITE_TASK_COUNT}, "
+ f"TABLE_COUNT={TABLE_COUNT}, QUEUE_SIZE={QUEUE_SIZE}, MAX_BATCH_SIZE={MAX_BATCH_SIZE}")
+
+ monitor_process = Process(target=run_monitor_process)
+ monitor_process.start()
+ time.sleep(3) # waiting for database ready.
+
+ task_queues: List[Queue] = []
+ # create task queues
+ for i in range(WRITE_TASK_COUNT):
+ queue = Queue(max_size_bytes=QUEUE_SIZE)
+ task_queues.append(queue)
+
+ # create write processes
+ for i in range(WRITE_TASK_COUNT):
+ p = Process(target=run_write_task, args=(i, task_queues[i]))
+ p.start()
+ logging.debug(f"WriteTask-{i} started with pid {p.pid}")
+ write_processes.append(p)
+
+ # create read processes
+ for i in range(READ_TASK_COUNT):
+ queues = assign_queues(i, task_queues)
+ p = Process(target=run_read_task, args=(i, queues))
+ p.start()
+ logging.debug(f"ReadTask-{i} started with pid {p.pid}")
+ read_processes.append(p)
+
+ try:
+ monitor_process.join()
+ except KeyboardInterrupt:
+ monitor_process.terminate()
+ [p.terminate() for p in read_processes]
+ [p.terminate() for p in write_processes]
+ [q.close() for q in task_queues]
+
+
+def assign_queues(read_task_id, task_queues):
+ """
+ Compute target queues for a specific read task.
+ """
+ ratio = WRITE_TASK_COUNT / READ_TASK_COUNT
+ from_index = math.floor(read_task_id * ratio)
+ end_index = math.ceil((read_task_id + 1) * ratio)
+ return task_queues[from_index:end_index]
+
+
+if __name__ == '__main__':
+ main()
+# ANCHOR_END: main
diff --git a/docs/examples/python/mockdatasource.py b/docs/examples/python/mockdatasource.py
new file mode 100644
index 0000000000000000000000000000000000000000..852860aec0adc8f9b043c9dcd5deb0bf00239201
--- /dev/null
+++ b/docs/examples/python/mockdatasource.py
@@ -0,0 +1,49 @@
+import time
+
+
+class MockDataSource:
+ samples = [
+ "8.8,119,0.32,LosAngeles,0",
+ "10.7,116,0.34,SanDiego,1",
+ "9.9,111,0.33,Hollywood,2",
+ "8.9,113,0.329,Compton,3",
+ "9.4,118,0.141,San Francisco,4"
+ ]
+
+ def __init__(self, tb_name_prefix, table_count):
+ self.table_name_prefix = tb_name_prefix + "_"
+ self.table_count = table_count
+ self.max_rows = 10000000
+ self.current_ts = round(time.time() * 1000) - self.max_rows * 100
+ # [(tableId, tableName, values),]
+ self.data = self._init_data()
+
+ def _init_data(self):
+ lines = self.samples * (self.table_count // 5 + 1)
+ data = []
+ for i in range(self.table_count):
+ table_name = self.table_name_prefix + str(i)
+ data.append((i, table_name, lines[i])) # tableId, row
+ return data
+
+ def __iter__(self):
+ self.row = 0
+ return self
+
+ def __next__(self):
+ """
+ next 1000 rows for each table.
+ return: {tableId:[row,...]}
+ """
+ # generate 1000 timestamps
+ ts = []
+ for _ in range(1000):
+ self.current_ts += 100
+ ts.append(str(self.current_ts))
+ # add timestamp to each row
+ # [(tableId, ["tableName,ts,current,voltage,phase,location,groupId"])]
+ result = []
+ for table_id, table_name, values in self.data:
+ rows = [table_name + ',' + t + ',' + values for t in ts]
+ result.append((table_id, rows))
+ return result
diff --git a/docs/examples/python/sql_writer.py b/docs/examples/python/sql_writer.py
new file mode 100644
index 0000000000000000000000000000000000000000..758167376b009f21afc701be7d89c1bfbabdeb9f
--- /dev/null
+++ b/docs/examples/python/sql_writer.py
@@ -0,0 +1,90 @@
+import logging
+import taos
+
+
+class SQLWriter:
+ log = logging.getLogger("SQLWriter")
+
+ def __init__(self, get_connection_func):
+ self._tb_values = {}
+ self._tb_tags = {}
+ self._conn = get_connection_func()
+ self._max_sql_length = self.get_max_sql_length()
+ self._conn.execute("USE test")
+
+ def get_max_sql_length(self):
+ rows = self._conn.query("SHOW variables").fetch_all()
+ for r in rows:
+ name = r[0]
+ if name == "maxSQLLength":
+ return int(r[1])
+ return 1024 * 1024
+
+ def process_lines(self, lines: str):
+ """
+ :param lines: [[tbName,ts,current,voltage,phase,location,groupId]]
+ """
+ for line in lines:
+ ps = line.split(",")
+ table_name = ps[0]
+ value = '(' + ",".join(ps[1:-2]) + ') '
+ if table_name in self._tb_values:
+ self._tb_values[table_name] += value
+ else:
+ self._tb_values[table_name] = value
+
+ if table_name not in self._tb_tags:
+ location = ps[-2]
+ group_id = ps[-1]
+ tag_value = f"('{location}',{group_id})"
+ self._tb_tags[table_name] = tag_value
+ self.flush()
+
+ def flush(self):
+ """
+ Assemble INSERT statement and execute it.
+ When the sql length grows close to MAX_SQL_LENGTH, the sql will be executed immediately, and a new INSERT statement will be created.
+ In case of "Table does not exit" exception, tables in the sql will be created and the sql will be re-executed.
+ """
+ sql = "INSERT INTO "
+ sql_len = len(sql)
+ buf = []
+ for tb_name, values in self._tb_values.items():
+ q = tb_name + " VALUES " + values
+ if sql_len + len(q) >= self._max_sql_length:
+ sql += " ".join(buf)
+ self.execute_sql(sql)
+ sql = "INSERT INTO "
+ sql_len = len(sql)
+ buf = []
+ buf.append(q)
+ sql_len += len(q)
+ sql += " ".join(buf)
+ self.execute_sql(sql)
+ self._tb_values.clear()
+
+ def execute_sql(self, sql):
+ try:
+ self._conn.execute(sql)
+ except taos.Error as e:
+ error_code = e.errno & 0xffff
+ # Table does not exit
+ if error_code == 9731:
+ self.create_tables()
+ else:
+ self.log.error("Execute SQL: %s", sql)
+ raise e
+ except BaseException as baseException:
+ self.log.error("Execute SQL: %s", sql)
+ raise baseException
+
+ def create_tables(self):
+ sql = "CREATE TABLE "
+ for tb in self._tb_values.keys():
+ tag_values = self._tb_tags[tb]
+ sql += "IF NOT EXISTS " + tb + " USING meters TAGS " + tag_values + " "
+ try:
+ self._conn.execute(sql)
+ except BaseException as e:
+ self.log.error("Execute SQL: %s", sql)
+ raise e
diff --git a/docs/examples/python/subscribe_demo.py b/docs/examples/python/subscribe_demo.py
deleted file mode 100644
index db9d49c3f4f8122634800c02a683d4cb022a7ba0..0000000000000000000000000000000000000000
--- a/docs/examples/python/subscribe_demo.py
+++ /dev/null
@@ -1,38 +0,0 @@
-"""
-Python asynchronous subscribe demo.
-run on Linux system with: python3 subscribe_demo.py
-"""
-
-from ctypes import c_void_p
-
-import taos
-import time
-
-
-def query_callback(p_sub, p_result, p_param, code):
- """
- :param p_sub: pointer returned by native API -- taos_subscribe
- :param p_result: pointer to native TAOS_RES
- :param p_param: None
- :param code: error code
- :return: None
- """
- print("in callback")
- result = taos.TaosResult(c_void_p(p_result))
- # raise exception if error occur
- result.check_error(code)
- for row in result.rows_iter():
- print(row)
- print(f"{result.row_count} rows consumed.")
-
-
-if __name__ == '__main__':
- conn = taos.connect()
- restart = True
- topic = "topic-meter-current-bg"
- sql = "select * from power.meters where current > 10" # Error sql
- interval = 2000 # consumption interval in microseconds.
- _ = conn.subscribe(restart, topic, sql, interval, query_callback)
- # Note: we received the return value as _ above, to avoid the TaosSubscription object to be deleted by gc.
- while True:
- time.sleep(10) # use Ctrl + C to interrupt
diff --git a/docs/examples/python/tmq_example.py b/docs/examples/python/tmq_example.py
index 1f6da3d1b6690ab12527c1810286ba22a7688851..cee036454ec4d3f4809576a1eee8ac054fcba056 100644
--- a/docs/examples/python/tmq_example.py
+++ b/docs/examples/python/tmq_example.py
@@ -1,59 +1,6 @@
import taos
-from taos.tmq import *
-
-conn = taos.connect()
-
-# create database
-conn.execute("drop database if exists py_tmq")
-conn.execute("create database if not exists py_tmq vgroups 2")
-
-# create table and stables
-conn.select_db("py_tmq")
-conn.execute("create stable if not exists stb1 (ts timestamp, c1 int, c2 float, c3 binary(10)) tags(t1 int)")
-conn.execute("create table if not exists tb1 using stb1 tags(1)")
-conn.execute("create table if not exists tb2 using stb1 tags(2)")
-conn.execute("create table if not exists tb3 using stb1 tags(3)")
-
-# create topic
-conn.execute("drop topic if exists topic_ctb_column")
-conn.execute("create topic if not exists topic_ctb_column as select ts, c1, c2, c3 from stb1")
-
-# set consumer configure options
-conf = TaosTmqConf()
-conf.set("group.id", "tg2")
-conf.set("td.connect.user", "root")
-conf.set("td.connect.pass", "taosdata")
-conf.set("enable.auto.commit", "true")
-conf.set("msg.with.table.name", "true")
-
-def tmq_commit_cb_print(tmq, resp, offset, param=None):
- print(f"commit: {resp}, tmq: {tmq}, offset: {offset}, param: {param}")
-
-conf.set_auto_commit_cb(tmq_commit_cb_print, None)
-
-# build consumer
-tmq = conf.new_consumer()
-
-# build topic list
-topic_list = TaosTmqList()
-topic_list.append("topic_ctb_column")
-
-# subscribe consumer
-tmq.subscribe(topic_list)
-
-# check subscriptions
-sub_list = tmq.subscription()
-print("subscribed topics: ",sub_list)
-
-# start subscribe
-while 1:
- res = tmq.poll(1000)
- if res:
- topic = res.get_topic_name()
- vg = res.get_vgroup_id()
- db = res.get_db_name()
- print(f"topic: {topic}\nvgroup id: {vg}\ndb: {db}")
- for row in res:
- print(row)
- tb = res.get_table_name()
- print(f"from table: {tb}")
+from taos.tmq import TaosConsumer
+consumer = TaosConsumer('topic_ctb_column', group_id='vg2')
+for msg in consumer:
+ for row in msg:
+ print(row)
diff --git a/docs/examples/rust/Cargo.toml b/docs/examples/rust/Cargo.toml
deleted file mode 100644
index 136d09ffbbbd9c7bc1b876e7bfc630dea0560382..0000000000000000000000000000000000000000
--- a/docs/examples/rust/Cargo.toml
+++ /dev/null
@@ -1,2 +0,0 @@
-[workspace]
-members = ["restexample", "nativeexample"]
diff --git a/docs/zh/01-index.md b/docs/zh/01-index.md
index 64a7d419e1cdf9a0e2617ad65c07be5c29fb7b62..f9127121f35c8cdb9d28e121c20b9b7bb9101625 100644
--- a/docs/zh/01-index.md
+++ b/docs/zh/01-index.md
@@ -4,22 +4,22 @@ sidebar_label: 文档首页
slug: /
---
-TDengine是一款[开源](https://www.taosdata.com/tdengine/open_source_time-series_database)、[高性能](https://www.taosdata.com/fast)、[云原生](https://www.taosdata.com/tdengine/cloud_native_time-series_database)的时序数据库(Time-Series Database, TSDB), 它专为物联网、工业互联网、金融等场景优化设计。同时它还带有内建的缓存、流式计算、数据订阅等系统功能,能大幅减少系统设计的复杂度,降低研发和运营成本,是一极简的时序数据处理平台。本文档是 TDengine 用户手册,主要是介绍 TDengine 的基本概念、安装、使用、功能、开发接口、运营维护、TDengine 内核设计等等,它主要是面向架构师、开发者与系统管理员的。
+TDengine 是一款[开源](https://www.taosdata.com/tdengine/open_source_time-series_database)、[高性能](https://www.taosdata.com/fast)、[云原生](https://www.taosdata.com/tdengine/cloud_native_time-series_database)的时序数据库(Time Series Database, TSDB), 它专为物联网、车联网、工业互联网、金融、IT 运维等场景优化设计。同时它还带有内建的缓存、流式计算、数据订阅等系统功能,能大幅减少系统设计的复杂度,降低研发和运营成本,是一款极简的时序数据处理平台。本文档是 TDengine 的用户手册,主要是介绍 TDengine 的基本概念、安装、使用、功能、开发接口、运营维护、TDengine 内核设计等等,它主要是面向架构师、开发工程师与系统管理员的。
-TDengine 充分利用了时序数据的特点,提出了“一个数据采集点一张表”与“超级表”的概念,设计了创新的存储引擎,让数据的写入、查询和存储效率都得到极大的提升。为正确理解并使用TDengine, 无论如何,请您仔细阅读[基本概念](./concept)一章。
+TDengine 充分利用了时序数据的特点,提出了“一个数据采集点一张表”与“超级表”的概念,设计了创新的存储引擎,让数据的写入、查询和存储效率都得到极大的提升。为正确理解并使用 TDengine,无论如何,请您仔细阅读[基本概念](./concept)一章。
-如果你是开发者,请一定仔细阅读[开发指南](./develop)一章,该部分对数据库连接、建模、插入数据、查询、流式计算、缓存、数据订阅、用户自定义函数等功能都做了详细介绍,并配有各种编程语言的示例代码。大部分情况下,你只要把示例代码拷贝粘贴,针对自己的应用稍作改动,就能跑起来。
+如果你是开发工程师,请一定仔细阅读[开发指南](./develop)一章,该部分对数据库连接、建模、插入数据、查询、流式计算、缓存、数据订阅、用户自定义函数等功能都做了详细介绍,并配有各种编程语言的示例代码。大部分情况下,你只要复制粘贴示例代码,针对自己的应用稍作改动,就能跑起来。
-我们已经生活在大数据的时代,纵向扩展已经无法满足日益增长的业务需求,任何系统都必须具有水平扩展的能力,集群成为大数据以及 database 系统的不可缺失功能。TDengine 团队不仅实现了集群功能,而且将这一重要核心功能开源。怎么部署、管理和维护 TDengine 集群,请参考[部署集群](./deployment)一章。
+我们已经生活在大数据时代,纵向扩展已经无法满足日益增长的业务需求,任何系统都必须具有水平扩展的能力,集群成为大数据以及 Database 系统的不可缺失功能。TDengine 团队不仅实现了集群功能,而且将这一重要核心功能开源。怎么部署、管理和维护 TDengine 集群,请仔细参考[部署集群](./deployment)一章。
-TDengine 采用 SQL 作为其查询语言,大大降低学习成本、降低迁移成本,但同时针对时序数据场景,又做了一些扩展,以支持插值、降采样、时间加权平均等操作。[SQL 手册](./taos-sql)一章详细描述了 SQL 语法、详细列出了各种支持的命令和函数。
+TDengine 采用 SQL 作为查询语言,大大降低学习成本、降低迁移成本,但同时针对时序数据场景,又做了一些扩展,以支持插值、降采样、时间加权平均等操作。[SQL 手册](./taos-sql)一章详细描述了 SQL 语法、详细列出了各种支持的命令和函数。
-如果你是系统管理员,关心安装、升级、容错灾备、关心数据导入、导出,配置参数,怎么监测 TDengine 是否健康运行,怎么提升系统运行的性能,那么请仔细参考[运维指南](./operation)一章。
+如果你是系统管理员,关心安装、升级、容错灾备、关心数据导入、导出、配置参数,如何监测 TDengine 是否健康运行,如何提升系统运行的性能,请仔细参考[运维指南](./operation)一章。
-如果你对 TDengine 外围工具,REST API, 各种编程语言的连接器想做更多详细了解,请看[参考指南](./reference)一章。
+如果你对 TDengine 的外围工具、REST API、各种编程语言的连接器(Connector)想做更多详细了解,请看[参考指南](./reference)一章。
-如果你对 TDengine 内部的架构设计很有兴趣,欢迎仔细阅读[技术内幕](./tdinternal)一章,里面对集群的设计、数据分区、分片、写入、读出、查询、聚合查询的流程都做了详细的介绍。如果你想研读 TDengine 代码甚至贡献代码,请一定仔细读完这一章。
+如果你对 TDengine 的内部架构设计很有兴趣,欢迎仔细阅读[技术内幕](./tdinternal)一章,里面对集群的设计、数据分区、分片、写入、读出、查询、聚合查询的流程都做了详细的介绍。如果你想研读 TDengine 代码甚至贡献代码,请一定仔细读完这一章。
-最后,作为一个开源软件,欢迎大家的参与。如果发现文档的任何错误,描述不清晰的地方,都请在每个页面的最下方,点击“编辑本文档“直接进行修改。
+最后,作为一个开源软件,欢迎大家的参与。如果发现文档有任何错误、描述不清晰的地方,请在每个页面的最下方,点击“编辑本文档”直接进行修改。
Together, we make a difference!
diff --git a/docs/zh/02-intro.md b/docs/zh/02-intro.md
index 97322c68a2cf40205e388f4f135192f8e0b1b095..012c49d2c3c82d5865eb2d8e76f37bb0f0f69e8b 100644
--- a/docs/zh/02-intro.md
+++ b/docs/zh/02-intro.md
@@ -1,74 +1,98 @@
---
title: 产品简介
+description: 简要介绍 TDengine 的主要功能
toc_max_heading_level: 2
---
-TDengine 是一款[开源](https://www.taosdata.com/tdengine/open_source_time-series_database)、[高性能](https://www.taosdata.com/tdengine/fast)、[云原生](https://www.taosdata.com/tdengine/cloud_native_time-series_database)的时序数据库 (Time-Series Database, TSDB)。TDengine 能被广泛运用于物联网、工业互联网、车联网、IT 运维、金融等领域。除核心的时序数据库功能外,TDengine 还提供[缓存](../develop/cache/)、[数据订阅](../develop/tmq)、[流式计算](../develop/stream)等功能,是一极简的时序数据处理平台,最大程度的减小系统设计的复杂度,降低研发和运营成本。
+TDengine 是一款开源、高性能、云原生的[时序数据库](https://tdengine.com/tsdb/),且针对物联网、车联网、工业互联网、金融、IT 运维等场景进行了优化。TDengine 的代码,包括集群功能,都在 GNU AGPL v3.0 下开源。除核心的时序数据库功能外,TDengine 还提供[缓存](../develop/cache/)、[数据订阅](../develop/tmq)、[流式计算](../develop/stream)等其它功能以降低系统复杂度及研发和运维成本。
-本章节介绍TDengine的主要功能、竞争优势、适用场景、与其他数据库的对比测试等等,让大家对TDengine有个整体的了解。
+本章节介绍 TDengine 的主要功能、竞争优势、适用场景、与其他数据库的对比测试等等,让大家对 TDengine 有个整体的了解。
## 主要功能
-TDengine的主要功能如下:
-
-1. 高速数据写入,除 [SQL 写入](../develop/insert-data/sql-writing)外,还支持 [Schemaless 写入](../reference/schemaless/),支持 [InfluxDB LINE 协议](../develop/insert-data/influxdb-line),[OpenTSDB Telnet](../develop/insert-data/opentsdb-telnet), [OpenTSDB JSON ](../develop/insert-data/opentsdb-json)等协议写入;
-2. 第三方数据采集工具 [Telegraf](../third-party/telegraf),[Prometheus](../third-party/prometheus),[StatsD](../third-party/statsd),[collectd](../third-party/collectd),[icinga2](../third-party/icinga2), [TCollector](../third-party/tcollector), [EMQ](../third-party/emq-broker), [HiveMQ](../third-party/hive-mq-broker) 等都可以进行配置后,不用任何代码,即可将数据写入;
-3. 支持[各种查询](../develop/query-data),包括聚合查询、嵌套查询、降采样查询、插值等
-4. 支持[用户自定义函数](../develop/udf)
-5. 支持[缓存](../develop/cache),将每张表的最后一条记录缓存起来,这样无需 Redis
-6. 支持[流式计算](../develop/stream)(Stream Processing)
-7. 支持[数据订阅](../develop/tmq),而且可以指定过滤条件
-8. 支持[集群](../deployment/),可以通过多节点进行水平扩展,并通过多副本实现高可靠
-9. 提供[命令行程序](../reference/taos-shell),便于管理集群,检查系统状态,做即席查询
-10. 提供多种数据的[导入](../operation/import)、[导出](../operation/export)
-11. 支持对[TDengine 集群本身的监控](../operation/monitor)
-12. 提供 [C/C++](../reference/connector/cpp), [Java](../reference/connector/java), [Python](../reference/connector/python), [Go](../reference/connector/go), [Rust](../reference/connector/rust), [Node.js](../reference/connector/node) 等多种编程语言的[连接器](../reference/connector/)
-13. 支持 [REST 接口](../reference/rest-api/)
-14. 支持与[ Grafana 无缝集成](../third-party/grafana)
-15. 支持与 Google Data Studio 无缝集成
-16. 支持 [Kubernetes 部署](../deployment/k8s)
-
-更多细小的功能,请阅读整个文档。
+TDengine 的主要功能如下:
+
+1. 写入数据,支持
+ - [SQL 写入](../develop/insert-data/sql-writing)
+ - [无模式(Schemaless)写入](../reference/schemaless/),支持多种标准写入协议
+ - [InfluxDB Line 协议](../develop/insert-data/influxdb-line)
+ - [OpenTSDB Telnet 协议](../develop/insert-data/opentsdb-telnet)
+ - [OpenTSDB JSON 协议](../develop/insert-data/opentsdb-json)
+ - 与多种第三方工具的无缝集成,它们都可以仅通过配置而无需任何代码即可将数据写入 TDengine
+ - [Telegraf](../third-party/telegraf)
+ - [Prometheus](../third-party/prometheus)
+ - [StatsD](../third-party/statsd)
+ - [collectd](../third-party/collectd)
+ - [Icinga2](../third-party/icinga2)
+ - [TCollector](../third-party/tcollector)
+ - [EMQX](../third-party/emq-broker)
+ - [HiveMQ](../third-party/hive-mq-broker) ;
+2. 查询数据,支持
+ - [标准 SQL](../taos-sql),含嵌套查询
+ - [时序数据特色函数](../taos-sql/function/#time-series-extensions)
+ - [时序数据特色查询](../taos-sql/distinguished),例如降采样、插值、累加和、时间加权平均、状态窗口、会话窗口等
+ - [用户自定义函数(UDF)](../taos-sql/udf)
+3. [缓存](../develop/cache),将每张表的最后一条记录缓存起来,这样无需 Redis 就能对时序数据进行高效处理
+4. [流式计算(Stream Processing)](../develop/stream),TDengine 不仅支持连续查询,还支持事件驱动的流式计算,这样在处理时序数据时就无需 Flink 或 Spark 这样流式计算组件
+5. [数据订阅](../develop/tmq),应用程序可以订阅一张表或一组表的数据,提供与 Kafka 相同的 API,而且可以指定过滤条件
+6. 可视化
+ - 支持与 [Grafana](../third-party/grafana/) 的无缝集成
+ - 支持与 Google Data Studio 的无缝集成
+7. 集群
+ - [集群部署](../deployment/),可以通过增加节点进行水平扩展以提升处理能力
+ - 可以通过 [Kubernetes 部署 TDengine](../deployment/k8s/)
+ - 通过多副本提供高可用能力
+8. 管理
+ - [监控](../operation/monitor)运行中的 TDengine 实例
+ - 多种[数据导入](../operation/import)方式
+ - 多种[数据导出](../operation/export)方式
+9. 工具
+ - 提供[交互式命令行程序(CLI)](../reference/taos-shell),便于管理集群,检查系统状态,做即席查询
+ - 提供压力测试工具[taosBenchmark](../reference/taosbenchmark),用于测试 TDengine 的性能
+10. 编程
+ - 提供各种语言的[连接器(Connector)](../connector): 如 [C/C++](../connector/cpp)、[Java](../connector/java)、[Go](../connector/go)、[Node.js](../connector/node)、[Rust](../connector/rust)、[Python](../connector/python)、[C#](../connector/csharp) 等
+ - 支持 [REST 接口](../connector/rest-api/)
+
+更多细节功能,请阅读整个文档。
## 竞争优势
-由于 TDengine 充分利用了[时序数据特点](https://www.taosdata.com/blog/2019/07/09/105.html),比如结构化、无需事务、很少删除或更新、写多读少等等,设计了全新的针对时序数据的存储引擎和计算引擎,因此与其他时序数据库相比,TDengine 有以下特点:
+由于 TDengine 充分利用了[时序数据特点](https://www.taosdata.com/blog/2019/07/09/105.html),比如结构化、无需事务、很少删除或更新、写多读少等等,因此与其他时序数据库相比,TDengine 有以下特点:
-- **[高性能](https://www.taosdata.com/tdengine/fast)**:通过创新的存储引擎设计,无论是数据写入还是查询,TDengine 的性能比通用数据库快 10 倍以上,也远超其他时序数据库,存储空间不及通用数据库的1/10。
+- **[高性能](https://www.taosdata.com/tdengine/fast)**:TDengine 是唯一一个解决了时序数据存储的高基数难题的时序数据库,支持上亿数据采集点,并在数据插入、查询和数据压缩上远胜其它时序数据库。
-- **[云原生](https://www.taosdata.com/tdengine/cloud_native_time-series_database)**:通过原生分布式的设计,充分利用云平台的优势,TDengine 提供了水平扩展能力,具备弹性、韧性和可观测性,支持k8s部署,可运行在公有云、私有云和混合云上。
+- **[极简时序数据平台](https://www.taosdata.com/tdengine/simplified_solution_for_time-series_data_processing)**:TDengine 内建缓存、流式计算和数据订阅等功能,为时序数据的处理提供了极简的解决方案,从而大幅降低了业务系统的设计复杂度和运维成本。
-- **[极简时序数据平台](https://www.taosdata.com/tdengine/simplified_solution_for_time-series_data_processing)**:TDengine 内建消息队列、缓存、流式计算等功能,应用无需再集成 Kafka/Redis/HBase/Spark 等软件,大幅降低系统的复杂度,降低应用开发和运营成本。
+- **[云原生](https://www.taosdata.com/tdengine/cloud_native_time-series_database)**:通过原生的分布式设计、数据分片和分区、存算分离、RAFT 协议、Kubernetes 部署和完整的可观测性,TDengine 是一款云原生时序数据库并且能够部署在公有云、私有云和混合云上。
-- **[分析能力](https://www.taosdata.com/tdengine/easy_data_analytics)**:支持 SQL,同时为时序数据特有的分析提供SQL扩展。通过超级表、存储计算分离、分区分片、预计算、自定义函数等技术,TDengine 具备强大的分析能力。
+- **[简单易用](https://www.taosdata.com/tdengine/ease_of_use)**:对系统管理员来说,TDengine 大幅降低了管理和维护的代价。对开发者来说, TDengine 提供了简单的接口、极简的解决方案和与第三方工具的无缝集成。对数据分析专家来说,TDengine 提供了便捷的数据访问能力。
-- **[简单易用](https://www.taosdata.com/tdengine/ease_of_use)**:无任何依赖,安装、集群几秒搞定;提供REST以及各种语言连接器,与众多第三方工具无缝集成;提供命令行程序,便于管理和即席查询;提供各种运维工具。
+- **[分析能力](https://www.taosdata.com/tdengine/easy_data_analytics)**:通过超级表、存储计算分离、分区分片、预计算和其它技术,TDengine 能够高效地浏览、格式化和访问数据。
-- **[核心开源](https://www.taosdata.com/tdengine/open_source_time-series_database)**:TDengine 的核心代码包括集群功能全部开源,截止到2022年8月1日,全球超过 135.9k 个运行实例,GitHub Star 18.7k,Fork 4.4k,社区活跃。
+- **[核心开源](https://www.taosdata.com/tdengine/open_source_time-series_database)**:TDengine 的核心代码包括集群功能全部在开源协议下公开。全球超过 140k 个运行实例,GitHub Star 19k,且拥有一个活跃的开发者社区。
采用 TDengine,可将典型的物联网、车联网、工业互联网大数据平台的总拥有成本大幅降低。表现在几个方面:
-1. 由于其超强性能,它能将系统需要的计算资源和存储资源大幅降低
+1. 由于其超强性能,它能将系统所需的计算资源和存储资源大幅降低
2. 因为支持 SQL,能与众多第三方软件无缝集成,学习迁移成本大幅下降
-3. 因为是一极简的时序数据平台,系统复杂度、研发和运营成本大幅降低
-4. 因为维护简单,运营维护成本能大幅降低
+3. 因为是一款极简的时序数据平台,系统复杂度、研发和运营成本大幅降低
## 技术生态
-在整个时序大数据平台中,TDengine 在其中扮演的角色如下:
+在整个时序大数据平台中,TDengine 扮演的角色如下:

+