Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
qiancai committed Dec 2, 2024
2 parents 57c4287 + 22341b8 commit e326595
Show file tree
Hide file tree
Showing 50 changed files with 389 additions and 278 deletions.
8 changes: 3 additions & 5 deletions accelerated-table-creation.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,9 @@ When accelerated table creation is enabled via [`tidb_enable_fast_create_table`]

The merged batch table creation statements are executed within the same transaction, so if one statement of them fails, all of them will fail.

> **Warning:**
>
> This feature is currently an experimental feature and it is not recommended to use in a production environment. This feature might change or be removed without prior notice. If you find a bug, please give feedback by raising an [issue](https://github.com/pingcap/tidb/issues) on GitHub.
## Compatibility with TiDB tools

- [TiCDC](https://docs.pingcap.com/tidb/stable/ticdc-overview) does not support replicating the tables that are created by `tidb_enable_fast_create_table`.
- Before TiDB v8.3.0, [TiCDC](https://docs.pingcap.com/tidb/stable/ticdc-overview) does not support replicating the tables that are created by `tidb_enable_fast_create_table`. Starting from v8.3.0, TiCDC can properly replicate these tables.

## Limitation

Expand All @@ -28,6 +24,8 @@ You can now use performance optimization for table creation only in the [`CREATE

You can enable or disable performance optimization for creating tables by specifying the value of the system variable [`tidb_enable_fast_create_table`](/system-variables.md#tidb_enable_fast_create_table-new-in-v800).

Starting from TiDB v8.5.0, the accelerated table creation feature is enabled by default for newly created clusters, with `tidb_enable_fast_create_table` set to `ON`. For clusters upgraded from v8.4.0 or earlier versions, the default value of `tidb_enable_fast_create_table` remains unchanged.

To enable performance optimization for creating tables, set the value of this variable to `ON`:

```sql
Expand Down
2 changes: 1 addition & 1 deletion auto-increment.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ SHOW CREATE TABLE t;
| Table | Create Table |
+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t | CREATE TABLE `t` (
`a` int(11) NOT NULL AUTO_INCREMENT,
`a` int NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`a`) /*T![clustered_index] CLUSTERED */
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=101 /*T![auto_id_cache] AUTO_ID_CACHE=100 */ |
+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Expand Down
2 changes: 1 addition & 1 deletion auto-random.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ tidb> SHOW CREATE TABLE t;
| Table | Create Table |
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t | CREATE TABLE `t` (
`a` bigint(20) NOT NULL /*T![auto_rand] AUTO_RANDOM(5) */,
`a` bigint NOT NULL /*T![auto_rand] AUTO_RANDOM(5) */,
`b` varchar(255) DEFAULT NULL,
PRIMARY KEY (`a`) /*T![clustered_index] CLUSTERED */
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin /*T! PRE_SPLIT_REGIONS=2 */ |
Expand Down
2 changes: 1 addition & 1 deletion basic-sql-operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ For example, to create a table named `person` which includes fields such as numb

```sql
CREATE TABLE person (
id INT(11),
id INT,
name VARCHAR(255),
birthday DATE
);
Expand Down
18 changes: 9 additions & 9 deletions br/br-pitr-manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ Usage example:
```shell
tiup br log truncate --until='2022-07-26 21:20:00+0800' \
–-storage='s3://backup-101/logbackup?access-key=${access-key}&secret-access-key=${secret-access-key}"'
--storage='s3://backup-101/logbackup?access-key=${access-key}&secret-access-key=${secret-access-key}'
```
Expected output:
Expand Down Expand Up @@ -396,7 +396,7 @@ The `--storage` parameter is used to specify the backup storage address. Current
Usage example:
```shell
tiup br log metadata –-storage='s3://backup-101/logbackup?access-key=${access-key}&secret-access-key=${secret-access-key}"'
tiup br log metadata --storage='s3://backup-101/logbackup?access-key=${access-key}&secret-access-key=${secret-access-key}'
```
Expected output:
Expand Down Expand Up @@ -450,8 +450,8 @@ Usage example:
```shell
tiup br restore point --pd="${PD_IP}:2379"
--storage='s3://backup-101/logbackup?access-key=${access-key}&secret-access-key=${secret-access-key}"'
--full-backup-storage='s3://backup-101/snapshot-202205120000?access-key=${access-key}&secret-access-key=${secret-access-key}"'
--storage='s3://backup-101/logbackup?access-key=${access-key}&secret-access-key=${secret-access-key}'
--full-backup-storage='s3://backup-101/snapshot-202205120000?access-key=${access-key}&secret-access-key=${secret-access-key}'

Full Restore <--------------------------------------------------------------------------------------------------------------------------------------------------------> 100.00%
*** ***["Full Restore success summary"] ****** [total-take=3.112928252s] [restore-data-size(after-compressed)=5.056kB] [Size=5056] [BackupTS=434693927394607136] [total-kv=4] [total-kv-size=290B] [average-speed=93.16B/s]
Expand All @@ -474,8 +474,8 @@ The following is an example:
```shell
tiup br restore point --pd="${PD_IP}:2379"
--storage='s3://backup-101/logbackup?access-key=${ACCESS-KEY}&secret-access-key=${SECRET-ACCESS-KEY}"'
--full-backup-storage='s3://backup-101/snapshot-202205120000?access-key=${ACCESS-KEY}&secret-access-key=${SECRET-ACCESS-KEY}"'
--storage='s3://backup-101/logbackup?access-key=${ACCESS-KEY}&secret-access-key=${SECRET-ACCESS-KEY}'
--full-backup-storage='s3://backup-101/snapshot-202205120000?access-key=${ACCESS-KEY}&secret-access-key=${SECRET-ACCESS-KEY}'
--crypter.method aes128-ctr
--crypter.key 0123456789abcdef0123456789abcdef
--log.crypter.method aes128-ctr
Expand All @@ -486,10 +486,10 @@ If a log backup is encrypted using a master key, you can decrypt and restore the
```shell
tiup br restore point --pd="${PD_IP}:2379"
--storage='s3://backup-101/logbackup?access-key=${ACCESS-KEY}&secret-access-key=${SECRET-ACCESS-KEY}"'
--full-backup-storage='s3://backup-101/snapshot-202205120000?access-key=${ACCESS-KEY}&secret-access-key=${SECRET-ACCESS-KEY}"'
--storage='s3://backup-101/logbackup?access-key=${ACCESS-KEY}&secret-access-key=${SECRET-ACCESS-KEY}'
--full-backup-storage='s3://backup-101/snapshot-202205120000?access-key=${ACCESS-KEY}&secret-access-key=${SECRET-ACCESS-KEY}'
--crypter.method aes128-ctr
--crypter.key 0123456789abcdef0123456789abcdef
--master-key-crypter-method aes128-ctr
--master-key "local:///path/to/master.key"
```
```
8 changes: 4 additions & 4 deletions cached-tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ SHOW CREATE TABLE users;
| Table | Create Table |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| users | CREATE TABLE `users` (
`id` bigint(20) NOT NULL,
`id` bigint NOT NULL,
`name` varchar(100) DEFAULT NULL,
PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin /* CACHED ON */ |
Expand Down Expand Up @@ -170,10 +170,10 @@ SHOW CREATE TABLE mysql.table_cache_meta\G
*************************** 1. row ***************************
Table: table_cache_meta
Create Table: CREATE TABLE `table_cache_meta` (
`tid` bigint(11) NOT NULL DEFAULT '0',
`tid` bigint NOT NULL DEFAULT '0',
`lock_type` enum('NONE','READ','INTEND','WRITE') NOT NULL DEFAULT 'NONE',
`lease` bigint(20) NOT NULL DEFAULT '0',
`oldReadLease` bigint(20) NOT NULL DEFAULT '0',
`lease` bigint NOT NULL DEFAULT '0',
`oldReadLease` bigint NOT NULL DEFAULT '0',
PRIMARY KEY (`tid`) /*T![clustered_index] CLUSTERED */
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
1 row in set (0.00 sec)
Expand Down
2 changes: 1 addition & 1 deletion clustered-indexes.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ mysql> SHOW CREATE TABLE t;
| Table | Create Table |
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t | CREATE TABLE `t` (
`a` bigint(20) NOT NULL,
`a` bigint NOT NULL,
`b` varchar(255) DEFAULT NULL,
PRIMARY KEY (`a`) /*T![clustered_index] CLUSTERED */
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
Expand Down
6 changes: 3 additions & 3 deletions constraints.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ SHOW CREATE TABLE t;
| Table | Create Table |
+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t | CREATE TABLE `t` (
`a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
`a` int DEFAULT NULL,
`b` int DEFAULT NULL,
`c` int DEFAULT NULL,
CONSTRAINT `c1` CHECK ((`b` > `c`)),
CONSTRAINT `t_chk_1` CHECK ((`a` > 10)) /*!80016 NOT ENFORCED */,
CONSTRAINT `t_chk_2` CHECK ((1 < `c`))
Expand Down
6 changes: 3 additions & 3 deletions cost-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ mysql> SHOW CREATE TABLE t;
| Table | Create Table |
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t | CREATE TABLE `t` (
`a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
`a` int DEFAULT NULL,
`b` int DEFAULT NULL,
`c` int DEFAULT NULL,
KEY `b` (`b`),
KEY `c` (`c`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
Expand Down
50 changes: 25 additions & 25 deletions develop/dev-guide-bookshop-schema-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ This table stores the basic information of books.

| Field name | Type | Description |
|--------------|---------------|------------------------------------------------------------------|
| id | bigint(20) | Unique ID of a book |
| id | bigint | Unique ID of a book |
| title | varchar(100) | Title of a book |
| type | enum | Type of a book (for example, magazine, animation, or teaching aids) |
| stock | bigint(20) | Stock |
| stock | bigint | Stock |
| price | decimal(15,2) | Price |
| published_at | datetime | Date of publish |

Expand All @@ -179,19 +179,19 @@ This table stores basic information of authors.

| Field name | Type | Description |
|------------|--------------|-------------------------------------------------------|
| id | bigint(20) | Unique ID of an author |
| id | bigint | Unique ID of an author |
| name | varchar(100) | Name of an author |
| gender | tinyint(1) | Biological gender (0: female, 1: male, NULL: unknown) |
| birth_year | smallint(6) | Year of birth |
| death_year | smallint(6) | Year of death |
| gender | tinyint | Biological gender (0: female, 1: male, NULL: unknown) |
| birth_year | smallint | Year of birth |
| death_year | smallint | Year of death |

### `users` table

This table stores information of Bookshop users.

| Field name | Type | Description |
|------------|---------------|-----------------------|
| id | bigint(20) | Unique ID of a user |
| id | bigint | Unique ID of a user |
| balance | decimal(15,2) | Balance |
| nickname | varchar(100) | Nickname |

Expand All @@ -212,19 +212,19 @@ An author may write multiple books, and a book may involve more than one author.

| Field name | Type | Description |
|------------|------------|--------------------------------------------------------------|
| book_id | bigint(20) | Unique ID of a book (linked to [books](#books-table)) |
| author_id | bigint(20) | Unique ID of an author(Link to [authors](#authors-table)|
| book_id | bigint | Unique ID of a book (linked to [books](#books-table)) |
| author_id | bigint | Unique ID of an author(Link to [authors](#authors-table)|

### `orders` table

This table stores user purchase information.

| Field name | Type | Description |
|------------|------------|----------------------------------------------------------------|
| id | bigint(20) | Unique ID of an order |
| book_id | bigint(20) | Unique ID of a book (linked to [books](#books-table)) |
| user_id | bigint(20) | User unique identifier (associated with [users](#users-table)) |
| quantity | tinyint(4) | Purchase quantity |
| id | bigint | Unique ID of an order |
| book_id | bigint | Unique ID of a book (linked to [books](#books-table)) |
| user_id | bigint | User unique identifier (associated with [users](#users-table)) |
| quantity | tinyint | Purchase quantity |
| ordered_at | datetime | Purchase time |

## Database initialization script `dbinit.sql`
Expand All @@ -236,29 +236,29 @@ CREATE DATABASE IF NOT EXISTS `bookshop`;

DROP TABLE IF EXISTS `bookshop`.`books`;
CREATE TABLE `bookshop`.`books` (
`id` bigint(20) AUTO_RANDOM NOT NULL,
`id` bigint AUTO_RANDOM NOT NULL,
`title` varchar(100) NOT NULL,
`type` enum('Magazine', 'Novel', 'Life', 'Arts', 'Comics', 'Education & Reference', 'Humanities & Social Sciences', 'Science & Technology', 'Kids', 'Sports') NOT NULL,
`published_at` datetime NOT NULL,
`stock` int(11) DEFAULT '0',
`stock` int DEFAULT '0',
`price` decimal(15,2) DEFAULT '0.0',
PRIMARY KEY (`id`) CLUSTERED
) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

DROP TABLE IF EXISTS `bookshop`.`authors`;
CREATE TABLE `bookshop`.`authors` (
`id` bigint(20) AUTO_RANDOM NOT NULL,
`id` bigint AUTO_RANDOM NOT NULL,
`name` varchar(100) NOT NULL,
`gender` tinyint(1) DEFAULT NULL,
`birth_year` smallint(6) DEFAULT NULL,
`death_year` smallint(6) DEFAULT NULL,
`gender` tinyint DEFAULT NULL,
`birth_year` smallint DEFAULT NULL,
`death_year` smallint DEFAULT NULL,
PRIMARY KEY (`id`) CLUSTERED
) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

DROP TABLE IF EXISTS `bookshop`.`book_authors`;
CREATE TABLE `bookshop`.`book_authors` (
`book_id` bigint(20) NOT NULL,
`author_id` bigint(20) NOT NULL,
`book_id` bigint NOT NULL,
`author_id` bigint NOT NULL,
PRIMARY KEY (`book_id`,`author_id`) CLUSTERED
) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

Expand All @@ -283,10 +283,10 @@ CREATE TABLE `bookshop`.`users` (

DROP TABLE IF EXISTS `bookshop`.`orders`;
CREATE TABLE `bookshop`.`orders` (
`id` bigint(20) AUTO_RANDOM NOT NULL,
`book_id` bigint(20) NOT NULL,
`user_id` bigint(20) NOT NULL,
`quality` tinyint(4) NOT NULL,
`id` bigint AUTO_RANDOM NOT NULL,
`book_id` bigint NOT NULL,
`user_id` bigint NOT NULL,
`quality` tinyint NOT NULL,
`ordered_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`) CLUSTERED,
KEY `orders_book_id_idx` (`book_id`)
Expand Down
8 changes: 4 additions & 4 deletions develop/dev-guide-create-secondary-indexes.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,22 @@ The fields in the `books` table are as follows:

| Field name | Type | Field description |
|--------------|---------------|------------------------------------------------------------------|
| id | bigint(20) | Unique ID of the book |
| id | bigint | Unique ID of the book |
| title | varchar(100) | Book title |
| type | enum | Types of books (for example, magazines, animations, and teaching aids) |
| stock | bigint(20) | Stock |
| stock | bigint | Stock |
| price | decimal(15,2) | Price |
| published_at | datetime | Date of publishing |

The `books` table is created using the following SQL statement:

```sql
CREATE TABLE `bookshop`.`books` (
`id` bigint(20) AUTO_RANDOM NOT NULL,
`id` bigint AUTO_RANDOM NOT NULL,
`title` varchar(100) NOT NULL,
`type` enum('Magazine', 'Novel', 'Life', 'Arts', 'Comics', 'Education & Reference', 'Humanities & Social Sciences', 'Science & Technology', 'Kids', 'Sports') NOT NULL,
`published_at` datetime NOT NULL,
`stock` int(11) DEFAULT '0',
`stock` int DEFAULT '0',
`price` decimal(15,2) DEFAULT '0.0',
PRIMARY KEY (`id`) CLUSTERED
) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
Expand Down
4 changes: 2 additions & 2 deletions develop/dev-guide-index-best-practice.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ This section takes the `books` table in the [bookshop](/develop/dev-guide-booksh

```sql
CREATE TABLE `books` (
`id` bigint(20) AUTO_RANDOM NOT NULL,
`id` bigint AUTO_RANDOM NOT NULL,
`title` varchar(100) NOT NULL,
`type` enum('Magazine', 'Novel', 'Life', 'Arts', 'Comics', 'Education & Reference', 'Humanities & Social Sciences', 'Science & Technology', 'Kids', 'Sports') NOT NULL,
`published_at` datetime NOT NULL,
`stock` int(11) DEFAULT '0',
`stock` int DEFAULT '0',
`price` decimal(15,2) DEFAULT '0.0',
PRIMARY KEY (`id`) CLUSTERED
) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
Expand Down
Loading

0 comments on commit e326595

Please sign in to comment.