Auto increment table column

Postgres 10 or later Consider a standard-SQL IDENTITY column. serial columns remain unchanged. (See below.) But the former is preferable in modern Postgres. Can be GENERATED BY DEFAULT or (stricter) GENERATED ALWAYS. Basics in the manual for CREATE TABLE. Details in this blog entry by its principal author Peter Eisentraut. Create table with IDENTITY column … Read more

How to choose between UUIDs, autoincrement/sequence keys and sequence tables for database primary keys?

UUIDs Unless these are generated “in increasing monotonic sequence” they can drastically hurt/fragment indexes. Support for UUID generation varies by system. While usable, I would not use a UUID as my primary clustered index/PK in most cases. If needed I would likely make it a secondary column, perhaps indexed, perhaps not. Some people argue that … Read more

tech