github.com/whtcorpsinc/MilevaDB-Prod@v0.0.0-20211104133533-f57f4be3b597/causetstore/stochastikctx/variable/milevadb_vars.go (about) 1 // Copyright 2020 WHTCORPS INC, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // See the License for the specific language governing permissions and 12 // limitations under the License. 13 14 package variable 15 16 import ( 17 "math" 18 "os" 19 20 "github.com/whtcorpsinc/BerolinaSQL/allegrosql" 21 "github.com/uber-go/atomic" 22 ) 23 24 /* 25 Steps to add a new MilevaDB specific system variable: 26 27 1. Add a new variable name with comment in this file. 28 2. Add the default value of the new variable in this file. 29 3. Add SysVar instance in 'defaultSysVars' slice with the default value. 30 4. Add a field in `StochastikVars`. 31 5. UFIDelate the `NewStochastikVars` function to set the field to its default value. 32 6. UFIDelate the `variable.SetStochastikSystemVar` function to use the new value when SET memex is executed. 33 7. If it is a global variable, add it in `stochastik.loadCommonGlobalVarsALLEGROSQL`. 34 8. UFIDelate ValidateSetSystemVar if the variable's value need to be validated. 35 9. Use this variable to control the behavior in code. 36 */ 37 38 // MilevaDB system variable names that only in stochastik scope. 39 const ( 40 MilevaDBDBSSlowOprThreshold = "dbs_slow_threshold" 41 42 // milevadb_snapshot is used for reading history data, the default value is empty string. 43 // The value can be a datetime string like '2020-11-11 20:20:20' or a tso string. When this variable is set, the stochastik reads history data of that time. 44 MilevaDBSnapshot = "milevadb_snapshot" 45 46 // milevadb_opt_agg_push_down is used to enable/disable the optimizer rule of aggregation push down. 47 MilevaDBOptAggPushDown = "milevadb_opt_agg_push_down" 48 49 MilevaDBOptBCJ = "milevadb_opt_broadcast_join" 50 // milevadb_opt_distinct_agg_push_down is used to decide whether agg with distinct should be pushed to einsteindb/tiflash. 51 MilevaDBOptDistinctAggPushDown = "milevadb_opt_distinct_agg_push_down" 52 53 // milevadb_opt_write_row_id is used to enable/disable the operations of insert、replace and uFIDelate to _milevadb_rowid. 54 MilevaDBOptWriteRowID = "milevadb_opt_write_row_id" 55 56 // Auto analyze will run if (causet modify count)/(causet event count) is greater than this value. 57 MilevaDBAutoAnalyzeRatio = "milevadb_auto_analyze_ratio" 58 59 // Auto analyze will run if current time is within start time and end time. 60 MilevaDBAutoAnalyzeStartTime = "milevadb_auto_analyze_start_time" 61 MilevaDBAutoAnalyzeEndTime = "milevadb_auto_analyze_end_time" 62 63 // milevadb_checksum_block_concurrency is used to speed up the ADMIN CHECKSUM TABLE 64 // memex, when a causet has multiple indices, those indices can be 65 // scanned concurrently, with the cost of higher system performance impact. 66 MilevaDBChecksumBlockConcurrency = "milevadb_checksum_block_concurrency" 67 68 // MilevaDBCurrentTS is used to get the current transaction timestamp. 69 // It is read-only. 70 MilevaDBCurrentTS = "milevadb_current_ts" 71 72 // MilevaDBLastTxnInfo is used to get the last transaction info within the current stochastik. 73 MilevaDBLastTxnInfo = "milevadb_last_txn_info" 74 75 // milevadb_config is a read-only variable that shows the config of the current server. 76 MilevaDBConfig = "milevadb_config" 77 78 // milevadb_batch_insert is used to enable/disable auto-split insert data. If set this option on, insert interlock will automatically 79 // insert data into multiple batches and use a single txn for each batch. This will be helpful when inserting large data. 80 MilevaDBBatchInsert = "milevadb_batch_insert" 81 82 // milevadb_batch_delete is used to enable/disable auto-split delete data. If set this option on, delete interlock will automatically 83 // split data into multiple batches and use a single txn for each batch. This will be helpful when deleting large data. 84 MilevaDBBatchDelete = "milevadb_batch_delete" 85 86 // milevadb_batch_commit is used to enable/disable auto-split the transaction. 87 // If set this option on, the transaction will be committed when it reaches stmt-count-limit and starts a new transaction. 88 MilevaDBBatchCommit = "milevadb_batch_commit" 89 90 // milevadb_dml_batch_size is used to split the insert/delete data into small batches. 91 // It only takes effort when milevadb_batch_insert/milevadb_batch_delete is on. 92 // Its default value is 20000. When the event size is large, 20k rows could be larger than 100MB. 93 // User could change it to a smaller one to avoid breaking the transaction size limitation. 94 MilevaDBDMLBatchSize = "milevadb_dml_batch_size" 95 96 // The following stochastik variables controls the memory quota during query execution. 97 // "milevadb_mem_quota_query": control the memory quota of a query. 98 MilevaDBMemQuotaQuery = "milevadb_mem_quota_query" // Bytes. 99 MilevaDBNestedLoopJoinCacheCapacity = "milevadb_nested_loop_join_cache_capacity" 100 // TODO: remove them below sometime, it should have only one Quota(MilevaDBMemQuotaQuery). 101 MilevaDBMemQuotaHashJoin = "milevadb_mem_quota_hashjoin" // Bytes. 102 MilevaDBMemQuotaMergeJoin = "milevadb_mem_quota_mergejoin" // Bytes. 103 MilevaDBMemQuotaSort = "milevadb_mem_quota_sort" // Bytes. 104 MilevaDBMemQuotaTopn = "milevadb_mem_quota_topn" // Bytes. 105 MilevaDBMemQuotaIndexLookupReader = "milevadb_mem_quota_indexlookupreader" // Bytes. 106 MilevaDBMemQuotaIndexLookupJoin = "milevadb_mem_quota_indexlookupjoin" // Bytes. 107 MilevaDBMemQuotaNestedLoopApply = "milevadb_mem_quota_nestedloopapply" // Bytes. 108 109 // milevadb_general_log is used to log every query in the server in info level. 110 MilevaDBGeneralLog = "milevadb_general_log" 111 112 // milevadb_pprof_sql_cpu is used to add label allegrosql label to pprof result. 113 MilevaDBPProfALLEGROSQLCPU = "milevadb_pprof_sql_cpu" 114 115 // milevadb_retry_limit is the maximum number of retries when committing a transaction. 116 MilevaDBRetryLimit = "milevadb_retry_limit" 117 118 // milevadb_disable_txn_auto_retry disables transaction auto retry. 119 MilevaDBDisableTxnAutoRetry = "milevadb_disable_txn_auto_retry" 120 121 // milevadb_enable_streaming enables MilevaDB to use streaming API for interlock requests. 122 MilevaDBEnableStreaming = "milevadb_enable_streaming" 123 124 // milevadb_enable_chunk_rpc enables MilevaDB to use Chunk format for interlock requests. 125 MilevaDBEnableChunkRPC = "milevadb_enable_chunk_rpc" 126 127 // milevadb_optimizer_selectivity_level is used to control the selectivity estimation level. 128 MilevaDBOptimizerSelectivityLevel = "milevadb_optimizer_selectivity_level" 129 130 // milevadb_txn_mode is used to control the transaction behavior. 131 MilevaDBTxnMode = "milevadb_txn_mode" 132 133 // milevadb_row_format_version is used to control milevadb event format version current. 134 MilevaDBRowFormatVersion = "milevadb_row_format_version" 135 136 // milevadb_enable_block_partition is used to control causet partition feature. 137 // The valid value include auto/on/off: 138 // on or auto: enable causet partition if the partition type is implemented. 139 // off: always disable causet partition. 140 MilevaDBEnableBlockPartition = "milevadb_enable_block_partition" 141 142 // milevadb_skip_isolation_level_check is used to control whether to return error when set unsupported transaction 143 // isolation level. 144 MilevaDBSkipIsolationLevelCheck = "milevadb_skip_isolation_level_check" 145 146 // MilevaDBLowResolutionTSO is used for reading data with low resolution TSO which is uFIDelated once every two seconds 147 MilevaDBLowResolutionTSO = "milevadb_low_resolution_tso" 148 149 // MilevaDBReplicaRead is used for reading data from replicas, followers for example. 150 MilevaDBReplicaRead = "milevadb_replica_read" 151 152 // MilevaDBAllowRemoveAutoInc indicates whether a user can drop the auto_increment defCausumn attribute or not. 153 MilevaDBAllowRemoveAutoInc = "milevadb_allow_remove_auto_inc" 154 155 // MilevaDBEvolveCausetTaskMaxTime controls the max time of a single evolution task. 156 MilevaDBEvolveCausetTaskMaxTime = "milevadb_evolve_plan_task_max_time" 157 158 // MilevaDBEvolveCausetTaskStartTime is the start time of evolution task. 159 MilevaDBEvolveCausetTaskStartTime = "milevadb_evolve_plan_task_start_time" 160 // MilevaDBEvolveCausetTaskEndTime is the end time of evolution task. 161 MilevaDBEvolveCausetTaskEndTime = "milevadb_evolve_plan_task_end_time" 162 163 // milevadb_slow_log_threshold is used to set the slow log threshold in the server. 164 MilevaDBSlowLogThreshold = "milevadb_slow_log_threshold" 165 166 // milevadb_record_plan_in_slow_log is used to log the plan of the slow query. 167 MilevaDBRecordCausetInSlowLog = "milevadb_record_plan_in_slow_log" 168 169 // milevadb_enable_slow_log enables MilevaDB to log slow queries. 170 MilevaDBEnableSlowLog = "milevadb_enable_slow_log" 171 172 // milevadb_query_log_max_len is used to set the max length of the query in the log. 173 MilevaDBQueryLogMaxLen = "milevadb_query_log_max_len" 174 175 // MilevaDBCheckMb4ValueInUTF8 is used to control whether to enable the check wrong utf8 value. 176 MilevaDBCheckMb4ValueInUTF8 = "milevadb_check_mb4_value_in_utf8" 177 178 // MilevaDBFoundInCausetCache indicates whether the last memex was found in plan cache 179 MilevaDBFoundInCausetCache = "last_plan_from_cache" 180 181 // MilevaDBAllowAutoRandExplicitInsert indicates whether explicit insertion on auto_random defCausumn is allowed. 182 MilevaDBAllowAutoRandExplicitInsert = "allow_auto_random_explicit_insert" 183 ) 184 185 // MilevaDB system variable names that both in stochastik and global scope. 186 const ( 187 // milevadb_build_stats_concurrency is used to speed up the ANALYZE memex, when a causet has multiple indices, 188 // those indices can be scanned concurrently, with the cost of higher system performance impact. 189 MilevaDBBuildStatsConcurrency = "milevadb_build_stats_concurrency" 190 191 // milevadb_allegrosql_scan_concurrency is used to set the concurrency of a allegrosql scan task. 192 // A allegrosql scan task can be a causet scan or a index scan, which may be distributed to many EinsteinDB nodes. 193 // Higher concurrency may reduce latency, but with the cost of higher memory usage and system performance impact. 194 // If the query has a LIMIT clause, high concurrency makes the system do much more work than needed. 195 // milevadb_allegrosql_scan_concurrency is deprecated, use milevadb_interlock_concurrency instead. 196 MilevaDBDistALLEGROSQLScanConcurrency = "milevadb_allegrosql_scan_concurrency" 197 198 // milevadb_opt_insubquery_to_join_and_agg is used to enable/disable the optimizer rule of rewriting IN subquery. 199 MilevaDBOptInSubqToJoinAnPosetDagg = "milevadb_opt_insubq_to_join_and_agg" 200 201 // milevadb_opt_correlation_threshold is a guard to enable event count estimation using defCausumn order correlation. 202 MilevaDBOptCorrelationThreshold = "milevadb_opt_correlation_threshold" 203 204 // milevadb_opt_correlation_exp_factor is an exponential factor to control heuristic approach when milevadb_opt_correlation_threshold is not satisfied. 205 MilevaDBOptCorrelationExpFactor = "milevadb_opt_correlation_exp_factor" 206 207 // milevadb_opt_cpu_factor is the CPU cost of processing one memex for one event. 208 MilevaDBOptCPUFactor = "milevadb_opt_cpu_factor" 209 // milevadb_opt_copcpu_factor is the CPU cost of processing one memex for one event in interlock. 210 MilevaDBOptCopCPUFactor = "milevadb_opt_copcpu_factor" 211 // milevadb_opt_tiflash_concurrency_factor is concurrency number of tiflash computation. 212 MilevaDBOptTiFlashConcurrencyFactor = "milevadb_opt_tiflash_concurrency_factor" 213 // milevadb_opt_network_factor is the network cost of transferring 1 byte data. 214 MilevaDBOptNetworkFactor = "milevadb_opt_network_factor" 215 // milevadb_opt_scan_factor is the IO cost of scanning 1 byte data on EinsteinDB. 216 MilevaDBOptScanFactor = "milevadb_opt_scan_factor" 217 // milevadb_opt_desc_factor is the IO cost of scanning 1 byte data on EinsteinDB in desc order. 218 MilevaDBOptDescScanFactor = "milevadb_opt_desc_factor" 219 // milevadb_opt_seek_factor is the IO cost of seeking the start value in a range on EinsteinDB or TiFlash. 220 MilevaDBOptSeekFactor = "milevadb_opt_seek_factor" 221 // milevadb_opt_memory_factor is the memory cost of storing one tuple. 222 MilevaDBOptMemoryFactor = "milevadb_opt_memory_factor" 223 // milevadb_opt_disk_factor is the IO cost of reading/writing one byte to temporary disk. 224 MilevaDBOptDiskFactor = "milevadb_opt_disk_factor" 225 // milevadb_opt_concurrency_factor is the CPU cost of additional one goroutine. 226 MilevaDBOptConcurrencyFactor = "milevadb_opt_concurrency_factor" 227 228 // milevadb_index_join_batch_size is used to set the batch size of a index lookup join. 229 // The index lookup join fetches batches of data from outer interlock and constructs ranges for inner interlock. 230 // This value controls how much of data in a batch to do the index join. 231 // Large value may reduce the latency but consumes more system resource. 232 MilevaDBIndexJoinBatchSize = "milevadb_index_join_batch_size" 233 234 // milevadb_index_lookup_size is used for index lookup interlock. 235 // The index lookup interlock first scan a batch of handles from a index, then use those handles to lookup the causet 236 // rows, this value controls how much of handles in a batch to do a lookup task. 237 // Small value sends more RPCs to EinsteinDB, consume more system resource. 238 // Large value may do more work than needed if the query has a limit. 239 MilevaDBIndexLookupSize = "milevadb_index_lookup_size" 240 241 // milevadb_index_lookup_concurrency is used for index lookup interlock. 242 // A lookup task may have 'milevadb_index_lookup_size' of handles at maximun, the handles may be distributed 243 // in many EinsteinDB nodes, we executes multiple concurrent index lookup tasks concurrently to reduce the time 244 // waiting for a task to finish. 245 // Set this value higher may reduce the latency but consumes more system resource. 246 // milevadb_index_lookup_concurrency is deprecated, use milevadb_interlock_concurrency instead. 247 MilevaDBIndexLookupConcurrency = "milevadb_index_lookup_concurrency" 248 249 // milevadb_index_lookup_join_concurrency is used for index lookup join interlock. 250 // IndexLookUpJoin starts "milevadb_index_lookup_join_concurrency" inner workers 251 // to fetch inner rows and join the matched (outer, inner) event pairs. 252 // milevadb_index_lookup_join_concurrency is deprecated, use milevadb_interlock_concurrency instead. 253 MilevaDBIndexLookupJoinConcurrency = "milevadb_index_lookup_join_concurrency" 254 255 // milevadb_index_serial_scan_concurrency is used for controlling the concurrency of index scan operation 256 // when we need to keep the data output order the same as the order of index data. 257 MilevaDBIndexSerialScanConcurrency = "milevadb_index_serial_scan_concurrency" 258 259 // MilevaDBMaxChunkSize is used to control the max chunk size during query execution. 260 MilevaDBMaxChunkSize = "milevadb_max_chunk_size" 261 262 // MilevaDBAllowBatchCop means if we should send batch interlock to TiFlash. It can be set to 0, 1 and 2. 263 // 0 means never use batch cop, 1 means use batch cop in case of aggregation and join, 2, means to force to send batch cop for any query. 264 // The default value is 0 265 MilevaDBAllowBatchCop = "milevadb_allow_batch_cop" 266 267 // MilevaDBInitChunkSize is used to control the init chunk size during query execution. 268 MilevaDBInitChunkSize = "milevadb_init_chunk_size" 269 270 // milevadb_enable_cascades_causet is used to control whether to enable the cascades causet. 271 MilevaDBEnableCascadesCausetAppend = "milevadb_enable_cascades_causet" 272 273 // milevadb_skip_utf8_check skips the UTF8 validate process, validate UTF8 has performance cost, if we can make sure 274 // the input string values are valid, we can skip the check. 275 MilevaDBSkipUTF8Check = "milevadb_skip_utf8_check" 276 277 // milevadb_skip_ascii_check skips the ASCII validate process 278 // old milevadb may already have fields with invalid ASCII bytes 279 // disable ASCII validate can guarantee a safe replication 280 MilevaDBSkipASCIICheck = "milevadb_skip_ascii_check" 281 282 // milevadb_hash_join_concurrency is used for hash join interlock. 283 // The hash join outer interlock starts multiple concurrent join workers to probe the hash causet. 284 // milevadb_hash_join_concurrency is deprecated, use milevadb_interlock_concurrency instead. 285 MilevaDBHashJoinConcurrency = "milevadb_hash_join_concurrency" 286 287 // milevadb_projection_concurrency is used for projection operator. 288 // This variable controls the worker number of projection operator. 289 // milevadb_projection_concurrency is deprecated, use milevadb_interlock_concurrency instead. 290 MilevaDBProjectionConcurrency = "milevadb_projection_concurrency" 291 292 // milevadb_hashagg_partial_concurrency is used for hash agg interlock. 293 // The hash agg interlock starts multiple concurrent partial workers to do partial aggregate works. 294 // milevadb_hashagg_partial_concurrency is deprecated, use milevadb_interlock_concurrency instead. 295 MilevaDBHashAggPartialConcurrency = "milevadb_hashagg_partial_concurrency" 296 297 // milevadb_hashagg_final_concurrency is used for hash agg interlock. 298 // The hash agg interlock starts multiple concurrent final workers to do final aggregate works. 299 // milevadb_hashagg_final_concurrency is deprecated, use milevadb_interlock_concurrency instead. 300 MilevaDBHashAggFinalConcurrency = "milevadb_hashagg_final_concurrency" 301 302 // milevadb_window_concurrency is used for window parallel interlock. 303 // milevadb_window_concurrency is deprecated, use milevadb_interlock_concurrency instead. 304 MilevaDBWindowConcurrency = "milevadb_window_concurrency" 305 306 // milevadb_enable_parallel_apply is used for parallel apply. 307 MilevaDBEnableParallelApply = "milevadb_enable_parallel_apply" 308 309 // milevadb_backoff_lock_fast is used for einsteindb backoff base time in milliseconds. 310 MilevaDBBackoffLockFast = "milevadb_backoff_lock_fast" 311 312 // milevadb_backoff_weight is used to control the max back off time in MilevaDB. 313 // The default maximum back off time is a small value. 314 // BackOffWeight could multiply it to let the user adjust the maximum time for retrying. 315 // Only positive integers can be accepted, which means that the maximum back off time can only grow. 316 MilevaDBBackOffWeight = "milevadb_backoff_weight" 317 318 // milevadb_dbs_reorg_worker_cnt defines the count of dbs reorg workers. 319 MilevaDBDBSReorgWorkerCount = "milevadb_dbs_reorg_worker_cnt" 320 321 // milevadb_dbs_reorg_batch_size defines the transaction batch size of dbs reorg workers. 322 MilevaDBDBSReorgBatchSize = "milevadb_dbs_reorg_batch_size" 323 324 // milevadb_dbs_error_count_limit defines the count of dbs error limit. 325 MilevaDBDBSErrorCountLimit = "milevadb_dbs_error_count_limit" 326 327 // milevadb_dbs_reorg_priority defines the operations priority of adding indices. 328 // It can be: PRIORITY_LOW, PRIORITY_NORMAL, PRIORITY_HIGH 329 MilevaDBDBSReorgPriority = "milevadb_dbs_reorg_priority" 330 331 // MilevaDBEnableChangeDeferredCausetType is used to control whether to enable the change defCausumn type. 332 MilevaDBEnableChangeDeferredCausetType = "milevadb_enable_change_defCausumn_type" 333 334 // milevadb_max_delta_schema_count defines the max length of deltaSchemaInfos. 335 // deltaSchemaInfos is a queue that maintains the history of schemaReplicant changes. 336 MilevaDBMaxDeltaSchemaCount = "milevadb_max_delta_schema_count" 337 338 // milevadb_scatter_region will scatter the regions for DBSs when it is ON. 339 MilevaDBScatterRegion = "milevadb_scatter_region" 340 341 // MilevaDBWaitSplitRegionFinish defines the split region behaviour is sync or async. 342 MilevaDBWaitSplitRegionFinish = "milevadb_wait_split_region_finish" 343 344 // MilevaDBWaitSplitRegionTimeout uses to set the split and scatter region back off time. 345 MilevaDBWaitSplitRegionTimeout = "milevadb_wait_split_region_timeout" 346 347 // milevadb_force_priority defines the operations priority of all memexs. 348 // It can be "NO_PRIORITY", "LOW_PRIORITY", "HIGH_PRIORITY", "DELAYED" 349 MilevaDBForcePriority = "milevadb_force_priority" 350 351 // milevadb_enable_radix_join indicates to use radix hash join algorithm to execute 352 // HashJoin. 353 MilevaDBEnableRadixJoin = "milevadb_enable_radix_join" 354 355 // milevadb_constraint_check_in_place indicates to check the constraint when the ALLEGROALLEGROSQL executing. 356 // It could hurt the performance of bulking insert when it is ON. 357 MilevaDBConstraintCheckInPlace = "milevadb_constraint_check_in_place" 358 359 // milevadb_enable_window_function is used to control whether to enable the window function. 360 MilevaDBEnableWindowFunction = "milevadb_enable_window_function" 361 362 // milevadb_enable_vectorized_memex is used to control whether to enable the vectorized memex evaluation. 363 MilevaDBEnableVectorizedExpression = "milevadb_enable_vectorized_memex" 364 365 // MilevaDBOptJoinReorderThreshold defines the threshold less than which 366 // we'll choose a rather time consuming algorithm to calculate the join order. 367 MilevaDBOptJoinReorderThreshold = "milevadb_opt_join_reorder_threshold" 368 369 // SlowQueryFile indicates which slow query log file for SLOW_QUERY causet to parse. 370 MilevaDBSlowQueryFile = "milevadb_slow_query_file" 371 372 // MilevaDBEnableFastAnalyze indicates to use fast analyze. 373 MilevaDBEnableFastAnalyze = "milevadb_enable_fast_analyze" 374 375 // MilevaDBExpensiveQueryTimeThreshold indicates the time threshold of expensive query. 376 MilevaDBExpensiveQueryTimeThreshold = "milevadb_expensive_query_time_threshold" 377 378 // MilevaDBEnableIndexMerge indicates to generate IndexMergePath. 379 MilevaDBEnableIndexMerge = "milevadb_enable_index_merge" 380 381 // MilevaDBEnableNoopFuncs set true will enable using fake funcs(like get_lock release_lock) 382 MilevaDBEnableNoopFuncs = "milevadb_enable_noop_functions" 383 384 // MilevaDBEnableStmtSummary indicates whether the memex summary is enabled. 385 MilevaDBEnableStmtSummary = "milevadb_enable_stmt_summary" 386 387 // MilevaDBStmtSummaryInternalQuery indicates whether the memex summary contain internal query. 388 MilevaDBStmtSummaryInternalQuery = "milevadb_stmt_summary_internal_query" 389 390 // MilevaDBStmtSummaryRefreshInterval indicates the refresh interval in seconds for each memex summary. 391 MilevaDBStmtSummaryRefreshInterval = "milevadb_stmt_summary_refresh_interval" 392 393 // MilevaDBStmtSummaryHistorySize indicates the history size of each memex summary. 394 MilevaDBStmtSummaryHistorySize = "milevadb_stmt_summary_history_size" 395 396 // MilevaDBStmtSummaryMaxStmtCount indicates the max number of memexs kept in memory. 397 MilevaDBStmtSummaryMaxStmtCount = "milevadb_stmt_summary_max_stmt_count" 398 399 // MilevaDBStmtSummaryMaxALLEGROSQLLength indicates the max length of displayed normalized allegrosql and sample allegrosql. 400 MilevaDBStmtSummaryMaxALLEGROSQLLength = "milevadb_stmt_summary_max_sql_length" 401 402 // MilevaDBCaptureCausetBaseline indicates whether the capture of plan baselines is enabled. 403 MilevaDBCaptureCausetBaseline = "milevadb_capture_plan_baselines" 404 405 // MilevaDBUseCausetBaselines indicates whether the use of plan baselines is enabled. 406 MilevaDBUseCausetBaselines = "milevadb_use_plan_baselines" 407 408 // MilevaDBEvolveCausetBaselines indicates whether the evolution of plan baselines is enabled. 409 MilevaDBEvolveCausetBaselines = "milevadb_evolve_plan_baselines" 410 411 // MilevaDBIsolationReadEngines indicates the milevadb only read from the stores whose engine type is involved in IsolationReadEngines. 412 // Now, only support EinsteinDB and TiFlash. 413 MilevaDBIsolationReadEngines = "milevadb_isolation_read_engines" 414 415 // MilevaDBStoreLimit indicates the limit of sending request to a causetstore, 0 means without limit. 416 MilevaDBStoreLimit = "milevadb_store_limit" 417 418 // MilevaDBMetricSchemaStep indicates the step when query metric schemaReplicant. 419 MilevaDBMetricSchemaStep = "milevadb_metric_query_step" 420 421 // MilevaDBMetricSchemaRangeDuration indicates the range duration when query metric schemaReplicant. 422 MilevaDBMetricSchemaRangeDuration = "milevadb_metric_query_range_duration" 423 424 // MilevaDBEnableDefCauslectInterDircutionInfo indicates that whether execution info is defCauslected. 425 MilevaDBEnableDefCauslectInterDircutionInfo = "milevadb_enable_defCauslect_execution_info" 426 427 // DefInterlockingDirectorateConcurrency is used for controlling the concurrency of all types of interlocks. 428 MilevaDBInterlockingDirectorateConcurrency = "milevadb_interlock_concurrency" 429 430 // MilevaDBEnableClusteredIndex indicates if clustered index feature is enabled. 431 MilevaDBEnableClusteredIndex = "milevadb_enable_clustered_index" 432 433 // MilevaDBPartitionPruneMode indicates the partition prune mode used. 434 MilevaDBPartitionPruneMode = "milevadb_partition_prune_mode" 435 436 // MilevaDBSlowLogMasking indicates that whether masking the query data when log slow query. 437 // Deprecated: use MilevaDBRedactLog instead. 438 MilevaDBSlowLogMasking = "milevadb_slow_log_masking" 439 440 // MilevaDBRedactLog indicates that whether redact log. 441 MilevaDBRedactLog = "milevadb_redact_log" 442 443 // MilevaDBShardAllocateStep indicates the max size of continuous rowid shard in one transaction. 444 MilevaDBShardAllocateStep = "milevadb_shard_allocate_step" 445 // MilevaDBEnableTelemetry indicates that whether usage data report to WHTCORPS INC is enabled. 446 MilevaDBEnableTelemetry = "milevadb_enable_telemetry" 447 448 // MilevaDBEnableAmendPessimisticTxn indicates if amend pessimistic transactions is enabled. 449 MilevaDBEnableAmendPessimisticTxn = "milevadb_enable_amend_pessimistic_txn" 450 ) 451 452 // Default MilevaDB system variable values. 453 const ( 454 DefHostname = "localhost" 455 DefIndexLookupConcurrency = ConcurrencyUnset 456 DefIndexLookupJoinConcurrency = ConcurrencyUnset 457 DefIndexSerialScanConcurrency = 1 458 DefIndexJoinBatchSize = 25000 459 DefIndexLookupSize = 20000 460 DefDistALLEGROSQLScanConcurrency = 15 461 DefBuildStatsConcurrency = 4 462 DefAutoAnalyzeRatio = 0.5 463 DefAutoAnalyzeStartTime = "00:00 +0000" 464 DefAutoAnalyzeEndTime = "23:59 +0000" 465 DefAutoIncrementIncrement = 1 466 DefAutoIncrementOffset = 1 467 DefChecksumBlockConcurrency = 4 468 DefSkipUTF8Check = false 469 DefSkipASCIICheck = false 470 DefOptAggPushDown = false 471 DefOptBCJ = false 472 DefOptWriteRowID = false 473 DefOptCorrelationThreshold = 0.9 474 DefOptCorrelationExpFactor = 1 475 DefOptCPUFactor = 3.0 476 DefOptCopCPUFactor = 3.0 477 DefOptTiFlashConcurrencyFactor = 24.0 478 DefOptNetworkFactor = 1.0 479 DefOptScanFactor = 1.5 480 DefOptDescScanFactor = 3.0 481 DefOptSeekFactor = 20.0 482 DefOptMemoryFactor = 0.001 483 DefOptDiskFactor = 1.5 484 DefOptConcurrencyFactor = 3.0 485 DefOptInSubqToJoinAnPosetDagg = true 486 DefBatchInsert = false 487 DefBatchDelete = false 488 DefBatchCommit = false 489 DefCurretTS = 0 490 DefInitChunkSize = 32 491 DefMaxChunkSize = 1024 492 DefDMLBatchSize = 0 493 DefMaxPreparedStmtCount = -1 494 DefWaitTimeout = 0 495 DefMilevaDBMemQuotaHashJoin = 32 << 30 // 32GB. 496 DefMilevaDBMemQuotaMergeJoin = 32 << 30 // 32GB. 497 DefMilevaDBMemQuotaSort = 32 << 30 // 32GB. 498 DefMilevaDBMemQuotaTopn = 32 << 30 // 32GB. 499 DefMilevaDBMemQuotaIndexLookupReader = 32 << 30 // 32GB. 500 DefMilevaDBMemQuotaIndexLookupJoin = 32 << 30 // 32GB. 501 DefMilevaDBMemQuotaNestedLoopApply = 32 << 30 // 32GB. 502 DefMilevaDBMemQuotaDistALLEGROSQL = 32 << 30 // 32GB. 503 DefMilevaDBGeneralLog = 0 504 DefMilevaDBPProfALLEGROSQLCPU = 0 505 DefMilevaDBRetryLimit = 10 506 DefMilevaDBDisableTxnAutoRetry = true 507 DefMilevaDBConstraintCheckInPlace = false 508 DefMilevaDBHashJoinConcurrency = ConcurrencyUnset 509 DefMilevaDBProjectionConcurrency = ConcurrencyUnset 510 DefMilevaDBOptimizerSelectivityLevel = 0 511 DefMilevaDBAllowBatchCop = 1 512 DefMilevaDBTxnMode = "" 513 DefMilevaDBRowFormatV1 = 1 514 DefMilevaDBRowFormatV2 = 2 515 DefMilevaDBDBSReorgWorkerCount = 4 516 DefMilevaDBDBSReorgBatchSize = 256 517 DefMilevaDBDBSErrorCountLimit = 512 518 DefMilevaDBMaxDeltaSchemaCount = 1024 519 DefMilevaDBChangeDeferredCausetType = false 520 DefMilevaDBHashAggPartialConcurrency = ConcurrencyUnset 521 DefMilevaDBHashAggFinalConcurrency = ConcurrencyUnset 522 DefMilevaDBWindowConcurrency = ConcurrencyUnset 523 DefMilevaDBForcePriority = allegrosql.NoPriority 524 DefMilevaDBUseRadixJoin = false 525 DefEnableWindowFunction = true 526 DefEnableVectorizedExpression = true 527 DefMilevaDBOptJoinReorderThreshold = 0 528 DefMilevaDBDBSSlowOprThreshold = 300 529 DefMilevaDBUseFastAnalyze = false 530 DefMilevaDBSkipIsolationLevelCheck = false 531 DefMilevaDBExpensiveQueryTimeThreshold = 60 // 60s 532 DefMilevaDBScatterRegion = false 533 DefMilevaDBWaitSplitRegionFinish = true 534 DefWaitSplitRegionTimeout = 300 // 300s 535 DefMilevaDBEnableNoopFuncs = false 536 DefMilevaDBAllowRemoveAutoInc = false 537 DefMilevaDBUseCausetBaselines = true 538 DefMilevaDBEvolveCausetBaselines = false 539 DefMilevaDBEvolveCausetTaskMaxTime = 600 // 600s 540 DefMilevaDBEvolveCausetTaskStartTime = "00:00 +0000" 541 DefMilevaDBEvolveCausetTaskEndTime = "23:59 +0000" 542 DefInnodbLockWaitTimeout = 50 // 50s 543 DefMilevaDBStoreLimit = 0 544 DefMilevaDBMetricSchemaStep = 60 // 60s 545 DefMilevaDBMetricSchemaRangeDuration = 60 // 60s 546 DefMilevaDBFoundInCausetCache = false 547 DefMilevaDBEnableDefCauslectInterDircutionInfo = true 548 DefMilevaDBAllowAutoRandExplicitInsert = false 549 DefMilevaDBEnableClusteredIndex = false 550 DefMilevaDBSlowLogMasking = false 551 DefMilevaDBShardAllocateStep = math.MaxInt64 552 DefMilevaDBEnableTelemetry = true 553 DefMilevaDBEnableParallelApply = false 554 DefMilevaDBEnableAmendPessimisticTxn = true 555 ) 556 557 // Process global variables. 558 var ( 559 ProcessGeneralLog uint32 560 EnablePProfALLEGROSQLCPU = atomic.NewBool(false) 561 dbsReorgWorkerCounter int32 = DefMilevaDBDBSReorgWorkerCount 562 maxDBSReorgWorkerCount int32 = 128 563 dbsReorgBatchSize int32 = DefMilevaDBDBSReorgBatchSize 564 dbsErrorCountlimit int64 = DefMilevaDBDBSErrorCountLimit 565 maxDeltaSchemaCount int64 = DefMilevaDBMaxDeltaSchemaCount 566 // Export for testing. 567 MaxDBSReorgBatchSize int32 = 10240 568 MinDBSReorgBatchSize int32 = 32 569 // DBSSlowOprThreshold is the threshold for dbs slow operations, uint is millisecond. 570 DBSSlowOprThreshold uint32 = DefMilevaDBDBSSlowOprThreshold 571 ForcePriority = int32(DefMilevaDBForcePriority) 572 ServerHostname, _ = os.Hostname() 573 MaxOfMaxAllowedPacket uint64 = 1073741824 574 ExpensiveQueryTimeThreshold uint64 = DefMilevaDBExpensiveQueryTimeThreshold 575 MinExpensiveQueryTimeThreshold uint64 = 10 //10s 576 CaptureCausetBaseline = serverGlobalVariable{globalVal: "0"} 577 DefInterlockingDirectorateConcurrency = 5 578 )