#
foreign-keys
Foreign key constraints and performance impacts
DatabasesWhy PostgreSQL INSERT Slow on Empty Tables with FKs
PostgreSQL INSERTs slow on empty tables with foreign keys due to planner stats (reltuples=0) causing seq scans. Seeding 1 row or ON CONFLICT fixes it. Best practices for bulk inserts, ANALYZE, libpq sync.
1 answer• 1 view