Re: Referential Integrity Checks with Statement-level Triggers

2019-08-01 Thread Corey Huinker
> > > > The people who expressed opinions on nuking triggers from orbit (it's > the only way to be sure) have yet to offer up any guidance on how to > proceed from here, and I suspect it's because they're all very busy getting > things ready for v12. I definitely have an interest in working on this

Re: Referential Integrity Checks with Statement-level Triggers

2019-08-01 Thread Thomas Munro
On Tue, Feb 26, 2019 at 5:41 AM Corey Huinker wrote: >> In order to avoid per-row calls of the constraint trigger functions, we could >> try to "aggregate" the constraint-specific events somehow, but I think a >> separate queue would be needed for the constraint-specific events. >> >> In general,

Re: Referential Integrity Checks with Statement-level Triggers

2019-02-25 Thread Corey Huinker
> > > In order to avoid per-row calls of the constraint trigger functions, we > could > try to "aggregate" the constraint-specific events somehow, but I think a > separate queue would be needed for the constraint-specific events. > > In general, the (after) triggers and constraints have too much in

Re: Referential Integrity Checks with Statement-level Triggers

2019-02-25 Thread Antonin Houska
Corey Huinker wrote: > Have you considered bulk processing of individual rows by row-level trigger? > For IMMEDIATE constraints we'd have to ensure that the trigger is notified > that the current row is the last one from the current query, but that might > not be difficult. > > I'm not sure

Re: Referential Integrity Checks with Statement-level Triggers

2019-02-22 Thread Corey Huinker
> > > While the idea to use the transition table is good, this approach probably > requires the trigger engine (trigger.c) to be adjusted, and that in a > non-trivial way. > It probably does. Several people with advanced knowledge of trigger.c expressed a desire to rebuild trigger.c from the groun

Re: Referential Integrity Checks with Statement-level Triggers

2019-02-20 Thread Antonin Houska
Corey Huinker wrote: > Attached is a patch that refactors DELETE triggers to fire at the statement > level. > > I chose delete triggers partly out of simplicity, and partly because there > some before/after row linkage in the ON UPDATE CASCADE cases where statement > level triggers might not be

Re: Referential Integrity Checks with Statement-level Triggers

2019-01-23 Thread Corey Huinker
Attached is a patch that refactors DELETE triggers to fire at the statement level. I chose delete triggers partly out of simplicity, and partly because there some before/after row linkage in the ON UPDATE CASCADE cases where statement level triggers might not be feasible as we have currently imple

Re: Referential Integrity Checks with Statement-level Triggers

2018-12-22 Thread Emre Hasegeli
> It is far from a premature optimization IMO, it is super useful and something > I was hoping would happen ever since I heard about transition tables being > worked on. Me too. Never-ending DELETEs are a common pain point especially for people migrated from MySQL which creates indexes for fore

Re: Referential Integrity Checks with Statement-level Triggers

2018-12-17 Thread Kevin Grittner
On Mon, Dec 17, 2018 at 8:32 AM Corey Huinker wrote: > All suggestions are appreciated. As I recall, the main issue is how to handle concurrency. The existing RI triggers do some very special handling of the multi-xact ID to manage concurrent modifications. Has anyone looked at the issues with

Re: Referential Integrity Checks with Statement-level Triggers

2018-12-17 Thread Kevin Grittner
On Mon, Dec 17, 2018 at 11:27 AM Alvaro Herrera wrote: > On 2018-Dec-17, Pavel Stehule wrote: > >> ROW trigger call RI check too often, and statement trigger too less. I >> think so ideal design can be call RI check every 10K rows. I think so can >> be unfriendly if somebody does very long import

Re: Referential Integrity Checks with Statement-level Triggers

2018-12-17 Thread Pavel Stehule
po 17. 12. 2018 v 19:19 odesílatel Adam Brusselback < adambrusselb...@gmail.com> napsal: > It's something I know I am interested in. For me, I don't really care if > my statement doesn't cancel until the very end if there is a RI violation. > The benefit of not having deletes be slow on tables whi

Re: Referential Integrity Checks with Statement-level Triggers

2018-12-17 Thread Adam Brusselback
It's something I know I am interested in. For me, I don't really care if my statement doesn't cancel until the very end if there is a RI violation. The benefit of not having deletes be slow on tables which have others referencing it with a fkey which don't have their own index is huge IMO. I have

Re: Referential Integrity Checks with Statement-level Triggers

2018-12-17 Thread Pavel Stehule
po 17. 12. 2018 v 18:27 odesílatel Alvaro Herrera napsal: > On 2018-Dec-17, Pavel Stehule wrote: > > > ROW trigger call RI check too often, and statement trigger too less. I > > think so ideal design can be call RI check every 10K rows. I think so can > > be unfriendly if somebody does very long

Re: Referential Integrity Checks with Statement-level Triggers

2018-12-17 Thread Alvaro Herrera
On 2018-Dec-17, Pavel Stehule wrote: > ROW trigger call RI check too often, and statement trigger too less. I > think so ideal design can be call RI check every 10K rows. I think so can > be unfriendly if somebody does very long import and it fails on the end. I > don't think so there should not b

Re: Referential Integrity Checks with Statement-level Triggers

2018-12-17 Thread Pavel Stehule
po 17. 12. 2018 v 15:32 odesílatel Corey Huinker napsal: > Back when Pg added statement-level triggers, I was interested in the > potential promise of moving referential integrity checks to statement-level > triggers. > > The initial conversation, along with Kevin Grittner's POC script (in SQL) >

Referential Integrity Checks with Statement-level Triggers

2018-12-17 Thread Corey Huinker
Back when Pg added statement-level triggers, I was interested in the potential promise of moving referential integrity checks to statement-level triggers. The initial conversation, along with Kevin Grittner's POC script (in SQL) that showed a potential for a 98% reduction in time spent doing RI ch