Answer the question
In order to leave comments, you need to log in
Storage of data from sensors. How to generate UUID?
The history of the issue. PostgreSQL base. The server flew on a raspberry where information from temperature sensors, humidity and others was stored. Somehow I pulled out a dump from a flash drive, but there was no data for half a month. Restored, flooded, launched. Then it turned out that I still backed up the data through Adminer and a large amount of data was saved (13 days out of 14+). I had to play around with Autoincrement, expand the range so that the desired section fits in, fill in the dump. And then an idea arose, since I can change the format of the base - change the autoincrement type ID to uuid based on the timestamp and device id. Has anyone solved a similar problem? Is there already a well-founded solution?
PS I'm not interested in the code any more, but in the theory of storing this type of data and using UUID. Everything in the context of the DBMS, specifically PostgreSQL.
Answer the question
In order to leave comments, you need to log in
What for? If you want to generate uuid on the base - just take sequence. There is no reason to use uuid in this case, and there will be nasty side effects.
I had to play with Autoincrement, move the range apart so that the desired section fits
Well, there are regular tools for this
https://postgrespro.ru/docs/postgresql/9.6/datatyp...
Take and use.)
There is absolutely no motivation to use uuid.
Uuid is used in distributed messaging systems where it is fundamentally impossible to provide a single counter.
In the author's case, it's better to just work with arithmetic to load the necessary data without key conflicts. And save valuable space.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question