, , - , , , db .
To answer your question, what do you consider a “usable” identifier? Please shed some light on this. Until all id is used, just
SELECT MAX(id) + 1 FROM table;
must do. If you set the criteria for “usable” identifiers, for example, reusing all identifiers that have been marked with the old, you can do:
SELECT MIN(id) FROM table WHERE is_old = 1;
Then just release the selected identifier.
source
share