4 ms·
To solve this problem is why many databases support sequences. Sequences are number generators which work outside the transactional system (e.g. sequence increm
by jeltz 15y ago
To solve this problem is why many databases support sequences. Sequences are number generators which work outside the transactional system (e.g. sequence incrementations cannot be rolled back) so the locks are very short.
To use sequences in PostgreSQL use simply call nextval('name_of_sequence') in the database. Rails uses the SERIAL type for the primary key column which is implemented with a sequence.