Skip to content

Commit 5dfe15b

Browse files
shnikdblinkov
andcommitted
Apply suggestions from code review
Co-authored-by: Ivan Blinkov <ivan@blinkov.ru>
1 parent fd26392 commit 5dfe15b

File tree

3 files changed

+29
-24
lines changed

3 files changed

+29
-24
lines changed

ydb/docs/en/core/reference/ydb-cli/export-import/_includes/tools_dump.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ The `tools dump` command dumps the schema objects to the client file system in t
5151
- `database`: A fully consistent dump, with one snapshot taken before starting the dump. Applied by default.
5252
- `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.
5353

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 %}
5555

5656
- `--save-partial-result`: Retain the result of a partial dump. Without this option, dumps that terminate with an error are deleted.
5757

ydb/docs/en/core/yql/reference/syntax/alter-sequence.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ALTER SEQUENCE
22

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.
44

55
## Syntax
66

@@ -13,19 +13,19 @@ ALTER SEQUENCE [ IF EXISTS ] path_to_sequence
1313

1414
## Parameters
1515

16-
* `path_to_sequence` — the absolute path to the `Sequence` object.
16+
* `path_to_sequence` — the absolute path to the sequence object.
1717

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.
2020
For example, for the column `user_id` in the table `/local/users`, the corresponding `Sequence` path will be `/local/users/_serial_column_user_id`.
2121

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.
2323

2424
* `INCREMENT [ BY ] increment` — sets the increment step for the sequence. Default: 1.
2525

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.
2727

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.
2929

3030
## Examples
3131

@@ -52,4 +52,9 @@ An alternative way to change the current value is to first set a new start value
5252
```yql
5353
ALTER SEQUENCE `/Root/users/_serial_column_user_id` INCREMENT BY 5 START WITH 1000;
5454
ALTER SEQUENCE `/Root/users/_serial_column_user_id` RESTART;
55-
```
55+
```
56+
57+
## See also
58+
59+
* [{#T}](create-table.md)
60+
* [{#T}](../types/serial.md)

ydb/docs/en/core/yql/reference/types/serial.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Serial Types
22

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).
44

55
## Description
66

@@ -18,16 +18,16 @@ However, such columns cannot be [altered](../syntax/alter_table/family#mod-colum
1818

1919
{% endnote %}
2020

21-
| Type | Maximum Value | YDB Type |
21+
| Type | Maximum Value | Underlying Type |
2222
|-------------|----------------------|----------|
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` |
2929

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:
3131

3232
```text
3333
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
4141

4242
{% endnote %}
4343

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.
4545

4646
## Usage Example
4747

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.
4949

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.
5151

5252
```yql
5353
CREATE TABLE users (
@@ -59,7 +59,7 @@ CREATE TABLE users (
5959
);
6060
```
6161

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.
6363

6464
``` yql
6565
UPSERT INTO users (user_hash, name, email) VALUES (123456789, 'Alice', 'alice@example.com');
@@ -75,7 +75,7 @@ Result (example `user_hash` values are used):
7575
| 987654321 | `bob@example.com` | Bob | 2 |
7676
| 111111111 | `john@example.com` | John | 3 |
7777

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:
7979

8080
``` yql
8181
UPSERT INTO users (user_hash, user_id, name, email) VALUES (222222222, 10, 'Peter', 'peter@example.com');
@@ -92,4 +92,4 @@ CREATE TABLE users_bad (
9292
);
9393
```
9494

95-
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

Comments
 (0)