diff --git a/TOC-tidb-cloud.md b/TOC-tidb-cloud.md index 4cdbb9cc4d69b..74d27f9a6288e 100644 --- a/TOC-tidb-cloud.md +++ b/TOC-tidb-cloud.md @@ -47,6 +47,7 @@ - [Follower Read](/develop/dev-guide-use-follower-read.md) - [Stale Read](/develop/dev-guide-use-stale-read.md) - [HTAP Queries](/develop/dev-guide-hybrid-oltp-and-olap-queries.md) + - [FastScan](/develop/dev-guide-use-fastscan.md) - Transaction - [Overview](/develop/dev-guide-transaction-overview.md) - [Optimistic and Pessimistic Transactions](/develop/dev-guide-optimistic-and-pessimistic-transaction.md) @@ -149,6 +150,7 @@ - [Aggregation](/explain-aggregation.md) - [Views](/explain-views.md) - [Partitions](/explain-partitions.md) + - [Index Merge](/explain-index-merge.md) - SQL Optimization Process - [Overview](/sql-optimization-concepts.md) - Logic Optimization @@ -165,6 +167,7 @@ - [Overview](/sql-physical-optimization.md) - [Index Selection](/choose-index.md) - [Statistics](/statistics.md) + - [Extended Statistics](/extended-statistics.md) - [Wrong Index Solution](/wrong-index-solution.md) - [Distinct Optimization](/agg-distinct-optimization.md) - [Cost Model](/cost-model.md) @@ -288,6 +291,8 @@ - [`EXECUTE`](/sql-statements/sql-statement-execute.md) - [`EXPLAIN ANALYZE`](/sql-statements/sql-statement-explain-analyze.md) - [`EXPLAIN`](/sql-statements/sql-statement-explain.md) + - [`FLASHBACK CLUSTER TO TIMESTAMP`](/sql-statements/sql-statement-flashback-to-timestamp.md) + - [`FLASHBACK DATABASE`](/sql-statements/sql-statement-flashback-database.md) - [`FLASHBACK TABLE`](/sql-statements/sql-statement-flashback-table.md) - [`FLUSH PRIVILEGES`](/sql-statements/sql-statement-flush-privileges.md) - [`FLUSH STATUS`](/sql-statements/sql-statement-flush-status.md) @@ -296,11 +301,13 @@ - [`GRANT `](/sql-statements/sql-statement-grant-role.md) - [`INSERT`](/sql-statements/sql-statement-insert.md) - [`KILL [TIDB]`](/sql-statements/sql-statement-kill.md) + - [`LOCK STATS`](/sql-statements/sql-statement-lock-stats.md) - [`MODIFY COLUMN`](/sql-statements/sql-statement-modify-column.md) - [`PREPARE`](/sql-statements/sql-statement-prepare.md) - [`RECOVER TABLE`](/sql-statements/sql-statement-recover-table.md) - [`RENAME INDEX`](/sql-statements/sql-statement-rename-index.md) - [`RENAME TABLE`](/sql-statements/sql-statement-rename-table.md) + - [`RENAME USER`](/sql-statements/sql-statement-rename-user.md) - [`REPLACE`](/sql-statements/sql-statement-replace.md) - [`REVOKE `](/sql-statements/sql-statement-revoke-privileges.md) - [`REVOKE `](/sql-statements/sql-statement-revoke-role.md) @@ -319,6 +326,7 @@ - [`SHOW CHARACTER SET`](/sql-statements/sql-statement-show-character-set.md) - [`SHOW COLLATION`](/sql-statements/sql-statement-show-collation.md) - [`SHOW [FULL] COLUMNS FROM`](/sql-statements/sql-statement-show-columns-from.md) + - [`SHOW CREATE DATABASE`](/sql-statements/sql-statement-show-create-database.md) - [`SHOW CREATE SEQUENCE`](/sql-statements/sql-statement-show-create-sequence.md) - [`SHOW CREATE TABLE`](/sql-statements/sql-statement-show-create-table.md) - [`SHOW CREATE USER`](/sql-statements/sql-statement-show-create-user.md) @@ -340,6 +348,7 @@ - [`SHOW SCHEMAS`](/sql-statements/sql-statement-show-schemas.md) - [`SHOW STATS_HEALTHY`](/sql-statements/sql-statement-show-stats-healthy.md) - [`SHOW STATS_HISTOGRAMS`](/sql-statements/sql-statement-show-histograms.md) + - [`SHOW STATS_LOCKED`](/sql-statements/sql-statement-show-stats-locked.md) - [`SHOW STATS_META`](/sql-statements/sql-statement-show-stats-meta.md) - [`SHOW STATUS`](/sql-statements/sql-statement-show-status.md) - [`SHOW TABLE NEXT_ROW_ID`](/sql-statements/sql-statement-show-table-next-rowid.md) @@ -354,6 +363,7 @@ - [`TABLE`](/sql-statements/sql-statement-table.md) - [`TRACE`](/sql-statements/sql-statement-trace.md) - [`TRUNCATE`](/sql-statements/sql-statement-truncate.md) + - [`UNLOCK STATS`](/sql-statements/sql-statement-unlock-stats.md) - [`UPDATE`](/sql-statements/sql-statement-update.md) - [`USE`](/sql-statements/sql-statement-use.md) - [`WITH`](/sql-statements/sql-statement-with.md) @@ -408,6 +418,7 @@ - [Usage Scenarios of Stale Read](/stale-read.md) - [Perform Stale Read Using `As OF TIMESTAMP`](/as-of-timestamp.md) - [Perform Stale Read Using `tidb_read_staleness`](/tidb-read-staleness.md) + - [Perform Stale Read Using `tidb_external_ts`](/tidb-external-ts.md) - [Use the `tidb_snapshot` System Variable](/read-historical-data.md) - System Tables - [`mysql`](/mysql-schema.md) @@ -427,6 +438,8 @@ - [`DEADLOCKS`](/information-schema/information-schema-deadlocks.md) - [`ENGINES`](/information-schema/information-schema-engines.md) - [`KEY_COLUMN_USAGE`](/information-schema/information-schema-key-column-usage.md) + - [`MEMORY_USAGE`](/information-schema/information-schema-memory-usage.md) + - [`MEMORY_USAGE_OPS_HISTORY`](/information-schema/information-schema-memory-usage-ops-history.md) - [`PARTITIONS`](/information-schema/information-schema-partitions.md) - [`PROCESSLIST`](/information-schema/information-schema-processlist.md) - [`REFERENTIAL_CONSTRAINTS`](/information-schema/information-schema-referential-constraints.md) @@ -446,9 +459,12 @@ - [`TIKV_REGION_PEERS`](/information-schema/information-schema-tikv-region-peers.md) - [`TIKV_REGION_STATUS`](/information-schema/information-schema-tikv-region-status.md) - [`TIKV_STORE_STATUS`](/information-schema/information-schema-tikv-store-status.md) + - [`USER_ATTRIBUTES`](/information-schema/information-schema-user-attributes.md) - [`USER_PRIVILEGES`](/information-schema/information-schema-user-privileges.md) + - [`VARIABLES_INFO`](/information-schema/information-schema-variables-info.md) - [`VIEWS`](/information-schema/information-schema-views.md) - [Metadata Lock](/metadata-lock.md) + - [Use UUIDs](/best-practices/uuid.md) - [System Variables](/system-variables.md) - Storage Engines - TiKV diff --git a/best-practices/uuid.md b/best-practices/uuid.md index 1f2f6d4c2c302..34c6308db8222 100644 --- a/best-practices/uuid.md +++ b/best-practices/uuid.md @@ -21,14 +21,36 @@ The textual UUID format looks like this: `ab06f63e-8fe7-11ec-a514-5405db7aad56`, ### UUID format binary order and a clustered PK -The `UUID_TO_BIN()` function can be used with one argument, the UUID or with two arguments where the second argument is a `swap_flag`. It is recommended to not set the `swap_flag` with TiDB to avoid [hotspots](/best-practices/high-concurrency-best-practices.md). +The `UUID_TO_BIN()` function can be used with one argument, the UUID or with two arguments where the second argument is a `swap_flag`. + + + +It is recommended to not set the `swap_flag` with TiDB to avoid [hotspots](/best-practices/high-concurrency-best-practices.md). + + + + + +It is recommended to not set the `swap_flag` with TiDB to avoid hotspots. + + You can also explicitly set the [`CLUSTERED` option](/clustered-indexes.md) for UUID based primary keys to avoid hotspots. To demonstrate the effect of the `swap_flag`, here are two tables with an identical structure. The difference is that the data inserted into `uuid_demo_1` uses `UUID_TO_BIN(?, 0)` and `uuid_demo_2` uses `UUID_TO_BIN(?, 1)`. + + In the screenshot of the [Key Visualizer](/dashboard/dashboard-key-visualizer.md) below, you can see that writes are concentrated in a single region of the `uuid_demo_2` table that has the order of the fields swapped in the binary format. + + + + +In the screenshot of the [Key Visualizer](/tidb-cloud/tune-performance.md#key-visualizer) below, you can see that writes are concentrated in a single region of the `uuid_demo_2` table that has the order of the fields swapped in the binary format. + + + ![Key Visualizer](/media/best-practices/uuid_keyviz.png) ```sql diff --git a/develop/dev-guide-choose-driver-or-orm.md b/develop/dev-guide-choose-driver-or-orm.md index bdab02b929573..fa5570502f9f8 100644 --- a/develop/dev-guide-choose-driver-or-orm.md +++ b/develop/dev-guide-choose-driver-or-orm.md @@ -247,3 +247,9 @@ go get -u gorm.io/driver/mysql ``` For an example of using GORM to build a TiDB application, see [Build a Simple CRUD App with TiDB and Golang](/develop/dev-guide-sample-application-golang.md). + + + +After you have determined the driver or ORM, you can [connect to your TiDB cluster](https://docs.pingcap.com/tidbcloud/connect-to-tidb-cluster). + + diff --git a/explain-subqueries.md b/explain-subqueries.md index 72180298c4aef..7558e01f67155 100644 --- a/explain-subqueries.md +++ b/explain-subqueries.md @@ -267,9 +267,4 @@ Currently, TiDB can only be null-aware of anti semi join and anti left outer sem + [Explain Statements That Use Aggregation](/explain-aggregation.md) + [Explain Statements Using Views](/explain-views.md) + [Explain Statements Using Partitions](/explain-partitions.md) - - - -+ [Explain Statements Using Index Merge](/explain-index-merge.md) - - ++ [Explain Statements Using Index Merge](/explain-index-merge.md) \ No newline at end of file diff --git a/information-schema/information-schema.md b/information-schema/information-schema.md index 96db8f13848c1..53f7b7dbcc3ec 100644 --- a/information-schema/information-schema.md +++ b/information-schema/information-schema.md @@ -87,7 +87,9 @@ Many `INFORMATION_SCHEMA` tables have a corresponding `SHOW` command. The benefi | [`TABLE_CONSTRAINTS`](/information-schema/information-schema-table-constraints.md) | Provides information on primary keys, unique indexes and foreign keys. | | `TABLE_PRIVILEGES` | Not implemented by TiDB. Returns zero rows. | | `TRIGGERS` | Not implemented by TiDB. Returns zero rows. | +| [`USER_ATTRIBUTES`](/information-schema/information-schema-user-attributes.md) | Summarizes information about user comments and user attributes. | | [`USER_PRIVILEGES`](/information-schema/information-schema-user-privileges.md) | Summarizes the privileges associated with the current user. | +| [`VARIABLES_INFO`](/information-schema/information-schema-variables-info.md) | Provides information about TiDB system variables. | | [`VIEWS`](/information-schema/information-schema-views.md) | Provides a list of views that the current user has visibility of. Similar to running `SHOW FULL TABLES WHERE table_type = 'VIEW'` | @@ -102,38 +104,38 @@ Many `INFORMATION_SCHEMA` tables have a corresponding `SHOW` command. The benefi | [`CLIENT_ERRORS_SUMMARY_BY_HOST`](/information-schema/client-errors-summary-by-host.md) | Provides a summary of errors and warnings generated by client requests and returned to clients. | | [`CLIENT_ERRORS_SUMMARY_BY_USER`](/information-schema/client-errors-summary-by-user.md) | Provides a summary of errors and warnings generated by clients. | | [`CLIENT_ERRORS_SUMMARY_GLOBAL`](/information-schema/client-errors-summary-global.md) | Provides a summary of errors and warnings generated by clients. | -| [`CLUSTER_CONFIG`](https://docs.pingcap.com/tidb/stable/information-schema-cluster-config) | Provides details about configuration settings for the entire TiDB cluster. This table is not applicable to TiDB Cloud. | +| [`CLUSTER_CONFIG`](/information-schema/information-schema-cluster-config.md) | Provides details about configuration settings for the entire TiDB cluster.| | `CLUSTER_DEADLOCKS` | Provides a cluster-level view of the `DEADLOCKS` table. | -| [`CLUSTER_HARDWARE`](https://docs.pingcap.com/tidb/stable/information-schema-cluster-hardware) | Provides details on the underlying physical hardware discovered on each TiDB component. This table is not applicable to TiDB Cloud. | +| [`CLUSTER_HARDWARE`](/information-schema/information-schema-cluster-hardware.md) | Provides details on the underlying physical hardware discovered on each TiDB component. | | [`CLUSTER_INFO`](/information-schema/information-schema-cluster-info.md) | Provides details on the current cluster topology. | -| [`CLUSTER_LOAD`](https://docs.pingcap.com/tidb/stable/information-schema-cluster-load) | Provides current load information for TiDB servers in the cluster. This table is not applicable to TiDB Cloud. | -| [`CLUSTER_LOG`](https://docs.pingcap.com/tidb/stable/information-schema-cluster-log) | Provides a log for the entire TiDB cluster. This table is not applicable to TiDB Cloud. | -| `CLUSTER_MEMORY_USAGE` | Provides a cluster-level view of the `MEMORY_USAGE` table. This table is not applicable to TiDB Cloud. | -| `CLUSTER_MEMORY_USAGE_OPS_HISTORY` | Provides a cluster-level view of the `MEMORY_USAGE_OPS_HISTORY` table. This table is not applicable to TiDB Cloud. | +| [`CLUSTER_LOAD`](/information-schema/information-schema-cluster-load.md) | Provides current load information for TiDB servers in the cluster. | +| [`CLUSTER_LOG`](/information-schema/information-schema-cluster-log.md) | Provides a log for the entire TiDB cluster. | +| `CLUSTER_MEMORY_USAGE` | Provides a cluster-level view of the `MEMORY_USAGE` table. | +| `CLUSTER_MEMORY_USAGE_OPS_HISTORY` | Provides a cluster-level view of the `MEMORY_USAGE_OPS_HISTORY` table. | | `CLUSTER_PROCESSLIST` | Provides a cluster-level view of the `PROCESSLIST` table. | | `CLUSTER_SLOW_QUERY` | Provides a cluster-level view of the `SLOW_QUERY` table. | | `CLUSTER_STATEMENTS_SUMMARY` | Provides a cluster-level view of the `STATEMENTS_SUMMARY` table. | | `CLUSTER_STATEMENTS_SUMMARY_HISTORY` | Provides a cluster-level view of the `STATEMENTS_SUMMARY_HISTORY` table. | | `CLUSTER_TIDB_TRX` | Provides a cluster-level view of the `TIDB_TRX` table. | -| [`CLUSTER_SYSTEMINFO`](https://docs.pingcap.com/tidb/stable/information-schema-cluster-systeminfo) | Provides details about kernel parameter configuration for servers in the cluster. This table is not applicable to TiDB Cloud. | +| [`CLUSTER_SYSTEMINFO`](/information-schema/information-schema-cluster-systeminfo.md) | Provides details about kernel parameter configuration for servers in the cluster. | | [`DATA_LOCK_WAITS`](/information-schema/information-schema-data-lock-waits.md) | Provides the lock-waiting information on the TiKV server. | | [`DDL_JOBS`](/information-schema/information-schema-ddl-jobs.md) | Provides similar output to `ADMIN SHOW DDL JOBS` | | [`DEADLOCKS`](/information-schema/information-schema-deadlocks.md) | Provides the information of several deadlock errors that have recently occurred. | -| [`INSPECTION_RESULT`](https://docs.pingcap.com/tidb/stable/information-schema-inspection-result) | Triggers internal diagnostics checks. This table is not applicable to TiDB Cloud. | -| [`INSPECTION_RULES`](https://docs.pingcap.com/tidb/stable/information-schema-inspection-rules) | A list of internal diagnostic checks performed. This table is not applicable to TiDB Cloud. | -| [`INSPECTION_SUMMARY`](https://docs.pingcap.com/tidb/stable/information-schema-inspection-summary) | A summarized report of important monitoring metrics. This table is not applicable to TiDB Cloud. | -| [`MEMORY_USAGE`](/information-schema/information-schema-memory-usage.md) | The memory usage of the current TiDB instance. This table is not applicable to TiDB Cloud. | -| [`MEMORY_USAGE_OPS_HISTORY`](/information-schema/information-schema-memory-usage-ops-history.md) | The history of memory-related operations and the execution basis of the current TiDB instance. This table is not applicable to TiDB Cloud. | -| [`METRICS_SUMMARY`](https://docs.pingcap.com/tidb/stable/information-schema-metrics-summary) | A summary of metrics extracted from Prometheus. This table is not applicable to TiDB Cloud. | +| [`INSPECTION_RESULT`](/information-schema/information-schema-inspection-result.md) | Triggers internal diagnostics checks. | +| [`INSPECTION_RULES`](/information-schema/information-schema-inspection-rules.md) | A list of internal diagnostic checks performed. | +| [`INSPECTION_SUMMARY`](/information-schema/information-schema-inspection-summary.md) | A summarized report of important monitoring metrics. | +| [`MEMORY_USAGE`](/information-schema/information-schema-memory-usage.md) | The memory usage of the current TiDB instance. | +| [`MEMORY_USAGE_OPS_HISTORY`](/information-schema/information-schema-memory-usage-ops-history.md) | The history of memory-related operations and the execution basis of the current TiDB instance. | +| [`METRICS_SUMMARY`](/information-schema/information-schema-metrics-summary.md) | A summary of metrics extracted from Prometheus. | | `METRICS_SUMMARY_BY_LABEL` | See `METRICS_SUMMARY` table. | -| [`METRICS_TABLES`](https://docs.pingcap.com/tidb/stable/information-schema-metrics-tables) | Provides the PromQL definitions for tables in `METRICS_SCHEMA`. This table is not applicable to TiDB Cloud. | -| [`PLACEMENT_POLICIES`](https://docs.pingcap.com/tidb/stable/information-schema-placement-policies) | Provides information on all placement policies. This table is not applicable to TiDB Cloud. | +| [`METRICS_TABLES`](/information-schema/information-schema-metrics-tables.md) | Provides the PromQL definitions for tables in `METRICS_SCHEMA`. | +| [`PLACEMENT_POLICIES`](/information-schema/information-schema-placement-policies.md) | Provides information on all placement policies. | | [`SEQUENCES`](/information-schema/information-schema-sequences.md) | The TiDB implementation of sequences is based on MariaDB. | | [`SLOW_QUERY`](/information-schema/information-schema-slow-query.md) | Provides information on slow queries on the current TiDB server. | | [`STATEMENTS_SUMMARY`](/statement-summary-tables.md) | Similar to performance_schema statement summary in MySQL. | | [`STATEMENTS_SUMMARY_HISTORY`](/statement-summary-tables.md) | Similar to performance_schema statement summary history in MySQL. | | [`TABLE_STORAGE_STATS`](/information-schema/information-schema-table-storage-stats.md) | Provides details about table sizes in storage. | -| [`TIDB_HOT_REGIONS`](https://docs.pingcap.com/tidb/stable/information-schema-tidb-hot-regions) | Provides statistics about which regions are hot. This table is not applicable to TiDB Cloud. | +| [`TIDB_HOT_REGIONS`](/information-schema/information-schema-tidb-hot-regions.md) | Provides statistics about which regions are hot. | | [`TIDB_HOT_REGIONS_HISTORY`](/information-schema/information-schema-tidb-hot-regions-history.md) | Provides history statistics about which Regions are hot. | | [`TIDB_INDEXES`](/information-schema/information-schema-tidb-indexes.md) | Provides index information about TiDB tables. | | [`TIDB_SERVERS_INFO`](/information-schema/information-schema-tidb-servers-info.md) | Provides a list of TiDB servers (namely, tidb-server component) | @@ -144,6 +146,7 @@ Many `INFORMATION_SCHEMA` tables have a corresponding `SHOW` command. The benefi | [`TIKV_STORE_STATUS`](/information-schema/information-schema-tikv-store-status.md) | Provides basic information about TiKV servers. | + | Table Name | Description | @@ -158,6 +161,8 @@ Many `INFORMATION_SCHEMA` tables have a corresponding `SHOW` command. The benefi | [`CLUSTER_INFO`](/information-schema/information-schema-cluster-info.md) | Provides details on the current cluster topology. | | [`CLUSTER_LOAD`](https://docs.pingcap.com/tidb/stable/information-schema-cluster-load) | Provides current load information for TiDB servers in the cluster. This table is not applicable to TiDB Cloud. | | [`CLUSTER_LOG`](https://docs.pingcap.com/tidb/stable/information-schema-cluster-log) | Provides a log for the entire TiDB cluster. This table is not applicable to TiDB Cloud. | +| `CLUSTER_MEMORY_USAGE` | Provides a cluster-level view of the `MEMORY_USAGE` table. This table is not applicable to TiDB Cloud. | +| `CLUSTER_MEMORY_USAGE_OPS_HISTORY` | Provides a cluster-level view of the `MEMORY_USAGE_OPS_HISTORY` table. This table is not applicable to TiDB Cloud. | | `CLUSTER_PROCESSLIST` | Provides a cluster-level view of the `PROCESSLIST` table. | | `CLUSTER_SLOW_QUERY` | Provides a cluster-level view of the `SLOW_QUERY` table. | | `CLUSTER_STATEMENTS_SUMMARY` | Provides a cluster-level view of the `STATEMENTS_SUMMARY` table. | @@ -170,6 +175,8 @@ Many `INFORMATION_SCHEMA` tables have a corresponding `SHOW` command. The benefi | [`INSPECTION_RESULT`](https://docs.pingcap.com/tidb/stable/information-schema-inspection-result) | Triggers internal diagnostics checks. This table is not applicable to TiDB Cloud. | | [`INSPECTION_RULES`](https://docs.pingcap.com/tidb/stable/information-schema-inspection-rules) | A list of internal diagnostic checks performed. This table is not applicable to TiDB Cloud. | | [`INSPECTION_SUMMARY`](https://docs.pingcap.com/tidb/stable/information-schema-inspection-summary) | A summarized report of important monitoring metrics. This table is not applicable to TiDB Cloud. | +| [`MEMORY_USAGE`](/information-schema/information-schema-memory-usage.md) | The memory usage of the current TiDB instance. | +| [`MEMORY_USAGE_OPS_HISTORY`](/information-schema/information-schema-memory-usage-ops-history.md) | The history of memory-related operations and the execution basis of the current TiDB instance. | | [`METRICS_SUMMARY`](https://docs.pingcap.com/tidb/stable/information-schema-metrics-summary) | A summary of metrics extracted from Prometheus. This table is not applicable to TiDB Cloud. | | `METRICS_SUMMARY_BY_LABEL` | See `METRICS_SUMMARY` table. | | [`METRICS_TABLES`](https://docs.pingcap.com/tidb/stable/information-schema-metrics-tables) | Provides the PromQL definitions for tables in `METRICS_SCHEMA`. This table is not applicable to TiDB Cloud. | diff --git a/optimizer-hints.md b/optimizer-hints.md index 53351fc1dae15..357a0749423c4 100644 --- a/optimizer-hints.md +++ b/optimizer-hints.md @@ -368,18 +368,8 @@ select /*+ READ_FROM_STORAGE(TIFLASH[t1], TIKV[t2]) */ t1.a from t t1, t t2 wher ### USE_INDEX_MERGE(t1_name, idx1_name [, idx2_name ...]) - - The `USE_INDEX_MERGE(t1_name, idx1_name [, idx2_name ...])` hint tells the optimizer to access a specific table with the index merge method. Index merge has two types: intersection type and union type. For details, see [Explain Statements Using Index Merge](/explain-index-merge.md). - - - - -The `USE_INDEX_MERGE(t1_name, idx1_name [, idx2_name ...])` hint tells the optimizer to access a specific table with the index merge method. Index merge has two types: intersection type and union type. - - - If you explicitly specify the list of indexes, TiDB selects indexes from the list to build index merge; if you do not specify the list of indexes, TiDB selects indexes from all available indexes to build index merge. For the intersection-type index merge, the given list of indexes is a required parameter in the hint. For the union-type index merge, the given list of indexes is an optional parameter in the hint. See the following example. diff --git a/sql-prepared-plan-cache.md b/sql-prepared-plan-cache.md index 2831a4e24f994..ebfffc30fe440 100644 --- a/sql-prepared-plan-cache.md +++ b/sql-prepared-plan-cache.md @@ -142,6 +142,7 @@ The following is an example of the **Plan Cache Memory Usage** and **Plan Cache You can control the maximum number of plans that can be cached in each session by configuring the system variable `tidb_prepared_plan_cache_size`. For different environments, the recommended value is as follows and you can adjust it according to the monitoring panels: + Using Prepared Plan Cache has some memory overhead. In internal tests, each cached plan consumes an average of 100 KiB of memory. Because Plan Cache is currently at the `SESSION` level, the total memory consumption is approximately `the number of sessions * the average number of cached plans in a session * 100 KiB`. @@ -287,12 +288,18 @@ mysql> select @@last_plan_from_cache; -- Reuse the last plan 1 row in set (0.00 sec) ``` - - ### Monitoring + + In [the Grafana dashboard](/grafana-tidb-dashboard.md) on the TiDB page in the **Executor** section, there are the "Queries Using Plan Cache OPS" and "Plan Cache Miss OPS" graphs. These graphs can be used to check if both TiDB and the application are configured correctly to allow the SQL Plan Cache to work correctly. The **Server** section on the same page provides the "Prepared Statement Count" graph. This graph shows a non-zero value if the application uses prepared statements, which is required for the SQL Plan Cache to function correctly. ![`sql_plan_cache`](/media/performance/sql_plan_cache.png) + + + +On the [**Monitoring**](/tidb-cloud/built-in-monitoring.md) page of the [TiDB Cloud console](https://tidbcloud.com/), you can check the `Queries Using Plan Cache OPS` metric to get the number of queries using or missing plan cache per second in all TiDB instances. + + diff --git a/sql-statements/sql-statement-commit.md b/sql-statements/sql-statement-commit.md index b7dba08391ffe..8543ab83a54bf 100644 --- a/sql-statements/sql-statement-commit.md +++ b/sql-statements/sql-statement-commit.md @@ -39,12 +39,7 @@ Query OK, 0 rows affected (0.01 sec) ## MySQL compatibility - - * Currently, TiDB use Metadata Locking (MDL) to prevent DDL statements from modifying tables used by transactions by default. The behavior of metadata lock is different between TiDB and MySQL. For more details, see [Metadata Lock](/metadata-lock.md). - - - * By default, TiDB 3.0.8 and later versions use [Pessimistic Locking](/pessimistic-transaction.md). When using [Optimistic Locking](/optimistic-transaction.md), it is important to consider that a `COMMIT` statement might fail because rows have been modified by another transaction. * When Optimistic Locking is enabled, `UNIQUE` and `PRIMARY KEY` constraint checks are deferred until statement commit. This results in additional situations where a a `COMMIT` statement might fail. This behavior can be changed by setting `tidb_constraint_check_in_place=ON`. * TiDB parses but ignores the syntax `ROLLBACK AND [NO] RELEASE`. This functionality is used in MySQL to disconnect the client session immediately after committing the transaction. In TiDB, it is recommended to instead use the `mysql_close()` functionality of your client driver. diff --git a/sql-statements/sql-statement-flashback-to-timestamp.md b/sql-statements/sql-statement-flashback-to-timestamp.md index 06187d53e79df..4d2bbce6573aa 100644 --- a/sql-statements/sql-statement-flashback-to-timestamp.md +++ b/sql-statements/sql-statement-flashback-to-timestamp.md @@ -7,6 +7,14 @@ summary: Learn the usage of FLASHBACK CLUSTER TO TIMESTAMP in TiDB databases. TiDB v6.4.0 introduces the `FLASHBACK CLUSTER TO TIMESTAMP` syntax. You can use it to restore a cluster to a specific point in time. + + +> **Warning:** +> +> The `FLASHBACK CLUSTER TO TIMESTAMP` syntax is not applicable to TiDB Cloud [Serverless Tier](/tidb-cloud/select-cluster-tier.md#serverless-tier-beta) clusters. Do not execute this statement on Serverless Tier clusters to avoid unexpected results. + + + > **Note:** > > The working principle of `FLASHBACK CLUSTER TO TIMESTAMP` is to write the old data of a specific point in time with the latest timestamp, and will not delete the current data. So before using this feature, you need to ensure that there is enough storage space for the old data and the current data. diff --git a/sql-statements/sql-statement-rollback.md b/sql-statements/sql-statement-rollback.md index 9a8090c92fc4c..5a08335a17243 100644 --- a/sql-statements/sql-statement-rollback.md +++ b/sql-statements/sql-statement-rollback.md @@ -45,12 +45,7 @@ Empty set (0.01 sec) ## See also - - * [SAVEPOINT](/sql-statements/sql-statement-savepoint.md) - - - * [COMMIT](/sql-statements/sql-statement-commit.md) * [BEGIN](/sql-statements/sql-statement-begin.md) * [START TRANSACTION](/sql-statements/sql-statement-start-transaction.md) diff --git a/stale-read.md b/stale-read.md index 8b16e42fb8e09..60b0a8c35afe3 100644 --- a/stale-read.md +++ b/stale-read.md @@ -35,8 +35,4 @@ TiDB provides the methods of performing Stale Read at the statement level, the s - Session level - Specifying a time range: In a session, if you need TiDB to read the data as new as possible within a time range in subsequent queries without violating the isolation level, you can specify the time range by setting the `tidb_read_staleness` system variable. For detailed usage, refer to [`tidb_read_staleness`](/tidb-read-staleness.md). - - Besides, TiDB provides a way to specify an exact point in time by setting the [`tidb_external_ts`](/system-variables.md#tidb_external_ts-new-in-v640) system variable on session or global level. For detailed usage, refer to [Perform Stale Read Using `tidb_external_ts`](/tidb-external-ts.md). - - diff --git a/statistics.md b/statistics.md index 8e6e3718767f4..f3e378f8566ad 100644 --- a/statistics.md +++ b/statistics.md @@ -864,14 +864,9 @@ mysql> show warnings; * [LOAD STATS](/sql-statements/sql-statement-load-stats.md) * [DROP STATS](/sql-statements/sql-statement-drop-stats.md) -* [LOCK STATS](/sql-statements/sql-statement-lock-stats.md) -* [UNLOCK STATS](/sql-statements/sql-statement-unlock-stats.md) -* [SHOW STATS_LOCKED](/sql-statements/sql-statement-show-stats-locked.md) - - -* [SQL Prepare Execution Plan Cache](/sql-prepared-plan-cache.md) - - +* [LOCK STATS](/sql-statements/sql-statement-lock-stats.md) +* [UNLOCK STATS](/sql-statements/sql-statement-unlock-stats.md) +* [SHOW STATS_LOCKED](/sql-statements/sql-statement-show-stats-locked.md) diff --git a/system-variables.md b/system-variables.md index 47a132a549014..6a9034a86cd8e 100644 --- a/system-variables.md +++ b/system-variables.md @@ -254,7 +254,7 @@ For more possible values of this variable, see [Authentication plugin status](/s -- If you need to change the behavior of the client connection for the expired password, modify the [`security.disconnect-on-expired-password`](https://docs.pingcap.com/tidb/stable/tidb-configuration-file#disconnect-on-expired-password-new-in-v650) configuration item in the configuration file. +- If you need to change the default behavior of the client connection for the expired password, contact [TiDB Cloud Support](/tidb-cloud/tidb-cloud-support.md). @@ -1014,13 +1014,7 @@ MPP is a distributed computing framework provided by the TiFlash engine, which a - This variable only applies to pessimistic transactions. For optimistic transactions, use [`tidb_constraint_check_in_place`](#tidb_constraint_check_in_place) instead. - When this variable is set to `OFF`, TiDB defers the unique constraint check of a unique index (to the next time when executing a statement that requires a lock to the index or to the time when committing the transaction). This helps improve performance but might be an unexpected behavior for some applications. See [Constraints](/constraints.md#pessimistic-transactions) for details. - Disabling this variable might cause TiDB to return a `LazyUniquenessCheckFailure` error in pessimistic transactions. When this error occurs, TiDB rolls back the current transaction. - - - - When this variable is disabled, you cannot use [`SAVEPOINT`](/sql-statements/sql-statement-savepoint.md) in pessimistic transactions. - - - - When this variable is disabled, committing a pessimistic transaction might return a `Write conflict` or `Duplicate entry` error. When such an error occurs, TiDB rolls back the current transaction. - When setting `tidb_constraint_check_in_place_pessimistic` to `OFF` and using pessimistic transactions: @@ -1085,6 +1079,14 @@ MPP is a distributed computing framework provided by the TiFlash engine, which a ### tidb_ddl_disk_quota New in v6.3.0 + + +> **Note:** +> +> This TiDB variable is not applicable to TiDB Cloud. Do not change the default value of this variable for TiDB Cloud. + + + - Scope: GLOBAL - Persists to cluster: Yes - Type: Integer @@ -1095,6 +1097,14 @@ MPP is a distributed computing framework provided by the TiFlash engine, which a ### tidb_ddl_enable_fast_reorg New in v6.3.0 + + +> **Note:** +> +> To improve the speed for index creation using this variable, make sure that your TiDB cluster is hosted on AWS and your TiDB node size is at least 8 vCPU. For [Serverless Tier](/tidb-cloud/select-cluster-tier.md#serverless-tier-beta) clusters, this feature is unavailable. + + + - Scope: GLOBAL - Persists to cluster: Yes - Type: Boolean @@ -1109,7 +1119,21 @@ MPP is a distributed computing framework provided by the TiFlash engine, which a > > Currently, this feature is not fully compatible with [altering multiple columns or indexes in a single `ALTER TABLE` statement](/sql-statements/sql-statement-alter-table.md). When adding a unique index with the index acceleration, you need to avoid altering other columns or indexes in the same statement. > -> When [PITR (Point-in-time recovery)](/br/backup-and-restore-overview.md) is disabled, the speed of adding indexes is expected to be about 10 times than that in v6.1.0. However, there is no performance improvement when both PITR and index acceleration are enabled. To optimize performance, it is recommended that you disable PITR, add indexes in a quick way, then enable PITR and perform a full backup. Otherwise, three expected behaviors might occur: +> When [PITR (Point-in-time recovery)](/br/backup-and-restore-overview.md) is disabled, the speed of adding indexes is expected to be about 10 times that in v6.1.0. However, there is no performance improvement when both PITR and index acceleration are enabled. To optimize performance, it is recommended that you disable PITR, add indexes in a quick way, then enable PITR and perform a full backup. Otherwise, the following behaviors might occur: +> +> - When PITR starts working first, the index adding job automatically falls back to the legacy mode by default, even if the configuration is set to `ON`. The index is added slowly. +> - When the index adding job starts first, it prevents the log backup job of PITR from starting by throwing an error, which does not affect the index adding job in progress. After the index adding job is completed, you need to restart the log backup job and perform a full backup manually. +> - When a log backup job of PITR and an index adding job start at the same time, no error is prompted because the two jobs are unable to detect each other. PITR does not back up the newly added index. After the index adding job is completed, you still need to restart the log backup job and perform a full backup manually. + + + + + +> **Warning:** +> +> Currently, this feature is not fully compatible with [altering multiple columns or indexes in a single `ALTER TABLE` statement](/sql-statements/sql-statement-alter-table.md). When adding a unique index with the index acceleration, you need to avoid altering other columns or indexes in the same statement. +> +> When [PITR (Point-in-time recovery)](/tidb-cloud/backup-and-restore.md) is disabled, the speed of adding indexes is expected to be about 10 times that in v6.1.0. However, there is no performance improvement when both PITR and index acceleration are enabled. To optimize performance, it is recommended that you disable PITR, add indexes in a quick way, then enable PITR and perform a full backup. Otherwise, the following expected behaviors might occur: > > - When PITR starts working first, the index adding job automatically falls back to the legacy mode by default, even if the configuration is set to `ON`. The index is added slowly. > - When the index adding job starts first, it prevents the log backup job of PITR from starting by throwing an error, which does not affect the index adding job in progress. After the index adding job is completed, you need to restart the log backup job and perform a full backup manually. @@ -1133,13 +1157,8 @@ MPP is a distributed computing framework provided by the TiFlash engine, which a - Type: Integer - Default value: `64` - Range: `[1, 256]` - - - - This variable controls the concurrency of [`FLASHBACK CLUSTER TO TIMESTAMP`](/sql-statements/sql-statement-flashback-to-timestamp.md). - - ### tidb_ddl_reorg_batch_size - Scope: GLOBAL @@ -1444,24 +1463,12 @@ MPP is a distributed computing framework provided by the TiFlash engine, which a ### tidb_enable_extended_stats - - -> **Note:** -> -> This TiDB variable is not applicable to TiDB Cloud. - - - - - - Scope: SESSION | GLOBAL - Persists to cluster: Yes - Type: Boolean - Default value: `OFF` - This variable indicates whether TiDB can collect the extended statistic to guide the optimizer. See [Introduction to Extended Statistics](/extended-statistics.md) for more information. - - ### tidb_enable_external_ts_read New in v6.4.0 - Scope: SESSION | GLOBAL @@ -1599,13 +1606,8 @@ MPP is a distributed computing framework provided by the TiFlash engine, which a - Persists to cluster: Yes - Type: Boolean - Default value: `ON` - - - - This variable is used to set whether to enable the [Metadata lock](/metadata-lock.md) feature. Note that when setting this variable, you need to make sure that there are no running DDL statements in the cluster. Otherwise, the data might be incorrect or inconsistent. - - ### tidb_enable_mutation_checker New in v6.0.0 - Scope: SESSION | GLOBAL @@ -3747,6 +3749,12 @@ For details, see [Identify Slow Queries](/identify-slow-queries.md). + + +- This variable is used to configure the different cluster IDs in a [bi-directional replication](https://docs.pingcap.com/tidb/stable/ticdc-bidirectional-replication) cluster. + + + ### tidb_stats_cache_mem_quota New in v6.1.0 > **Warning:** @@ -4204,13 +4212,8 @@ For details, see [Identify Slow Queries](/identify-slow-queries.md). - Scope: SESSION | GLOBAL - Default value: `OFF` - Type: Boolean - - - - If [FastScan](/develop/dev-guide-use-fastscan.md) is enabled (set to `ON`), TiFlash provides more efficient query performance, but does not guarantee the accuracy of the query results or data consistency. - - ### `tiflash_fine_grained_shuffle_batch_size` New in v6.2.0 - Scope: SESSION | GLOBAL diff --git a/tidb-cloud/serverless-tier-limitations.md b/tidb-cloud/serverless-tier-limitations.md index 87242be79213d..61607e1e0ea48 100644 --- a/tidb-cloud/serverless-tier-limitations.md +++ b/tidb-cloud/serverless-tier-limitations.md @@ -19,6 +19,11 @@ We are constantly filling in the feature gaps between Serverless Tier and Dedica - The compute resource is limited to 1 vCPU and 1 GiB RAM. - **Note**: In the coming months, we intend to offer a usage-based billing plan for additional resources and higher performance, while still keeping offering the free starter plan. In the coming releases, the limitations of the free Serverless Tier might be changed. +## SQL + +- [Time to live (TTL)](/time-to-live.md) is not available for Serverless Tier clusters currently. +- The [`FLASHBACK CLUSTER TO TIMESTAMP`](/sql-statements/sql-statement-flashback-to-timestamp.md) syntax is not applicable to TiDB Cloud [Serverless Tier](/tidb-cloud/select-cluster-tier.md#serverless-tier-beta) clusters. + ## Transaction - The total size of a single transaction is set to no more than 10 MB on Serverless Tier during the beta phase.