You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ydb/docs/en/core/reference/ydb-cli/export-import/_includes/tools_dump.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -51,7 +51,7 @@ The `tools dump` command dumps the schema objects to the client file system in t
51
51
-`database`: A fully consistent dump, with one snapshot taken before starting the dump. Applied by default.
52
52
-`table`: Consistency within each dumped table, taking individual independent snapshots for each table. Might run faster and have less impact on the current workload processing in the database.
53
53
54
-
-`--avoid-copy`: Do not create a snapshot before dumping. The default consistency snapshot might be inapplicable in some cases (for example, for tables with external blobs).{% if feature_serial %} For correct export of tables with [serial](../../../../yql/reference/types/serial.md) types, this parameter should not be set. Otherwise, the current value of the sequence generator will not be copied, and new values will start from the initial value, which may lead to primary key conflicts.{% endif %}
54
+
-`--avoid-copy`: Do not create a snapshot before dumping. The default consistency snapshot might be inapplicable in some cases (for example, for tables with external blobs).{% if feature_serial %} For correct export of tables with [serial](../../../../yql/reference/types/serial.md) types, this parameter must not be set. Otherwise, the current value of the sequence generator will not be copied, and new values will start from the initial value, which may lead to primary key conflicts.{% endif %}
55
55
56
56
-`--save-partial-result`: Retain the result of a partial dump. Without this option, dumps that terminate with an error are deleted.
Copy file name to clipboardExpand all lines: ydb/docs/en/core/yql/reference/syntax/alter-sequence.md
+13-8Lines changed: 13 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# ALTER SEQUENCE
2
2
3
-
Modifies parameters of an existing `Sequence` object associated with a [Serial](../types/serial.md) column.
3
+
Modifies the parameters of an existing `Sequence` object associated with a [Serial](../types/serial.md) column.
4
4
5
5
## Syntax
6
6
@@ -13,19 +13,19 @@ ALTER SEQUENCE [ IF EXISTS ] path_to_sequence
13
13
14
14
## Parameters
15
15
16
-
*`path_to_sequence` — the absolute path to the `Sequence` object.
16
+
*`path_to_sequence` — the absolute path to the sequence object.
17
17
18
-
The path is constructed as `<path_to_table>/_serial_column_{column_name}`,
19
-
where `<path_to_table>` is the absolute path to the table, and `{column_name}` is the name of the `Serial`column.
18
+
The path is constructed as `<path_to_table>/_serial_column_<column_name>`,
19
+
where `<path_to_table>` is the absolute path to the table, and `<column_name>` is the name of the column with the `Serial`data type.
20
20
For example, for the column `user_id` in the table `/local/users`, the corresponding `Sequence` path will be `/local/users/_serial_column_user_id`.
21
21
22
-
*`IF EXISTS` — if used, the statement does not return an error if the `Sequence` does not exist at the specified path.
22
+
*`IF EXISTS` — when used, the statement does not return an error if the sequence does not exist at the specified path.
23
23
24
24
*`INCREMENT [ BY ] increment` — sets the increment step for the sequence. Default: 1.
25
25
26
-
*`START [ WITH ] start_value` — sets a new start value for the sequence. Changing this parameter with `ALTER SEQUENCE` does not affect the current value, but new start value will be used with `ALTER SEQUENCE RESTART` if no value is specified. Default: 1.
26
+
*`START [ WITH ] start_value` — sets a new start value for the sequence. Changing this parameter with `ALTER SEQUENCE` does not affect the current value; the new start value is used with `ALTER SEQUENCE RESTART` if no value is specified. Default: 1.
27
27
28
-
*`RESTART [ [ WITH ] restart_value ]` — sets the current value of the sequence to the specified `restart_value`. If the value is not specified, the current value will be set to the current start value.
28
+
*`RESTART [ [ WITH ] restart_value ]` — sets the current sequence value to the specified `restart_value`. If no value is specified, it sets the current value to the start value.
29
29
30
30
## Examples
31
31
@@ -52,4 +52,9 @@ An alternative way to change the current value is to first set a new start value
52
52
```yql
53
53
ALTER SEQUENCE `/Root/users/_serial_column_user_id` INCREMENT BY 5 START WITH 1000;
54
54
ALTER SEQUENCE `/Root/users/_serial_column_user_id` RESTART;
Copy file name to clipboardExpand all lines: ydb/docs/en/core/yql/reference/types/serial.md
+15-15Lines changed: 15 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Serial Types
2
2
3
-
Serial types are integer types with an associated value-generation mechanism. These types are used to create auto-increment columns: for each new row inserted into a table, a unique value for this column is generated automatically (similar to the [SERIAL](https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-SERIAL) type in PostgreSQL or the [AUTO_INCREMENT](https://dev.mysql.com/doc/refman/9.0/en/example-auto-increment.html) property in MySQL).
3
+
Serial types are integer data types with an associated value-generation mechanism. They create auto-increment columns: each new row inserted into a table automatically generates a unique value for this column (similar to the [SERIAL](https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-SERIAL) type in PostgreSQL or the [AUTO_INCREMENT](https://dev.mysql.com/doc/refman/9.0/en/example-auto-increment.html) property in MySQL).
4
4
5
5
## Description
6
6
@@ -18,16 +18,16 @@ However, such columns cannot be [altered](../syntax/alter_table/family#mod-colum
18
18
19
19
{% endnote %}
20
20
21
-
| Type | Maximum Value |YDB Type |
21
+
| Type | Maximum Value |Underlying Type |
22
22
|-------------|----------------------|----------|
23
-
| SmallSerial | 2^15–1 | Int16 |
24
-
| Serial2 | 2^15–1 | Int16 |
25
-
| Serial | 2^31–1 | Int32 |
26
-
| Serial4 | 2^31–1 | Int32 |
27
-
| Serial8 | 2^63–1 | Int64 |
28
-
| BigSerial | 2^63–1 | Int64 |
23
+
|`SmallSerial`|$2^15–1$|`Int16`|
24
+
|`Serial2`|$2^15–1$|`Int16`|
25
+
|`Serial`|$2^31–1$|`Int32`|
26
+
|`Serial4`|$2^31–1$|`Int32`|
27
+
|`Serial8`|$2^63–1$|`Int64`|
28
+
|`BigSerial`|$2^63–1$|`Int64`|
29
29
30
-
If the sequence reaches its maximum value, insertion will result in an error:
30
+
If a sequence reaches its maximum value, insertion results in an error:
31
31
32
32
```text
33
33
Error: Failed to get next val for sequence: /dev/test/users/_serial_column_user_id, status: SCHEME_ERROR
@@ -41,13 +41,13 @@ As a result, the values in such a column may have gaps and may not form a contin
41
41
42
42
{% endnote %}
43
43
44
-
Tables with `Serial` columns support [copy](../../../reference/ydb-cli/tools-copy.md), [rename](../../../reference/ydb-cli/commands/tools/rename.md), [dump](../../../reference/ydb-cli/export-import/tools-dump.md), [restore](../../../reference/ydb-cli/export-import/import-file.md), and [import](../../../reference/ydb-cli/export-import/import-s3.md)/[export](../../../reference/ydb-cli/export-import/export-s3.md) operations.
44
+
Tables with `Serial` columns support [copy](../../../reference/ydb-cli/tools-copy.md), [rename](../../../reference/ydb-cli/commands/tools/rename.md), [dump](../../../reference/ydb-cli/export-import/tools-dump.md), [restore](../../../reference/ydb-cli/export-import/import-file.md), and [import](../../../reference/ydb-cli/export-import/import-s3.md)/[export](../../../reference/ydb-cli/export-import/export-s3.md)CLI operations.
45
45
46
46
## Usage Example
47
47
48
-
You should carefully choose the columns for your [PRIMARY KEY](../../../dev/primary-key/row-oriented.md). For scalability and high performance, you should avoid writing rows with monotonically increasing primary keys. In this case, all records will go to the last partition, and all the load will target a single server.
48
+
Carefully choose the columns for your [PRIMARY KEY](../../../dev/primary-key/row-oriented.md). To ensure scalability and high performance, avoid using monotonically increasing primary keys; this pattern directs all inserts to the last partition, concentrating load on a single server.
49
49
50
-
As a recommended approach, use a hash (for example, from the whole or a part of the primary key) as the first key element, which will help evenly distribute data across cluster partitions.
50
+
Instead, use a hash of the entire primary key (or a portion of it) as the first key element to distribute data evenly across cluster partitions.
51
51
52
52
```yql
53
53
CREATE TABLE users (
@@ -59,7 +59,7 @@ CREATE TABLE users (
59
59
);
60
60
```
61
61
62
-
The `user_hash` field can be calculated on the application side, for example, by applying a hash function to the `email`.
62
+
The `user_hash` field can be calculated on the application side, for example, by applying a hash function to the `email` column.
63
63
64
64
```yql
65
65
UPSERT INTO users (user_hash, name, email) VALUES (123456789, 'Alice', 'alice@example.com');
@@ -75,7 +75,7 @@ Result (example `user_hash` values are used):
75
75
| 987654321 |`bob@example.com`| Bob | 2 |
76
76
| 111111111 |`john@example.com`| John | 3 |
77
77
78
-
You can also explicitly specify a value for the `Serial`column during insertion, for example, when restoring data. In this case, the insertion will work like with a regular integer column, and the `Sequence` will not be affected:
78
+
You can also explicitly specify a value for a column of type `Serial` during insertion, for example, when restoring data. In this case, the insertion behaves like a regular integer column, and the sequence remains unaffected:
In this example, the auto-increment column is the first and only element of the primary key. This leads to an uneven load and a bottleneck on the last partition.
95
+
In this example, the auto-increment column is the sole component of the primary key, resulting in an uneven load and creating a bottleneck on the last partition.
0 commit comments