Skip to content

Commit

Permalink
Merge docs special week branch to master (#3372)
Browse files Browse the repository at this point in the history
* *: udpate part of TOC and create new files

* *: add more topics

* �*: add more topics to toc and create files

* toc: add assignee to two topics

* *: add some issue topics

* *: add some troubleshoot topics

* *: add performance tuning topics

* *: add tutorial topics

* *: add more topics

* *: add more reference topics

* tidb-binlog: create binlogctl file

* perf-tuning:adjust the structure of the `SQL tuning` section (#3149)

* faq, toc: add faq and ui topics

* toc: update troubleshoot and sql tuning

* TOC: add database tools section (#3161)

* TOC: add database tools section

* fix ci

* relocate the section

* add assignees

* add /faq/licensing-faq.md

* modify assignees

* Update command line flags for pd configruation (#3153)

Signed-off-by: nolouch <nolouch@gmail.com>

Co-authored-by: Lilian Lee <lilin@pingcap.com>

* Remove tiflash section in old TOC (commented out) to prevent lint error (#3194)

* toc: remove topics that are commented out

* Remove upgrade-tiflash.md (#3164)

Duplicated with TiDB's upgrade manual.

Co-authored-by: ruoxi <zanmato1984@gmail.com>
Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>

* sql-statements: update "admin" related statements (#3175)

* add tiflash faq (#3167)

* add tiflash faq

* delete original tiflash faq

* fix ci

* address comment

* Revert "fix ci"

This reverts commit 73dff28.

Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>

* toc: remove inapplicable dm topics

* Remove two inapplicable files

* Add lightning faq (#3176)

* .github: add three github action workflows (#3213)

* .github: update workflow to auto assign project (#3229)

* update tikv configuration about pessimistic transaction (#3178)

* update tikv configuration about pessimistic transaction

Signed-off-by: youjiali1995 <zlwgx1023@gmail.com>

* Update tikv-configuration-file.md

Co-authored-by: TomShawn <41534398+TomShawn@users.noreply.github.com>

* Update tikv-configuration-file.md

Co-authored-by: toutdesuite <guizhiluo2014@163.com>

Co-authored-by: TomShawn <41534398+TomShawn@users.noreply.github.com>
Co-authored-by: toutdesuite <guizhiluo2014@163.com>

* Add TiFlash performance tuning to TOC (#3203)

* tuning: add tune-operating-system (#3157)

* tuning: add tune-operating-system

Signed-off-by: Wenbo Zhang <ethercflow@gmail.com>

* refine format and TOC

* Update tune-operating-system.md

Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>

* Update tune-operating-system.md

Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>

* Update tune-operating-system.md

Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>

* Update tune-operating-system.md

Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>

* Update tune-operating-system.md

Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>

* Update tune-operating-system.md

Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>

* Update tune-operating-system.md

Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>

* Update tune-operating-system.md

Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>

Co-authored-by: yikeke <yikeke@pingcap.com>
Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>
Co-authored-by: pingcap-github-bot <sre-bot@pingcap.com>

* add doc about tiflash command line flags (#3205)

* add doc about tiflash command line flags

* Small fix for format

* Try fix link

* Update tiflash/tiflash-command-line-flags.md

Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>
Co-authored-by: pingcap-github-bot <sre-bot@pingcap.com>

* split to DDL DML DQL DCL sections (#3215)

* Add files via upload

* update format

* Update basic-sql-operations.md

Co-authored-by: Ran <huangran@pingcap.com>

* Update command line flags for tikv configruation (#3155)

* update mysql-compatibility.md & add auto-increment.md (#3163)

* perf-tuning: Add document for column prune (#3190)

* *: Update documents and sqlgrams with "alter" prefixed statements (#3235)

* transaction-isolation-levels.md: update txn isolation (#3140)

* Update error-codes.md (#3160)

* Update tidb-specific-system-variables.md (#3159)

* reference: Optimize documents about GC (#3158)

* add troubleshooting-writeconflict (#3209)

* add troubleshooting-writeconflict

* fix syntax

* fix snytax again

* adjust

* fix format

* refine format and wording

Co-authored-by: yikeke <yikeke@pingcap.com>
Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>

* reference: update constraints.md (#3146)

* update literal-values.md (#3236)

* perf-tuning: Update the doc of query-execution-plan (#3201)

* Update configfile pd (#3238)

 *: update PD config file

Signed-off-by: nolouch <nolouch@gmail.com>

* reference: update the pd-ctl docs (#3305)

* update the pd-ctl docs

Signed-off-by: Ryan Leung <rleungx@gmail.com>

* perf-tuning: add document for predicate push down (#3181)

* toc: remove /tidb-index.md (#3258)

* perf-tuning: add docs for DISTINCT optimizations (#3214)

* *: update some statements (#3300)

* update transaction overview (#3165)

* update generate ssl doc (#3260)

* resources: update the Figma link (#3230)

* update generate ssl

Signed-off-by: TXXT <hunterlxt@live.com>

* update generate ssl

Signed-off-by: TXXT <hunterlxt@live.com>

* revert

Signed-off-by: TXXT <hunterlxt@live.com>

* Apply suggestions from code review

Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>

* safe point

Signed-off-by: TXXT <hunterlxt@live.com>

* fix format to pass ci

* update code block format

* address comments

Signed-off-by: TXXT <hunterlxt@live.com>

* Apply suggestions from code review

Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>

Co-authored-by: Caitin <34535727+CaitinChen@users.noreply.github.com>
Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>
Co-authored-by: yikeke <yikeke@pingcap.com>

* perf-tuning: add introduction for prepare plan cache (#3187)

* Fix sql-statement: use, update, truncate, trace (#3255)

* fix use

* fix pic

* fix pic

* update doc

* update doc

Co-authored-by: Lilian Lee <lilin@pingcap.com>

* update document of privilege management (#3202)

* update privilege document

* Apply suggestions from code review

Co-authored-by: Lilian Lee <lilin@pingcap.com>

Co-authored-by: kissmydb <likun@pingcap.com>
Co-authored-by: Lilian Lee <lilin@pingcap.com>
Co-authored-by: Jack Yu <yusp@pingcap.com>

* perf-tuning: add index-choose.md (#3173)

* Add documentations for TiUP (#3197)

* tiup: improve the TiUP related documents

Signed-off-by: Lonng <heng@lonng.org>

* add fag/troubleshoot documents

Signed-off-by: Lonng <heng@lonng.org>

* add TiUP to TOC.md

Signed-off-by: Lonng <heng@lonng.org>

* add aliases to redirect old links

* Apply suggestions from code review

Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>

* address comment

Signed-off-by: Lonng <heng@lonng.org>

* refine TOC and a filename

* fix ci

* Update tiup/tiup-cluster.md

Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>

* fix a dead link

* fix a link

* fix a link

* address comments

Signed-off-by: Lonng <heng@lonng.org>

Co-authored-by: yikeke <yikeke@pingcap.com>
Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>

* update the tidb configuration document (#3148)

* update configure file document

* update command line arguments doc

* update

* update

* update

* update

* update

* update

* update

* update

* update

* fix a typo in tiup doc

Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>
Co-authored-by: yikeke <yikeke@pingcap.com>

* update all the syntax png files (#3322)

* add shutdown statement (#3306)

* reference: update statement summary tables (#3145)

* Add Grafana monitoring content and update images (#3195)

* perf-tuning: add doc for wrong index solution page (#3302)

* add/update several sql statements docs (#3299)

* Add docs for rocksdb (#3198)

* add docs for rocksdb

Signed-off-by: Little-Wallace <bupt2013211450@gmail.com>

* update several sql statements (#3298)

 - sql-statements/sql-statement-set-names.md
 - sql-statements/sql-statement-show-columns-from.md
 - sql-statements/sql-statement-show-create-sequence.md

* add show config statement (#3308)

* add & update several sql statements (#3296)

* *: udpate `begin` and `commit` statements (#3301)

* perf-tuning: update docs for statistics (#3223)

* Update tispark doc (#3257)

* update some syntax diagram (#3312)

Signed-off-by: crazycs520 <crazycs520@gmail.com>

* update several statements (#3309)

* add document of `SHOW PLUGINS` (#3326)

* Add doc about next_row_id and profiles (#3316)

* update comment-syntax.md (#3193)

* update keywords-and-reserved-words.md (#3246)

* update document of tidb-ctl (#3189)

* update the doc of view (#3179)

* update functions-and-operator documents (#3318)

* update some syntax diagram (#3317)

* add syntax diagram for show stats_buckets (#3321)

* perf-tuning: add docs for subquery optimizations (#3191)

* perf-tuning: add docs for some overview pages for sql-tuning (#3170)

* perf-tuning: add docs for some overview pages

* Update query-execution-plan.md

* Apply suggestions from code review

Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>
Co-authored-by: Zhuomin(Charming) Liu <lzmhhh123@gmail.com>

* Update control-execution-plan.md

Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>

* Update sql-tuning-overview.md

* Update control-execution-plan.md

Co-authored-by: Zhang Jian <zjsariel@gmail.com>

Co-authored-by: TomShawn <41534398+TomShawn@users.noreply.github.com>
Co-authored-by: 苗青利 <51319517+miaoqingli@users.noreply.github.com>
Co-authored-by: Zhang Jian <zjsariel@gmail.com>
Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>
Co-authored-by: Zhuomin(Charming) Liu <lzmhhh123@gmail.com>
Co-authored-by: pingcap-github-bot <sre-bot@pingcap.com>

* update sql-statement-modify-column.md (#3323)

* add topology YAML template (#3279)

* add topology YAML template

* fix topology YAML template

* fix topology YAML template

* update topology YAML template

* sql-statements:add drop-stats.md (#3337)

* sql-statements: update create view and drop view (#3331)

* perf-tuning: add document for partition pruning (#3184)

* docs: add sql statement for load data (#3335)

* Create monitor-deploy.md and tidb-monitoring-api.md (#3196)

* Create monitor-deploy.md

deploy monitor

* Update TOC.md

add monitor deploy

* Update monitor-deploy.md

* Delete monitor-a-tidb-cluster.md

delete

* Update monitor-deploy.md

* Rename monitor-deploy.md to deploy-monitoring-services.md

* Update TOC.md

* add #3186 document

* add alias

* Update mysql-compatibility.md

* Update deploy-monitoring-services.md

* 整理监控报警相关 TOC

* Update deploy-monitoring-services.md

* Update tidb-monitoring-api.md

Co-authored-by: TomShawn <41534398+TomShawn@users.noreply.github.com>

* Update tidb-monitoring-api.md

Co-authored-by: TomShawn <41534398+TomShawn@users.noreply.github.com>
Co-authored-by: kissmydb <likun@pingcap.com>

* Update upgrade-tidb-using-tiup.md (#3212)

* Update upgrade-tidb-using-tiup.md

* Update upgrade-tidb-using-tiup.md

* Update upgrade-tidb-using-tiup.md

Co-authored-by: Lilian Lee <lilin@pingcap.com>

* Update upgrade-tidb-using-tiup.md

Co-authored-by: Lilian Lee <lilin@pingcap.com>

* Update upgrade-tidb-using-tiup.md

Co-authored-by: Lilian Lee <lilin@pingcap.com>

Co-authored-by: kissmydb <likun@pingcap.com>
Co-authored-by: Lilian Lee <lilin@pingcap.com>

* update several document related to privilege sql statement (#3310)

* update create user gramma

* update serveral statment doc

* refine punctuation

* Update sql-statements/sql-statement-grant-privileges.md

Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>

* Update sql-statements/sql-statement-revoke-privileges.md

Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>

Co-authored-by: yikeke <yikeke@pingcap.com>
Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>

* update optimistic transaction (#3171)

* *: update "change column" and some sqlgram (#3304)

* Update three-data-centers-in-two-cities-deployment.md (#3243)

* Add files via upload

* Update three-data-centers-in-two-cities-deployment.md

* fix ci and update format

* Update three-data-centers-in-two-cities-deployment.md

Co-authored-by: Ran <huangran@pingcap.com>

* Update post-installation-check.md (#3297)

* Multi-data-centers-in-one-city-deployment  (#3245)

* sql statements: add create binding, drop binding and show bindings (#3333)

* refine enable tls for client/components (#3325)

* fix hardware-and-software-requirements (#3228)

* update security-compatibility-with-mysql.md (#3311)

* Update scale-tidb-using-tiup.md and production-offline-deployment-using-tiup.md (#3208)

* update several statements (#3289)

* update pessimistic transaction (#3177)

* Add syntax gram of `show stats_meta` (#3338)

* update schema-object-names.md (#3242)

* add sql statement for show analyze status (#3329)

* Update the sql diagram of SHOW TABLES and SHOW INDEXES. (#3346)

* update syntax gram for `kill`, `prepare` and `show stats_healthy` (#3319)

* update expression-syntax.md (#3313)

* Update sql diagrams of show statements (#3277)

* Update the docs of `drop database` (#3332)

* update partition-table.md (#3216)

* update placement rules (#3169)

Signed-off-by: disksing <i@disksing.com>

* add troubleshoot-hot-spot-issues  (#3276)

* picture of troubleshoot-hot-spot-issues

* troubleshoot-hot-spot-issues v1

* Update troubleshoot-hot-spot-issues.md

Co-authored-by: kissmydb <likun@pingcap.com>

* Update troubleshoot-hot-spot-issues.md

* Update troubleshoot-hot-spot-issues.md

* Update troubleshoot-hot-spot-issues.md

* Update troubleshoot-hot-spot-issues.md

* a little fix

Co-authored-by: kissmydb <likun@pingcap.com>
Co-authored-by: pepezzzz <35323945+pepezzzz@users.noreply.github.com>

* Add troubleshooting CPU issues (#3282)

* Create troubleshooting-cpu.md

* Update troubleshoot-cpu-issues.md

* Delete troubleshooting-cpu.md

* Update troubleshoot-cpu-issues.md

Co-authored-by: TomShawn <41534398+TomShawn@users.noreply.github.com>

* Update troubleshoot-cpu-issues.md

Co-authored-by: TomShawn <41534398+TomShawn@users.noreply.github.com>

* Update troubleshoot-cpu-issues.md

* Update troubleshoot-cpu-issues.md

* Update troubleshoot-cpu-issues.md

* refine format

* Spoken language modified to written language

* Update troubleshoot-cpu-issues.md

Co-authored-by: TomShawn <41534398+TomShawn@users.noreply.github.com>
Co-authored-by: pepezzzz <35323945+pepezzzz@users.noreply.github.com>
Co-authored-by: kissmydb <likun@pingcap.com>
Co-authored-by: pingcap-github-bot <sre-bot@pingcap.com>

* Docs special week for troubleshoot-lock-conflicts (#3206)

* troubleshoot-lock-conflicts-pictures

add pictures for troubleshoot-lock-conflicts

* add file troubleshoot-lock-conflicts

add file troubleshoot-lock-conflicts

* Update SW troubleshoot-lock-conflicts

Update SW troubleshoot-lock-conflicts

* refine format and content

* Update SW troubleshoot-lock-conflicts

Update SW troubleshoot-lock-conflicts

* Update troubleshoot-lock-conflicts.md

Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>

* Update SW troubleshoot-lock-conflicts

Update SW troubleshoot-lock-conflicts

* Update the ci format for troubleshooting lock conflicts

Update the ci format for troubleshooting lock conflicts

* refine content

* fix indentation

* change category

Co-authored-by: yikeke <yikeke@pingcap.com>
Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>
Co-authored-by: kissmydb <likun@pingcap.com>

* *: update `analyze` statement (#3241)

`

* Move TiFlash troubleshoot part to a new document (#3192)

* update TiDB metrics (#3284)

* add experimental warning (#3330)

* tiny refine cert based authentication (#3328)

* add a dir for config-templates (#3349)

* sql-stmt: modify SelectStmt and add page for `SHOW STATS_HISTOGRAMS` (#3336)

* update tikv-ctl doc (#3254)

* TOC: remove unused pages (#3339)

* Update document for generated column (#3295)

* update the 'Overview' metrics doc for grafana dashboard (#3286)

* add deployment and operation FAQ (#3268)

* best-practice: update massive regions to match 4.0 (#3152)

* Update grafana-monitor-best-practices.md (#3288)

* tools: add data migration route (#3292)

* update user-defined-variables.md (#3271)

* perf-tuning: Add document for topn-limit-push-down (#3307)

* add minimal-deploy-topology.md (#3226)

* add sql statement about pump and drainer (#3324)

* add hybrid-deployment-topology.md (#3227)

* add ticdc-deploy-topology.md (#3281)

* add tiflash-deploy-topology.md (#3285)

* update user-account-management.md (#3211)

* update user-account-management.md

* fix lint?

* Apply suggestions from code review

Co-authored-by: Lilian Lee <lilin@pingcap.com>

* Apply suggestions from code review

* Update user-account-management.md

Co-authored-by: Jack Yu <yusp@pingcap.com>
Co-authored-by: Lilian Lee <lilin@pingcap.com>
Co-authored-by: pingcap-github-bot <sre-bot@pingcap.com>

* add doc for slow-queries in dashboard (#3274)

* add doc for slow-queries in dashboard

Signed-off-by: crazycs520 <crazycs520@gmail.com>

* address comment

Signed-off-by: crazycs520 <crazycs520@gmail.com>

* update format

* Apply suggestions from code review

Co-authored-by: Ran <huangran@pingcap.com>

* update relative paths

* Update list.md

* update alt text and punctuation

* change name and dir

* rename picture

Signed-off-by: crazycs520 <crazycs520@gmail.com>

Co-authored-by: Ran <huangran@pingcap.com>
Co-authored-by: Wenxuan <hi@breeswish.org>

* add check-before-deployment.md (#3225)

* add check-befor-deployment.md

* Update check-before-deployment.md

Co-authored-by: kissmydb <likun@pingcap.com>

* Update check-before-deployment.md

Co-authored-by: Ran <huangran@pingcap.com>

* Update check-before-deployment.md

Co-authored-by: Ran <huangran@pingcap.com>

* Update check-before-deployment.md

Co-authored-by: Ran <huangran@pingcap.com>

* Update check-before-deployment.md

Co-authored-by: Ran <huangran@pingcap.com>

* Update check-before-deployment.md

Co-authored-by: Ran <huangran@pingcap.com>

* Update check-before-deployment.md

* Update check-before-deployment.md

* Update check-before-deployment.md

* Update check-before-deployment.md

* Update check-before-deployment.md

Co-authored-by: Zhang Jian <zjsariel@gmail.com>

* Apply suggestions from code review

Co-authored-by: Lilian Lee <lilin@pingcap.com>

Co-authored-by: kissmydb <likun@pingcap.com>
Co-authored-by: Ran <huangran@pingcap.com>
Co-authored-by: Zhang Jian <zjsariel@gmail.com>
Co-authored-by: Lilian Lee <lilin@pingcap.com>

* Add daily-inspection.md (#3221)

* cdc: update cdc cli doc (#3141)

* add geographic-redundancy-deploy-topology.md (#3283)

* Add tikv overview (#3249)

* add tikv overview

Signed-off-by: Little-Wallace <bupt2013211450@gmail.com>

* add upgrade faq (#3267)

* add tidb-binlog-deploy-topology.md (#3280)

* update character-set-and-collation (#3256)

* update several sql statement docs (#3294)

* Add document of dumpling, the new export tool (#3151)

* Create configure-load-base-split.md (#3168)

* Create configure-load-base-split.md

* TiFlash: Modify scale doc structure (#3341)

Co-authored-by: Flowyi <flowbehappy@gmail.com>
Co-authored-by: kissmydb <likun@pingcap.com>
Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>
Co-authored-by: yikeke <yikeke@pingcap.com>

* update doc credits (#3248)

* update doc credits

Signed-off-by: shirly <AndreMouche@126.com>

* address comments

Signed-off-by: shirly <AndreMouche@126.com>

* Apply suggestions from code review

Co-authored-by: Lilian Lee <lilin@pingcap.com>

* Update credits.md

Co-authored-by: winkyao <golangwink@gmail.com>
Co-authored-by: Lilian Lee <lilin@pingcap.com>
Co-authored-by: pingcap-github-bot <sre-bot@pingcap.com>

* Add FAQ documents to BR (#3344)

* tools: update toc for binlog (#3347)

* update several 'CREATE' related statement: (#3293)

* Update grafana pd dashboard (#3343)

* add scheduling overview from tidb in action (#3180)

* Add some experimental features of br (#3143)

* br: add online restore, raw kv.

* br: warp line of some commands.

* br: fix a dead link.

* Update br/backup-and-restore-tool.md

Co-authored-by: kissmydb <likun@pingcap.com>

* Apply suggestions from code review

Co-authored-by: TomShawn <41534398+TomShawn@users.noreply.github.com>
Co-authored-by: WangXiangUSTC <wx347249478@gmail.com>

* Update backup-and-restore-tool.md

* refine format

* br: fix incremental backup time range.

* br: add a hint of where the backup stores

* br: add a hint of local storage

* Update backup-and-restore-tool.md

* Update br/backup-and-restore-tool.md

Co-authored-by: Neil Shen <overvenus@gmail.com>

* Update backup-and-restore-tool.md

* Update br/backup-and-restore-tool.md

Co-authored-by: TomShawn <41534398+TomShawn@users.noreply.github.com>

* Update backup-and-restore-tool.md

* Update br/backup-and-restore-tool.md

Co-authored-by: kissmydb <likun@pingcap.com>
Co-authored-by: TomShawn <41534398+TomShawn@users.noreply.github.com>
Co-authored-by: WangXiangUSTC <wx347249478@gmail.com>
Co-authored-by: Neil Shen <overvenus@gmail.com>

* Some optimization configuration for TiKV (#3278)

* add optimize for tikv

Signed-off-by: Little-Wallace <bupt2013211450@gmail.com>

* add blank

Signed-off-by: Little-Wallace <bupt2013211450@gmail.com>

* rename some file

Signed-off-by: Little-Wallace <bupt2013211450@gmail.com>

* fix some link

Signed-off-by: Little-Wallace <bupt2013211450@gmail.com>

* fix blank

Signed-off-by: Little-Wallace <bupt2013211450@gmail.com>

* fix some comment

Signed-off-by: Little-Wallace <bupt2013211450@gmail.com>

* Update tune-tikv-performance-thread.md

Co-authored-by: Lilian Lee <lilin@pingcap.com>

* Update tune-tikv-performance-thread.md

Co-authored-by: Lilian Lee <lilin@pingcap.com>

* Update faq/tidb-faq.md

Co-authored-by: Lilian Lee <lilin@pingcap.com>

* fix grafana

Signed-off-by: Little-Wallace <bupt2013211450@gmail.com>

* Update tune-tikv-performance-thread.md

Co-authored-by: Lilian Lee <lilin@pingcap.com>

* Update tune-tikv-performance-thread.md

Co-authored-by: Lilian Lee <lilin@pingcap.com>

* Update faq/tidb-faq.md

Co-authored-by: Lilian Lee <lilin@pingcap.com>

* rename file

Signed-off-by: Little-Wallace <bupt2013211450@gmail.com>

* add code format

Signed-off-by: Little-Wallace <bupt2013211450@gmail.com>

* address comment

Signed-off-by: Little-Wallace <bupt2013211450@gmail.com>

* Update tune-tikv-thread-performance.md

* Apply suggestions from code review

* Fix format

* Apply suggestions from code review

Co-authored-by: Lilian Lee <lilin@pingcap.com>
Co-authored-by: pingcap-github-bot <sre-bot@pingcap.com>

* add troubleshoot-high-disk-io.md (#3237)

* system-table: update diagnose system table doc (#3154)

* Update tidb-best-practices.md (#3291)

* optimize production-deployment-using-tiup (#3224)

* Update grafana tikv dashboard doc (#3150)

Signed-off-by: TXXT <hunterlxt@live.com>

Co-authored-by: Connor <zbk602423539@gmail.com>
Co-authored-by: Ran <huangran@pingcap.com>
Co-authored-by: Lei Zhao <zlwgx1023@gmail.com>
Co-authored-by: qupeng <onlyqupeng@gmail.com>
Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>
Co-authored-by: zhangjinpeng1987 <zhangjinpeng@pingcap.com>

* Update tiflash usage (#3351)

* Add tiflash intro into TOC (#3355)

* Update sql-faq.md (#3262)

* tools: update toc for cdc (#3352)

* update ticdc

* add link in ticdc overview

* update link

* fix link

* add aliases

* Update TOC.md

Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>

* fix link

* combine deploy ticdc to manage ticdc

* update title

* Update manage-ticdc.md

* Update production-deployment-using-tiup.md

* move ticdc files to ticdc folder

* fix links

* Update manage-ticdc.md

* Update ticdc-overview.md

* fix a link

Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>
Co-authored-by: kissmydb <likun@pingcap.com>
Co-authored-by: yikeke <yikeke@pingcap.com>

* migrate: migrate from mysql files (#3252)

* perf-tuning: add blacklist-control-plan.md (#3253)

* Update benchmark-tidb-using-tpcc.md (#3354)

* Update benchmark-tidb-using-tpcc.md

* Update benchmark-tidb-using-tpcc.md

* Update benchmark/benchmark-tidb-using-tpcc.md

* Update format

Co-authored-by: Lilian Lee <lilin@pingcap.com>
Co-authored-by: pingcap-github-bot <sre-bot@pingcap.com>

* update maintain-tidb-using-tiup.md (#3204)

* architecture: add tidb-architecture, tidb-computing, tidb-storage (#3222)

* dashboard: add docs for cluster info, statement, log search pages (#3247)

* Add Dashboard TOC

Signed-off-by: Breezewish <me@breeswish.org>

* dashboard: add docs about cluster info page

* dashboard: add docs about statement list page

* dashboard: add docs about statement detail page

* dashboard: add docs about log search page

* dashboard: add missed content for statement detail page

* dashboard: fix CI

* dashboard: address the comments

Signed-off-by: baurine <2008.hbl@gmail.com>

* refine

* Update cluster-info.md

* Update log-search.md

* Update detail.md

* Update list.md

* dashboard: add summary meta

* adjust files structure

* fix CI

* fix CI

* fix CI

* Update dashboard/dashboard-statements-list.md

Co-authored-by: 混沌DM <hundundm@gmail.com>

* Update dashboard/dashboard-cluster-info.md

Co-authored-by: 混沌DM <hundundm@gmail.com>

* update file name

Co-authored-by: Breezewish <me@breeswish.org>
Co-authored-by: Wenxuan <hi@breeswish.org>
Co-authored-by: 混沌DM <hundundm@gmail.com>

* Update Dashboard Key-Visualizer Page (#3250)

* Update overview.md (#3166)

* add some note of TiCDC (#3356)

* Add store limit guide (#3353)

* dashboard: update dashboard media files structure (#3359)

* dashboard: update media files structure

* fix link

Co-authored-by: TomShawn <41534398+TomShawn@users.noreply.github.com>

* add `SET ROLE` document (#3358)

* Add Dashboard Access, Overview and Profiling Page (#3244)

* Add Dashboard TOC

Signed-off-by: Breezewish <me@breeswish.org>

* Add Access, Overview and Profiling Page

Signed-off-by: Breezewish <me@breeswish.org>

* Fix lint

Signed-off-by: Breezewish <me@breeswish.org>

* Address comments

Signed-off-by: Breezewish <me@breeswish.org>

* Update some doc styles

Signed-off-by: Breezewish <me@breeswish.org>

* Rename files

Signed-off-by: Breezewish <me@breeswish.org>

* Rename

Signed-off-by: Breezewish <me@breeswish.org>

* Make CI happy

Signed-off-by: Breezewish <me@breeswish.org>

* Update dashboard/dashboard-profiling.md

Co-authored-by: 混沌DM <hundundm@gmail.com>

* Update dashboard/dashboard-access.md

Co-authored-by: 混沌DM <hundundm@gmail.com>

* Move images

Signed-off-by: Breezewish <me@breeswish.org>

* Fix deadlink

Signed-off-by: Breezewish <me@breeswish.org>

Co-authored-by: 混沌DM <hundundm@gmail.com>

* combine duplicate doc (#3361)

* combine duplicate doc:

 - sql-statements/sql-statement-show-table-next-row-id.md
 - sql-statements/sql-statement-show-table-next-rowid.md

* fix link

Co-authored-by: yikeke <yikeke@pingcap.com>
Co-authored-by: pingcap-github-bot <sre-bot@pingcap.com>

* Add syntax gram of `load stats`  (#3362)

* resources: update the Figma link (#3230)

* load stats

* add png

* make linter happy

* Update sql-statements/sql-statement-load-stats.md

Co-authored-by: Lynn <zimu_xia@126.com>

* update

Co-authored-by: Caitin <34535727+CaitinChen@users.noreply.github.com>
Co-authored-by: Lynn <zimu_xia@126.com>
Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>

* Add new sql statements to TOC.md (#3357)

* Add doc for cluster diagnose in dashboard (#3273)

* architecture: fix link (#3365)

* architecture: fix link

* Update tidb-computing.md

Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>

Co-authored-by: pingcap-github-bot <sre-bot@pingcap.com>
Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>

* tools: update toc for data migration (#3363)

* add migration by sql

* update toc

* Update data-migration-route.md

Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Lilian Lee <lilin@pingcap.com>
Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>

* remove duplicate content

Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>
Co-authored-by: Lilian Lee <lilin@pingcap.com>
Co-authored-by: pingcap-github-bot <sre-bot@pingcap.com>

* delete extra aliases (#3367)

* delete extra aliases

* Update sql-statement-alter-index.md

* Update sql-statement-change-column.md

* update dashboard diagnostics pickture name (#3366)

* update dashboard diagnostics pickture name

Signed-off-by: crazycs520 <crazycs520@gmail.com>

* update link

Signed-off-by: crazycs520 <crazycs520@gmail.com>

* fix typos

Co-authored-by: TomShawn <41534398+TomShawn@users.noreply.github.com>
Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>

* add plan_from_cache in slow_query document (#3369)

* add plan_from_cache in slow_query document

* Update identify-slow-queries.md

Co-authored-by: Lilian Lee <lilin@pingcap.com>

* improve location-awareness (#3174)

* improve location-awareness

Signed-off-by: disksing <i@disksing.com>

* Update location-awareness.md

Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>

* Update location-awareness.md

Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>

* Update location-awareness.md

Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>

* Update location-awareness.md

Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>

* Update location-awareness.md

Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>

* Update location-awareness.md

Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>

* Update location-awareness.md

Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>

* Update location-awareness.md

Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>

* Update location-awareness.md

Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>

* Update location-awareness.md

Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>

* Update location-awareness.md

Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>

* rename the file and add an alias

* update title

* fix CI

* fix 2 links

* Update TOC.md

Co-authored-by: Keke Yi <40977455+yikeke@users.noreply.github.com>
Co-authored-by: yikeke <yikeke@pingcap.com>

* tidy up docs-special-week branch (#3368)

* remove names and refs

* tidy up TOC; add draft attribute; fix minor issues

* draft:true -> draft: true

* refine TOC

* rename a file; delete extra empty files

* fix 4 dead links due to renaming

* rename a file; add an alias

* <br> -> <br/>

* Update descriptions and format (#3370)

* 修改一些描述的层次格式

* 修改缩进

* Update troubleshoot-high-disk-io.md

* Update troubleshoot-high-disk-io.md

* Update indentation

* Update troubleshoot-high-disk-io.md

* Update troubleshoot-high-disk-io.md

update 一些段落格式

Co-authored-by: Lilian Lee <lilin@pingcap.com>

* add backticks to fix build issues (#3371)

* add backticks to fix build issues

* remove extra slash

* revert frontmatter changes

* Update tune-tiflash-performance.md

* delete extra assignee names

* fix two build issues

Co-authored-by: lilin90 <lilin@pingcap.com>
Co-authored-by: Yiding Cui <winoros@gmail.com>
Co-authored-by: ShuNing <nolouch@gmail.com>
Co-authored-by: ruoxi <zanmato1984@gmail.com>
Co-authored-by: Flowyi <flowbehappy@gmail.com>
Co-authored-by: Lynn <zimu_xia@126.com>
Co-authored-by: xufei <xufei@pingcap.com>
Co-authored-by: 3pointer <luancheng@pingcap.com>
Co-authored-by: Ran <huangran@pingcap.com>
Co-authored-by: Lei Zhao <zlwgx1023@gmail.com>
Co-authored-by: TomShawn <41534398+TomShawn@users.noreply.github.com>
Co-authored-by: toutdesuite <guizhiluo2014@163.com>
Co-authored-by: JaySon <tshent@qq.com>
Co-authored-by: Zwb <ethercflow@gmail.com>
Co-authored-by: pingcap-github-bot <sre-bot@pingcap.com>
Co-authored-by: lidezhu <47731263+lidezhu@users.noreply.github.com>
Co-authored-by: pepezzzz <35323945+pepezzzz@users.noreply.github.com>
Co-authored-by: tangenta <tangenta@126.com>
Co-authored-by: lawyerphx <pheqx@qq.com>
Co-authored-by: cfzjywxk <lsswxr@163.com>
Co-authored-by: Zejun Li <lizejun@pingcap.com>
Co-authored-by: MyonKeminta <9948422+MyonKeminta@users.noreply.github.com>
Co-authored-by: Win-Man <825895587@qq.com>
Co-authored-by: Jack Yu <yusp@pingcap.com>
Co-authored-by: Chengpeng Yan <41809508+Reminiscent@users.noreply.github.com>
Co-authored-by: Ryan Leung <rleungx@gmail.com>
Co-authored-by: HuaiyuXu <391585975@qq.com>
Co-authored-by: Feng Liyuan <darktemplar.f@gmail.com>
Co-authored-by: Xintao <hunterlxt@live.com>
Co-authored-by: Caitin <34535727+CaitinChen@users.noreply.github.com>
Co-authored-by: Kenan Yao <cauchy1992@gmail.com>
Co-authored-by: djshow832 <873581766@qq.com>
Co-authored-by: Lingyu Song <songlingyu@pingcap.com>
Co-authored-by: kissmydb <likun@pingcap.com>
Co-authored-by: Zhuomin(Charming) Liu <lzmhhh123@gmail.com>
Co-authored-by: Lonng <heng@lonng.org>
Co-authored-by: yuzhibotao <52073478+yuzhibotao@users.noreply.github.com>
Co-authored-by: bb7133 <bb7133@gmail.com>
Co-authored-by: Wallace <bupt2013211450@gmail.com>
Co-authored-by: Liangliang Gu <marsishandsome@gmail.com>
Co-authored-by: crazycs <crazycs520@gmail.com>
Co-authored-by: 苗青利 <51319517+miaoqingli@users.noreply.github.com>
Co-authored-by: Zhang Jian <zjsariel@gmail.com>
Co-authored-by: lzs <43946384+superlzs0476@users.noreply.github.com>
Co-authored-by: Shenghui Wu <793703860@qq.com>
Co-authored-by: xiaoyangwang5 <49518579+xiaoyangwang5@users.noreply.github.com>
Co-authored-by: pcqz <45614653+pcqz@users.noreply.github.com>
Co-authored-by: freyfl <48233548+freyfl@users.noreply.github.com>
Co-authored-by: wentaojin <34805682+WentaoJin@users.noreply.github.com>
Co-authored-by: lysu <sulifx@gmail.com>
Co-authored-by: tiancaiamao <tiancaiamao@gmail.com>
Co-authored-by: King-Dylan <50897894+King-Dylan@users.noreply.github.com>
Co-authored-by: Zhi Qi <30543181+LittleFall@users.noreply.github.com>
Co-authored-by: disksing <i@disksing.com>
Co-authored-by: DamonGuo@PingCAP <50732087+Damon-PingCap@users.noreply.github.com>
Co-authored-by: KASSADAR <KASSADAR@ALIYUN.COM>
Co-authored-by: zhenjiao gao <26379799+zhenjiaogao@users.noreply.github.com>
Co-authored-by: lei yu <leiysky@outlook.com>
Co-authored-by: qupeng <onlyqupeng@gmail.com>
Co-authored-by: wjHuang <huangwenjun1997@gmail.com>
Co-authored-by: glkappe <qihang.li@pingcap.com>
Co-authored-by: Jay <BusyJay@users.noreply.github.com>
Co-authored-by: WangXiangUSTC <wx347249478@gmail.com>
Co-authored-by: Wenxuan <hi@breeswish.org>
Co-authored-by: Wang Jun <277372664@qq.com>
Co-authored-by: Neil Shen <overvenus@gmail.com>
Co-authored-by: 山岚 <36239017+YuJuncen@users.noreply.github.com>
Co-authored-by: lhy1024 <liuhanyang@pingcap.com>
Co-authored-by: birdstorm <samuelwyf@hotmail.com>
Co-authored-by: Shirly <wuxuelian@pingcap.com>
Co-authored-by: winkyao <golangwink@gmail.com>
Co-authored-by: TaoZhengCN <taozheng@pingcap.com>
Co-authored-by: Connor <zbk602423539@gmail.com>
Co-authored-by: zhangjinpeng1987 <zhangjinpeng@pingcap.com>
Co-authored-by: yilongrong <55389305+yilongrong@users.noreply.github.com>
Co-authored-by: Se-L <Seiferbb@126.com>
Co-authored-by: wangxj <44355590+together-wang@users.noreply.github.com>
Co-authored-by: Sparkle <1284531+baurine@users.noreply.github.com>
Co-authored-by: Breezewish <me@breeswish.org>
Co-authored-by: 混沌DM <hundundm@gmail.com>
Co-authored-by: ruofly0425 <ruofly0425@gmail.com>
Co-authored-by: leoppro <zhaoyilin@pingcap.com>
Co-authored-by: Yuanjia Zhang <zhangyuanjia@pingcap.com>
  • Loading branch information
Show file tree
Hide file tree
Showing 950 changed files with 16,751 additions and 7,663 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/assign-to-project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Assign to Project

on:
issues:
types: [opened, labeled]
pull_request:
types: [opened, labeled]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
assign_one_project:
runs-on: ubuntu-latest
name: Assign to Project
steps:
- name: Assign NEW issues to Docs SIG project
uses: srggrs/assign-one-project-github-action@1.2.0
if: |
github.event_name == 'issues' &&
github.event.action == 'opened'
with:
project: 'https://github.com/pingcap/docs-cn/projects/1'
column_name: 'Issue: Backlog'
- name: Assign NEW pull requests to Docs SIG project
uses: srggrs/assign-one-project-github-action@1.2.0
if: |
github.event_name == 'pull_request' &&
github.event.action == 'opened'
with:
project: 'https://github.com/pingcap/docs-cn/projects/1'
column_name: 'PR: In Progress'
- name: Assign issues or PRs with translation-welcome label
uses: srggrs/assign-one-project-github-action@1.2.0
if: |
contains(github.event.issue.labels.*.name, 'translation/welcome') ||
contains(github.event.pull_request.labels.*.name, 'translation/welcome')
with:
project: 'https://github.com/pingcap/docs-cn/projects/2'
column_name: 'To do'
669 changes: 359 additions & 310 deletions TOC.md

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions adopters.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
draft: true
---
57 changes: 57 additions & 0 deletions agg-distinct-optimization.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
title: Distinct 优化
category: performance
---

# Distinct 优化

本文档介绍可用于 `DISTINCT` 的优化,包括简单 `DISTINCT` 和聚合函数 `DISTINCT` 的优化。

## 简单 DISTINCT

通常简单的 `DISTINCT` 会被优化成 GROUP BY 来执行。例如:

```sql
mysql> explain select DISTINCT a from t;
+--------------------------+---------+-----------+---------------+-------------------------------------------------------+
| id | estRows | task | access object | operator info |
+--------------------------+---------+-----------+---------------+-------------------------------------------------------+
| HashAgg_6 | 2.40 | root | | group by:test.t.a, funcs:firstrow(test.t.a)->test.t.a |
| └─TableReader_11 | 3.00 | root | | data:TableFullScan_10 |
| └─TableFullScan_10 | 3.00 | cop[tikv] | table:t | keep order:false, stats:pseudo |
+--------------------------+---------+-----------+---------------+-------------------------------------------------------+
3 rows in set (0.00 sec)
```

## 聚合函数 DISTINCT

通常来说,带有 `DISTINCT` 的聚合函数会单线程的在 TiDB 侧执行。
使用系统变量 [`tidb_opt_distinct_agg_push_down`](/tidb-specific-system-variables.md#tidb_opt_distinct_agg_push_down) 或者 TiDB 的配置项 [distinct-agg-push-down](/tidb-configuration-file.md#distinct-agg-push-down) 控制优化器是否执行带有 `DISTINCT` 的聚合函数(比如 `select count(distinct a) from t`)下推到 Coprocessor 的优化操作。

在以下示例中,`tidb_opt_distinct_agg_push_down` 开启前,TiDB 需要从 TiKV 读取所有数据,并在 TiDB 侧执行 `disctinct``tidb_opt_distinct_agg_push_down` 开启后,`distinct a` 被下推到了 Coprocessor,在 `HashAgg_5` 里新增了一个 `group by``test.t.a`

```sql
mysql> desc select count(distinct a) from test.t;
+-------------------------+----------+-----------+---------------+------------------------------------------+
| id | estRows | task | access object | operator info |
+-------------------------+----------+-----------+---------------+------------------------------------------+
| StreamAgg_6 | 1.00 | root | | funcs:count(distinct test.t.a)->Column#4 |
| └─TableReader_10 | 10000.00 | root | | data:TableFullScan_9 |
| └─TableFullScan_9 | 10000.00 | cop[tikv] | table:t | keep order:false, stats:pseudo |
+-------------------------+----------+-----------+---------------+------------------------------------------+
3 rows in set (0.01 sec)

mysql> set session tidb_opt_distinct_agg_push_down = 1;
Query OK, 0 rows affected (0.00 sec)

mysql> desc select count(distinct a) from test.t;
+---------------------------+----------+-----------+---------------+------------------------------------------+
| id | estRows | task | access object | operator info |
+---------------------------+----------+-----------+---------------+------------------------------------------+
| HashAgg_8 | 1.00 | root | | funcs:count(distinct test.t.a)->Column#3 |
| └─TableReader_9 | 1.00 | root | | data:HashAgg_5 |
| └─HashAgg_5 | 1.00 | cop[tikv] | | group by:test.t.a, |
| └─TableFullScan_7 | 10000.00 | cop[tikv] | table:t | keep order:false, stats:pseudo |
+---------------------------+----------+-----------+---------------+------------------------------------------+
4 rows in set (0.00 sec)
```
202 changes: 202 additions & 0 deletions auto-increment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
---
title: AUTO_INCREMENT
category: reference
summary: 介绍 TiDB 的 `AUTO_INCREMENT` 列属性。
---

# AUTO_INCREMENT

本文介绍列属性 `AUTO_INCREMENT` 的基本概念、实现原理、自增相关的特性,以及使用限制。

## 基本概念

`AUTO_INCREMENT` 是用于自动填充缺省列值的列属性。当 `INSERT` 语句没有指定 `AUTO_INCREMENT` 列的具体值时,系统会自动地为该列分配一个值。该值满足唯一性,以及**特殊情况下**的递增性和连续性。使用示例如下:

{{< copyable "sql" >}}

```sql
create table t(id int primary key AUTO_INCREMENT, c int);
```

{{< copyable "sql" >}}

```sql
insert into t(c) values (1);
insert into t(c) values (2);
insert into t(c) values (3), (4), (5);
```

```sql
mysql> select * from t;
+----+---+
| id | c |
+----+---+
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
| 4 | 4 |
| 5 | 5 |
+----+---+
5 rows in set (0.01 sec)
```

此外,`AUTO_INCREMENT` 还支持显式指定列值的插入语句,此时 TiDB 会保存显式指定的值:

{{< copyable "sql" >}}

```sql
insert into t(id, c) values (6, 6);
```

```sql
mysql> select * from t;
+----+---+
| id | c |
+----+---+
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
| 4 | 4 |
| 5 | 5 |
| 6 | 6 |
+----+---+
6 rows in set (0.01 sec)
```

以上用法和 MySQL 的 `AUTO_INCREMENT` 用法一致。但在隐式分配的具体值方面,TiDB 和 MySQL 之间具有较为显著的差异。

## 实现原理

TiDB 实现 `AUTO_INCREMENT` 隐式分配的原理是,对于每一个自增列,都使用一个全局可见的键值对用于记录当前已分配的最大 ID。由于分布式环境下的节点通信存在一定开销,为了避免写请求放大的问题,每个 TiDB 节点在分配 ID 时,都申请一段 ID 作为缓存,用完之后再去取下一段,而不是每次分配都向存储节点申请。例如,对于以下新建的表:

```sql
create table t(id int unique key AUTO_INCREMENT, c int);
```

假设集群中有两个 TiDB 实例 A 和 B,如果向 A 和 B 分别对 `t` 执行一条插入语句:

```sql
insert into t (c) values (1)
```

实例 A 可能会缓存 `[1,30000]` 的自增 ID,而实例 B 则可能缓存 `[30001,60000]` 的自增 ID。各自实例缓存的 ID 将随着执行将来的插入语句被作为缺省值,顺序地填充到 `AUTO_INCREMENT` 列中。

## 基本特性

### 唯一性保证

> **警告:**
>
> 在集群中有多个 TiDB 实例时,如果表结构中有自增 ID,建议不要混用显式插入和隐式分配(即自增列的缺省值和自定义值),否则可能会破坏隐式分配值的唯一性。
例如在上述示例中,依次执行如下操作:

1. 客户端向实例 B 插入一条将 `id` 设置为 `2` 的语句 `insert into t values (2, 1)`,并执行成功。
2. 客户端向实例 A 发送 `Insert` 语句 `insert into t (c) (1)`,这条语句中没有指定 `id` 的值,所以会由 A 分配。当前 A 缓存了 `[1, 30000]` 这段 ID,可能会分配 `2` 为自增 ID 的值,并把本地计数器加 `1`。而此时数据库中已经存在 `id``2` 的数据,最终返回 `Duplicated Error` 错误。

### 递增性保证

`AUTO_INCREMENT` 列隐式分配值的递增性只能在含有单个 TiDB 实例的集群中得到保证:即对于同一个自增列,先分配的值小于后分配的值;而在含有多个 TiDB 实例的集群中,无法保证自增列的递增性。

例如,对于上述例子,如果先向实例 B 执行一条插入语句,再向实例 A 执行一条插入语句。根据缓存自增 ID 的性质,自增列隐式分配的值可能分别是 `30002``2`。因此从时间上看,不满足递增性。

### 连续性保证

在含有多个 TiDB 实例的集群中,`AUTO_INCREMENT` 分配值的连续性**只能**在 batch insert 语句中得到保证。

例如,对以下表执行以下语句:

```sql
create table t (a int primary key AUTO_INCREMENT)
```

```sql
insert into t values (), (), (), ()
```

即使存在正在执行并发写入的其他 TiDB 实例,或者当前实例剩余的缓存 ID 数量不够,都不会影响分配值的连续性。

### `_tidb_rowid` 的关联性

> **注意:**
>
> 在没有指定整数类型主键的情况下 TiDB 会使用 `_tidb_rowid` 来标识行,该数值的分配会和自增列(如果存在的话)共用一个分配器,其中缓存的大小可能会被自增列和 `_tidb_rowid` 共同消耗。因此会有以下的示例情况:
```sql
mysql> create table t(id int unique key AUTO_INCREMENT);
Query OK, 0 rows affected (0.05 sec)

mysql> insert into t values (),(),();
Query OK, 3 rows affected (0.00 sec)
Records: 3 Duplicates: 0 Warnings: 0

mysql> select _tidb_rowid, id from t;
+-------------+------+
| _tidb_rowid | id |
+-------------+------+
| 4 | 1 |
| 5 | 2 |
| 6 | 3 |
+-------------+------+
3 rows in set (0.01 sec)
```

### 缓存大小控制

TiDB 自增 ID 的缓存大小在早期版本中是对用户透明的。从 v3.1.2、v3.0.14 和 v4.0.rc-2 版本开始,TiDB 引入了 `AUTO_ID_CACHE` 表选项来允许用户自主设置自增 ID 分配缓存的大小。例如:

```sql
mysql> create table t(a int auto_increment key) AUTO_ID_CACHE 100;
Query OK, 0 rows affected (0.02 sec)

mysql> insert into t values();
Query OK, 1 row affected (0.00 sec)
Records: 1 Duplicates: 0 Warnings: 0

mysql> select * from t;
+---+
| a |
+---+
| 1 |
+---+
1 row in set (0.01 sec)
```

此时如果将该列的自增缓存无效化,重新进行隐式分配:

```sql
mysql> delete from t;
Query OK, 1 row affected (0.01 sec)

mysql> rename table t to t1;
Query OK, 0 rows affected (0.01 sec)

mysql> insert into t1 values()
Query OK, 1 row affected (0.00 sec)

mysql> select * from t;
+-----+
| a |
+-----+
| 101 |
+-----+
1 row in set (0.00 sec)
```

可以看到再一次分配的值为 `101`,说明该表的自增 ID 分配缓存的大小为 `100`

此外如果在批量插入的 `INSERT` 语句中所需连续 ID 长度超过 `AUTO_ID_CACHE` 的长度时,TiDB 会适当调大缓存以便能够保证该语句的正常插入。

### 自增步长和偏移量设置

从 v3.0.9 和 v4.0.rc-1 开始,和 MySQL 的行为类似,自增列隐式分配的值遵循 session 变量 `@@auto_increment_increment``@@auto_increment_offset` 的控制,其中自增列隐式分配的值 (ID) 将满足式子 `(ID - auto_increment_offset) % auto_increment_increment == 0`

## 使用限制

目前在 TiDB 中使用 `AUTO_INCREMENT` 有以下限制:

- 必须定义在主键或者唯一索引的列上。
- 只能定义在类型为整数、`FLOAT``DOUBLE` 的列上。
- 不支持与列的默认值 `DEFAULT` 同时指定在同一列上。
- 不支持使用 `ALTER TABLE` 来添加 `AUTO_INCREMENT` 属性。
- 支持使用 `ALTER TABLE` 来移除 `AUTO_INCREMENT` 属性。但从 TiDB 2.1.18 和 3.0.4 版本开始,TiDB 通过 session 变量 `@@tidb_allow_remove_auto_inc` 控制是否允许通过 `ALTER TABLE MODIFY``ALTER TABLE CHANGE` 来移除列的 `AUTO_INCREMENT` 属性,默认是不允许移除。
7 changes: 4 additions & 3 deletions auto-random.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: AUTO_RANDOM
category: reference
summary: 本文介绍了 TiDB 的 `AUTO_RANDOM` 列属性。
aliases: ['/docs-cn/dev/reference/sql/attributes/auto-random/']
---

Expand Down Expand Up @@ -119,7 +120,7 @@ TiDB 支持解析版本注释语法。示例如下:
{{< copyable "sql" >}}

```sql
create table t (a bigint primary key /*T!30100 auto_random */)
create table t (a bigint primary key /*T![auto_rand] auto_random */)
```

{{< copyable "sql" >}}
Expand All @@ -130,9 +131,9 @@ create table t (a bigint primary key auto_random)

以上两个语句含义相同。

`show create table` 的结果中,`AUTO_RANDOM` 属性会被注释掉。注释会附带一个版本号,例如 `/*T!30100 auto_random */`。其中 `30100` 表示 v3.1.0 引入该功能,低版本的 TiDB 能够忽略带有上述注释的 `AUTO_RANDOM` 属性
`show create table` 的结果中,`AUTO_RANDOM` 属性会被注释掉。注释会附带一个特性标识符,例如 `/*T![auto_rand] auto_random */`。其中 `auto_rand` 表示 `AUTO_RANDOM` 的特性标识符,只有实现了该标识符对应特性的 TiDB 版本才能够正常解析 SQL 语句片段

该功能支持向前兼容,即降级兼容。v3.1.0 以前的 TiDB 会忽略表(带有上述注释)的 `AUTO_RANDOM` 属性,因此能够使用含有该属性的表。
该功能支持向前兼容,即降级兼容。没有实现对应特性的 TiDB 版本则会忽略表(带有上述注释)的 `AUTO_RANDOM` 属性,因此能够使用含有该属性的表。

## 使用限制

Expand Down
Loading

0 comments on commit a3c0b95

Please sign in to comment.