R
R
rocketml2021-03-09 12:56:40
Yandex
rocketml, 2021-03-09 12:56:40

How to correctly generate an ID in Yandex Database?

Hello!

I read the documentation in Yandex Cloud Yandex Database, I realized that I need to generate an evenly distributed primary key. I did not find any functions in the docks to create an ID.
Google didn't turn up any results either.
Is there any established practice for newsql? Or is it just possible to take uuid?

As an example, they show the usual int for id.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
idShura, 2021-03-09
@idShura

As Anton Shamanov advises to take a timestamp or pre-calculate: (select max (id)) + 1, Yandex does not recommend:

... As a consequence of this rule, you should not use a monotonically increasing sequence, for example, timestamp, as the primary key of a table.

And so everything is in the documentation:
Designing a primary key
How to design a primary key?

A
Anton Shamanov, 2021-03-09
@SilenceOfWinter

take a timestamp or precalculate: (select max(id)) + 1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question