Skip to content

Commit

Permalink
Describe key choosing profits (#4835)
Browse files Browse the repository at this point in the history
  • Loading branch information
kunga authored May 29, 2024
1 parent e888137 commit 3acb5b5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ydb/docs/en/core/dev/primary-key/row-oriented.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Writing data to a table with the ```( timestamp, userid, userevent, PRIMARY KEY

### Using a hash of key column values as a primary key {#key-hash}

To obtain a more even distribution of inserts across a table's partitions, make the primary key "prefix" (initial part) values more varied. To do this, make the primary key include the value of a hash of the entire primary key or a part of the primary key.
To obtain a more even distribution of operations across a table's partitions and reduce the size of internal data structures, make the primary key "prefix" (initial part) values more varied. To do this, make the primary key include the value of a hash of the entire primary key or a part of the primary key.

For instance, the schema of this table with the schema ```( timestamp, userid, userevent, PRIMARY KEY (userid, timestamp) )``` might be made to include an additional field computed as a hash: ```userhash = HASH(userid)```. This would change the table schema as follows:

Expand Down
2 changes: 1 addition & 1 deletion ydb/docs/ru/core/dev/primary-key/row-oriented.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

### Использование хеша от значений ключевых колонок в качестве первичного ключа {#key-hash}

Для получения более равномерного распределения операций вставки между партициями таблицы необходимо увеличить разнообразие значений "префикса" (начальной части) первичного ключа. Для этого можно включить в первичный ключ значение хеш-кода от всего первичного ключа или его части.
Для получения более равномерного распределения операций между партициями таблицы, а также уменьшения размеров внутренних структур данных, необходимо увеличить разнообразие значений "префикса" (начальной части) первичного ключа. Для этого можно включить в первичный ключ значение хеш-кода от всего первичного ключа или его части.

Например, в рассматриваемую таблицу со схемой ```( timestamp, userid, userevent, PRIMARY KEY (userid, timestamp) )``` можно включить дополнительное поле, рассчитываемое как хеш-код: ```userhash = HASH(userid)```. В результате схема таблицы преобразуется к следующему виду:

Expand Down

0 comments on commit 3acb5b5

Please sign in to comment.