Skip to content

Instantly share code, notes, and snippets.

@amitlan
Last active December 10, 2018 03:58
Show Gist options
  • Save amitlan/484767ee8784c88c6c6afaa7a25b6b57 to your computer and use it in GitHub Desktop.
Save amitlan/484767ee8784c88c6c6afaa7a25b6b57 to your computer and use it in GitHub Desktop.
RI trigger efficiency

Improve RI trigger efficiency with transition tables (Corey Huinker)

Common approach in DW environments it to disable constraints before loading and validate later. Disabling is a workaround for inefficient constraint checking which occurs per-row, per-constraint. Transition tables in PG 10 for statement level triggers are promising to implementing those checks more efficiently, but benchmarks shown initially were a bit artificial. Corey is considering making RI checking efficient with statement-level triggers based on transition tables. Discussion on which offending rows are shown in the error message. Possibility of a feature to ignore failed rows and store failing rows in a separate "rejection" table. It seems it makes sense to make a PoC patch as the approach seems promising and figure out the details later, including whether to allow users to specify whether to use per-row trigger based approach or statement level triggers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment