2 ms·
TBF there's only a 50% chance that the deduplication loop will run (once) after 5.1 x 10^9 keys. It's still better than erroring in that case IMO. If that's no
by minxomat 6y ago
TBF there's only a 50% chance that the deduplication loop will run (once) after 5.1 x 10^9 keys. It's still better than erroring in that case IMO.
If that's not needed, the loop and subquery and be removed. This then enables the usage of shortkey_generate() as a DEFAULT expression instead of a trigger. Maybe I should provide that as an alternative, something like shortkey_generate_unsafe().
- mattbillenstein 6y agoAlternatively, perhaps one could handle the duplicate key error on an insert into the table using one of these keys as the PK.