From 162575ea66a4fedadbbf225dc692c5fbff4bc5b5 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Wed, 30 Nov 2022 14:30:44 +0800 Subject: [PATCH] opti:get meta cost for schemaless & add config for write batch in schemaless --- include/common/tglobal.h | 1 + source/client/src/clientSml.c | 5 ++--- source/common/src/tglobal.c | 5 +++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/include/common/tglobal.h b/include/common/tglobal.h index 0ded2bc4b5..24ed898163 100644 --- a/include/common/tglobal.h +++ b/include/common/tglobal.h @@ -125,6 +125,7 @@ extern char tsUdfdLdLibPath[]; extern char tsSmlChildTableName[]; extern char tsSmlTagName[]; extern bool tsSmlDataFormat; +extern int32_t tsSmlBatchSize; // wal extern int64_t tsWalFsyncDataSizeLimit; diff --git a/source/client/src/clientSml.c b/source/client/src/clientSml.c index 985b758869..28e873cca3 100644 --- a/source/client/src/clientSml.c +++ b/source/client/src/clientSml.c @@ -79,7 +79,6 @@ #define NCHAR_ADD_LEN 3 // L"nchar" 3 means L" " #define MAX_RETRY_TIMES 5 -#define LINE_BATCH 2000 //================================================================================================= typedef TSDB_SML_PROTOCOL_TYPE SMLProtocolType; @@ -2563,7 +2562,7 @@ TAOS_RES *taos_schemaless_insert_inner(SRequestObj *request, char *lines[], char goto end; } - batchs = ceil(((double)numLines) / LINE_BATCH); + batchs = ceil(((double)numLines) / tsSmlBatchSize); params.total = batchs; for (int i = 0; i < batchs; ++i) { SRequestObj *req = (SRequestObj *)createRequest(pTscObj->id, TSDB_SQL_INSERT, 0); @@ -2582,7 +2581,7 @@ TAOS_RES *taos_schemaless_insert_inner(SRequestObj *request, char *lines[], char info->isRawLine = (rawLine == NULL); info->ttl = ttl; - int32_t perBatch = LINE_BATCH; + int32_t perBatch = tsSmlBatchSize; if (numLines > perBatch) { numLines -= perBatch; diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index aeef1b5277..d922b5342b 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -75,6 +75,7 @@ char tsSmlChildTableName[TSDB_TABLE_NAME_LEN] = ""; // user defined child table // If set to empty system will generate table name using MD5 hash. // true means that the name and order of cols in each line are the same(only for influx protocol) bool tsSmlDataFormat = false; +int32_t tsSmlBatchSize = 10000; // query int32_t tsQueryPolicy = 1; @@ -302,6 +303,7 @@ static int32_t taosAddClientCfg(SConfig *pCfg) { if (cfgAddString(pCfg, "smlChildTableName", "", 1) != 0) return -1; if (cfgAddString(pCfg, "smlTagName", tsSmlTagName, 1) != 0) return -1; if (cfgAddBool(pCfg, "smlDataFormat", tsSmlDataFormat, 1) != 0) return -1; + if (cfgAddInt32(pCfg, "smlBatchSize", tsSmlBatchSize, 1, INT32_MAX, true) != 0) return -1; if (cfgAddInt32(pCfg, "maxMemUsedByInsert", tsMaxMemUsedByInsert, 1, INT32_MAX, true) != 0) return -1; if (cfgAddInt32(pCfg, "rpcRetryLimit", tsRpcRetryLimit, 1, 100000, 0) != 0) return -1; if (cfgAddInt32(pCfg, "rpcRetryInterval", tsRpcRetryInterval, 1, 100000, 0) != 0) return -1; @@ -643,6 +645,7 @@ static int32_t taosSetClientCfg(SConfig *pCfg) { tstrncpy(tsSmlTagName, cfgGetItem(pCfg, "smlTagName")->str, TSDB_COL_NAME_LEN); tsSmlDataFormat = cfgGetItem(pCfg, "smlDataFormat")->bval; + tsSmlBatchSize = cfgGetItem(pCfg, "smlBatchSize")->i32; tsMaxMemUsedByInsert = cfgGetItem(pCfg, "maxMemUsedByInsert")->i32; tsShellActivityTimer = cfgGetItem(pCfg, "shellActivityTimer")->i32; @@ -1013,6 +1016,8 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) { tstrncpy(tsSmlTagName, cfgGetItem(pCfg, "smlTagName")->str, TSDB_COL_NAME_LEN); } else if (strcasecmp("smlDataFormat", name) == 0) { tsSmlDataFormat = cfgGetItem(pCfg, "smlDataFormat")->bval; + } else if (strcasecmp("smlBatchSize", name) == 0) { + tsSmlBatchSize = cfgGetItem(pCfg, "smlBatchSize")->i32; } else if (strcasecmp("shellActivityTimer", name) == 0) { tsShellActivityTimer = cfgGetItem(pCfg, "shellActivityTimer")->i32; } else if (strcasecmp("supportVnodes", name) == 0) { -- GitLab