diff --git a/Jenkinsfile2 b/Jenkinsfile2 index 0177c57538..bb7fa70c57 100644 --- a/Jenkinsfile2 +++ b/Jenkinsfile2 @@ -313,7 +313,8 @@ def pre_test_build_win() { bat ''' cd %WIN_CONNECTOR_ROOT% python.exe -m pip install --upgrade pip - python -m pip install . + python -m pip uninstall taospy -y + python -m pip install taospy==2.7.6 xcopy /e/y/i/f %WIN_INTERNAL_ROOT%\\debug\\build\\lib\\taos.dll C:\\Windows\\System32 ''' return 1 @@ -331,8 +332,6 @@ def run_win_test() { bat ''' echo "windows test ..." cd %WIN_CONNECTOR_ROOT% - python.exe -m pip install --upgrade pip - python -m pip install . xcopy /e/y/i/f %WIN_INTERNAL_ROOT%\\debug\\build\\lib\\taos.dll C:\\Windows\\System32 ls -l C:\\Windows\\System32\\taos.dll time /t diff --git a/cmake/taostools_CMakeLists.txt.in b/cmake/taostools_CMakeLists.txt.in index 10677f0208..736ab0b095 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 41d4f95 + GIT_TAG d9ec91d SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools" BINARY_DIR "" #BUILD_IN_SOURCE TRUE diff --git a/docs/en/12-taos-sql/07-tag-index.md b/docs/en/12-taos-sql/07-tag-index.md new file mode 100644 index 0000000000..cb2a61d3e8 --- /dev/null +++ b/docs/en/12-taos-sql/07-tag-index.md @@ -0,0 +1,51 @@ +--- +sidebar_label: Tag Index +title: Tag Index +description: Use Tag Index to Improve Query Performance +--- + +## Introduction + +Prior to TDengine 3.0.3.0 (excluded),only one index is created by default on the first tag of each super talbe, but it's not allowed to dynamically create index on any other tags. From version 3.0.30, you can dynamically create index on any tag of any type. The index created automatically by TDengine is still valid. Query performance can benefit from indexes if you use properly. + +## Syntax + +1. The syntax of creating an index + +```sql +CREATE INDEX index_name ON tbl_name (tagColName) +``` + +In the above statement, `index_name` if the name of the index, `tbl_name` is the name of the super table,`tagColName` is the name of the tag on which the index is being created. `tagColName` can be any type supported by TDengine. + +2. The syntax of drop an index + +```sql +DROP INDEX index_name +``` + +In the above statement, `index_name` is the name of an existing index. If the index doesn't exist, the command would fail but doesn't generate any impact to the system. + +3. The syntax of show indexes in the system + +```sql +SELECT * FROM information_schema.INS_INDEXES +``` + +You can also add filter conditions to limit the results. + +## Detailed Specification + +1. Indexes can improve query performance significantly if they are used properly. The operators supported by tag index include `=`, `>`, `>=`, `<`, `<=`. If you use these operators with tags, indexes can improve query performance significantly. However, for operators not in this scope, indexes don't help. More and more operators will be added in future. + +2. Only one index can be created on each tag, error would be reported if you try to create more than one indexes on same tag. + +3. Each time you can create an index on a single tag, you are not allowed to create indexes on multiple tags together. + +4. The name of each index must be unique across the whole system, regardless of the type of the index, e.g. tag index or sma index. + +5. There is no limit on the number of indexes, but each index may add some burden on the metadata subsystem. So too many indexes may decrease the efficiency of reading or writing metadata and then decrease the system performance. So it's better not to add unnecessary indexes. + +6. You can' create index on a normal table or a child table. + +7. If the unique values of a tag column are too few, it's better not to create index on such tag columns, the benefit would be very small. \ No newline at end of file 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 6c66b85719..1691b8be8b 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 @@ -297,7 +297,6 @@ Response body: ```json { - "status": "succ", "code": 0, "desc": "/KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04" } 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 index 04b149a4b9..8678f65231 100644 --- 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 @@ -36,28 +36,17 @@ public class DataBaseMonitor { 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"); + public long count() throws SQLException { + try (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"); + public long getTableCount() throws SQLException { + try (ResultSet result = stmt.executeQuery("select count(*) from information_schema.ins_tables where db_name = 'test';")) { result.next(); - return result.getLong(5); + return result.getLong(1); } - return null; } } \ 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 index c2989acdbe..dc820f161c 100644 --- 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 @@ -42,7 +42,7 @@ public class SQLWriter { /** * Maximum SQL length. */ - private int maxSQLLength; + private int maxSQLLength = 800_000; /** * Map from table name to column values. For example: @@ -81,14 +81,6 @@ public class SQLWriter { 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); - } - } } /** @@ -149,7 +141,7 @@ public class SQLWriter { } catch (SQLException e) { // convert to error code defined in taoserror.h int errorCode = e.getErrorCode() & 0xffff; - if (errorCode == 0x362 || errorCode == 0x218) { + if (errorCode == 0x2603) { // Table does not exist createTables(); executeSQL(sql); diff --git a/docs/zh/08-connector/02-rest-api.mdx b/docs/zh/08-connector/02-rest-api.mdx index 68b12b9f23..a081595bca 100644 --- a/docs/zh/08-connector/02-rest-api.mdx +++ b/docs/zh/08-connector/02-rest-api.mdx @@ -298,7 +298,6 @@ curl http://192.168.0.1:6041/rest/login/root/taosdata ```json { - "status": "succ", "code": 0, "desc": "/KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04" } diff --git a/docs/zh/12-taos-sql/07-tag-index.md b/docs/zh/12-taos-sql/07-tag-index.md new file mode 100644 index 0000000000..ae16b0b2ec --- /dev/null +++ b/docs/zh/12-taos-sql/07-tag-index.md @@ -0,0 +1,51 @@ +--- +sidebar_label: 标签索引 +title: 标签索引 +description: 使用标签索引提升查询性能 +--- + +## 简介 + +在 TDengine 3.0.3.0 版本之前(不含),默认在第一列 TAG 上建立索引,但不支持给其它列动态添加索引。从 3.0.3.0 版本开始,可以动态地为其它 TAG 列添加索引。对于第一个 TAG 列上自动建立的索引,其在查询中默认生效,且用户无法对其进行任何干预。适当地使用索引能够有效地提升查询性能。 + +## 语法 + +创建索引的语法如下 + +```sql +CREATE INDEX index_name ON tbl_name (tagColName) +``` + +其中 `index_name` 为索引名称, `tbl_name` 为超级表名称,`tagColName` 为要在其上建立索引的 tag 列的名称。`tagColName` 的类型不受限制,即任何类型的 tag 列都可以建立索引。 + +删除索引的语法如下 + +```sql +DROP INDEX index_name +``` + +其中 `index_name` 为已经建立的某个索引的名称,如果该索引不存在则该命令执行失败,但不会对系统产生任何其它影响。 + +查看系统中已经存在的索引 + +```sql +SELECT * FROM information_schema.INS_INDEXES +``` + +也可以为上面的查询语句加上过滤条件以缩小查询范围。 + +## 使用说明 + +1. 索引使用得当能够提升数据过滤的效率,目前支持的过滤算子有 `=`, `>`, `>=`, `<`, `<=`。如果查询过滤条件中使用了这些算子,则索引能够明显提升查询效率。但如果查询过滤条件中使用的是其它算子,则索引起不到作用,查询效率没有变化。未来会逐步添加更多的算子。 + +2. 针对一个 tag 列只能建立一个索引,如果重复创建索引则会报错。 + +3. 每次只能针对一个 tag 列建立一个索引,不能同时对多个 tag 建立索引。 + +4. 整个系统中不管是哪种类型的索引,其名称必须唯一。 + +5. 对索引个数没有限制,但每增加一个索引都会导致系统中的元数据增加,过多的索引会降低元数据存取的效率从而降低整个系统的性能。所以请尽量避免添加不必要的索引。 + +6. 不支持对普通和子表建立索引。 + +7. 如果某个 tag 列的唯一值较少时,不建议对其建立索引,这种情况下收效甚微。 \ No newline at end of file diff --git a/docs/zh/12-taos-sql/26-udf.md b/docs/zh/12-taos-sql/26-udf.md index cb349109a7..7697944f9a 100644 --- a/docs/zh/12-taos-sql/26-udf.md +++ b/docs/zh/12-taos-sql/26-udf.md @@ -41,7 +41,7 @@ CREATE AGGREGATE FUNCTION function_name AS library_path OUTPUTTYPE output_type [ ```sql CREATE AGGREGATE FUNCTION l2norm AS "/home/taos/udf_example/libl2norm.so" OUTPUTTYPE DOUBLE bufsize 8; ``` -关于如何开发自定义函数,请参考 [UDF使用说明](../../develop/udf)。 +关于如何开发自定义函数,请参考 [UDF使用说明](/develop/udf)。 ## 管理 UDF diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/auto_create_table_json.py b/tests/develop-test/5-taos-tools/taosbenchmark/auto_create_table_json.py index a6167158a2..9da678bf81 100644 --- a/tests/develop-test/5-taos-tools/taosbenchmark/auto_create_table_json.py +++ b/tests/develop-test/5-taos-tools/taosbenchmark/auto_create_table_json.py @@ -108,49 +108,49 @@ class TDTestCase: tdLog.info("%s" % cmd) os.system("%s" % cmd) tdSql.execute("reset query cache") - tdSql.query("select count(*) from (select distinct(tbname) from db.stb2)") + tdSql.query("select count(*) from (select distinct(tbname) from stmt_db.stb2)") tdSql.checkData(0, 0, 8) - tdSql.query("select count(*) from db.stb2") + tdSql.query("select count(*) from stmt_db.stb2") tdSql.checkData(0, 0, 160) - tdSql.query("select * from information_schema.ins_databases") - tdSql.checkData(2, 14, "us") + tdSql.query("select * from information_schema.ins_databases where name='stmt_db'") + tdSql.checkData(0, 14, "us") tdSql.execute("reset query cache") - tdSql.query("select count(*) from (select distinct(tbname) from db.`stb2-2`)") + tdSql.query("select count(*) from (select distinct(tbname) from stmt_db.`stb2-2`)") tdSql.checkData(0, 0, 8) - tdSql.query("select count(*) from db.`stb2-2`") + tdSql.query("select count(*) from stmt_db.`stb2-2`") tdSql.checkData(0, 0, 160) cmd = "%s -f ./5-taos-tools/taosbenchmark/json/rest_auto_create_table.json" %binPath tdLog.info("%s" % cmd) os.system("%s" % cmd) tdSql.execute("reset query cache") - tdSql.query("select count(*) from (select distinct(tbname) from db.stb3)") + tdSql.query("select count(*) from (select distinct(tbname) from rest_db.stb3)") tdSql.checkData(0, 0, 8) - tdSql.query("select count(*) from db.stb3") + tdSql.query("select count(*) from rest_db.stb3") tdSql.checkData(0, 0, 160) - tdSql.query("select * from information_schema.ins_databases") - tdSql.checkData(2, 14, "ns") + tdSql.query("select * from information_schema.ins_databases where name='rest_db'") + tdSql.checkData(0, 14, "ns") tdSql.execute("reset query cache") - tdSql.query("select count(*) from (select distinct(tbname) from db.`stb3-2`)") + tdSql.query("select count(*) from (select distinct(tbname) from rest_db.`stb3-2`)") tdSql.checkData(0, 0, 8) - tdSql.query("select count(*) from db.`stb3-2`") + tdSql.query("select count(*) from rest_db.`stb3-2`") tdSql.checkData(0, 0, 160) cmd = "%s -f ./5-taos-tools/taosbenchmark/json/sml_auto_create_table.json" %binPath tdLog.info("%s" % cmd) os.system("%s" % cmd) tdSql.execute("reset query cache") - tdSql.query("select count(*) from (select distinct(tbname) from db.stb4)") + tdSql.query("select count(*) from (select distinct(tbname) from sml_db.stb4)") tdSql.checkData(0, 0, 8) - tdSql.query("select count(*) from db.stb4") + tdSql.query("select count(*) from sml_db.stb4") tdSql.checkData(0, 0, 160) tdSql.execute("reset query cache") - tdSql.query("select count(*) from (select distinct(tbname) from db.`stb4-2`)") + tdSql.query("select count(*) from (select distinct(tbname) from sml_db.`stb4-2`)") tdSql.checkData(0, 0, 8) - tdSql.query("select count(*) from db.`stb4-2`") + tdSql.query("select count(*) from sml_db.`stb4-2`") tdSql.checkData(0, 0, 160) tAdapter.stop() diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/json/rest_auto_create_table.json b/tests/develop-test/5-taos-tools/taosbenchmark/json/rest_auto_create_table.json index 868ff99842..9b99521f52 100644 --- a/tests/develop-test/5-taos-tools/taosbenchmark/json/rest_auto_create_table.json +++ b/tests/develop-test/5-taos-tools/taosbenchmark/json/rest_auto_create_table.json @@ -15,7 +15,7 @@ "num_of_records_per_req": 10, "databases": [{ "dbinfo": { - "name": "db", + "name": "rest_db", "drop": "yes", "replica": 1, "precision": "ns", diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_auto_create_table.json b/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_auto_create_table.json index 1bbeca672b..7b87919a6d 100644 --- a/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_auto_create_table.json +++ b/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_auto_create_table.json @@ -15,7 +15,7 @@ "num_of_records_per_req": 10, "databases": [{ "dbinfo": { - "name": "db", + "name": "sml_db", "drop": "yes", "replica": 1, "precision": "ms", diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/json/stmt_auto_create_table.json b/tests/develop-test/5-taos-tools/taosbenchmark/json/stmt_auto_create_table.json index e6e773f616..baf0384e46 100644 --- a/tests/develop-test/5-taos-tools/taosbenchmark/json/stmt_auto_create_table.json +++ b/tests/develop-test/5-taos-tools/taosbenchmark/json/stmt_auto_create_table.json @@ -15,7 +15,7 @@ "num_of_records_per_req": 10, "databases": [{ "dbinfo": { - "name": "db", + "name": "stmt_db", "drop": "yes", "replica": 1, "precision": "us", diff --git a/tests/parallel_test/run_case.sh b/tests/parallel_test/run_case.sh index e0b905375a..95115bc437 100755 --- a/tests/parallel_test/run_case.sh +++ b/tests/parallel_test/run_case.sh @@ -69,6 +69,12 @@ ulimit -c unlimited md5sum /usr/lib/libtaos.so.1 md5sum /home/TDinternal/debug/build/lib/libtaos.so + +#define taospy 2.7.6 +pip3 list|grep taospy +pip3 uninstall taospy -y +pip3 install taospy==2.7.6 + $TIMEOUT_CMD $cmd RET=$? echo "cmd exit code: $RET" diff --git a/tests/parallel_test/run_container.sh b/tests/parallel_test/run_container.sh index b5deb09341..8ea2f249c1 100755 --- a/tests/parallel_test/run_container.sh +++ b/tests/parallel_test/run_container.sh @@ -130,8 +130,6 @@ docker run \ -v ${SOURCEDIR}:/usr/local/src/ \ -v "$TMP_DIR/thread_volume/$thread_no/sim:${SIM_DIR}" \ -v ${TMP_DIR}/thread_volume/$thread_no/coredump:$coredump_dir \ - -v $WORKDIR/taos-connector-python/taos:/usr/local/lib/python3.8/site-packages/taos:ro \ - -v $WORKDIR/taos-connector-python/taosrest:/usr/local/lib/python3.8/site-packages/taosrest:ro \ --rm --ulimit core=-1 taos_test:v1.0 $CONTAINER_TESTDIR/tests/parallel_test/run_case.sh -d "$exec_dir" -c "$cmd" $extra_param ret=$? exit $ret