T
T
tem12qaz2021-02-21 18:58:59
PostgreSQL
tem12qaz, 2021-02-21 18:58:59

Is it possible to skip some id's?

Can I set an id limit for a table. For example, so that the values ​​54 and 37 are not filled in and after the line with id=53 there is a line with id=55?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
rPman, 2021-02-21
@rPman

Will run many telegram bots. I wanted them to work on port=id. But not all ports are free.

The correct solution is compound identifiers.
Those. the identifier must be simultaneously a pair of ports - record id and port (or device) id.
There is a practice when two are stuffed into one numeric identifier, the easiest way is to increase the value of the identifier for each new entry not by 1 but by N, where N is the maximum number of devices (in your case, bots), albeit with a margin. Those. if the port number is P, then the identifier will be equal to P + N * seq, until the number of devices is less than N, they do not intersect and by simple division modulo N, you can extract P from the identifier.
In your postgres it supports sequences

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question