Dancing Around Foreign Keys: Challenges in FK Creation and Validation
This talk explores the challenges we encountered — and solved — while migrating massive databases from Oracle to PostgreSQL.
One of the most complex aspects of this process was rebuilding foreign keys (FKs). To overcome these challenges, we had to dive deep into the internal workings of FK creation and validation.
Key topics include:
Does ALTER TABLE ... ADD CONSTRAINT ... FOREIGN KEY have an execution plan?
Can an ordinary user influence this process?
What locks are applied during FK creation and validation?
Also, we’ll introduce a first-principles method for investigating performance issues, applying it to a real-world FK creation bottleneck.