pg.ddx.io pgsql-performance@postgresql.org mailing list archive
help / color / mirror / Atom feedDeferred constraint and delete performance
4+ messages / 4 participants
[nested] [flat]
* Deferred constraint and delete performance
@ 2010-02-10 10:55 Franck Routier <franck.routier@axege.com>
0 siblings, 1 reply; 4+ messages in thread
From: Franck Routier @ 2010-02-10 10:55 UTC (permalink / raw)
To: pgsql-performance
Hi,
I am trying to improve delete performance on a database with several
foreign keys between relations that have 100M or so rows.
Until now, I have manually disabled the triggers, done the delete, and
re-enabled the triggers.
This works, but I have to do that when I am sure no other user will
access the database...
I am wondering if deferring foreign key constraints (instead of
disableing them) would increase performance, compared to non deferred
constraints (and compared to disableing the constraints, but I guess no
in this case).
Thanks,
Franck
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Deferred constraint and delete performance
@ 2010-02-10 14:56 Tom Lane <tgl@sss.pgh.pa.us>
parent: Franck Routier <franck.routier@axege.com>
0 siblings, 2 replies; 4+ messages in thread
From: Tom Lane @ 2010-02-10 14:56 UTC (permalink / raw)
To: Franck Routier <franck.routier@axege.com>; +Cc: pgsql-performance
Franck Routier <franck.routier@axege.com> writes:
> I am wondering if deferring foreign key constraints (instead of
> disableing them) would increase performance, compared to non deferred
> constraints
No, it wouldn't make any noticeable difference AFAICS. It would
postpone the work from end-of-statement to end-of-transaction,
but not make the work happen any more (or less) efficiently.
regards, tom lane
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Deferred constraint and delete performance
@ 2010-02-10 17:36 Andres Freund <andres@anarazel.de>
parent: Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 4+ messages in thread
From: Andres Freund @ 2010-02-10 17:36 UTC (permalink / raw)
To: pgsql-performance; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Franck Routier <franck.routier@axege.com>
On Wednesday 10 February 2010 15:56:40 Tom Lane wrote:
> Franck Routier <franck.routier@axege.com> writes:
> > I am wondering if deferring foreign key constraints (instead of
> > disableing them) would increase performance, compared to non deferred
> > constraints
>
> No, it wouldn't make any noticeable difference AFAICS. It would
> postpone the work from end-of-statement to end-of-transaction,
> but not make the work happen any more (or less) efficiently.
It could make a difference if the transaction is rather long and updates the
same row repeatedly because of better cache usage. But I admit thats a bit of
a constructed scenario (where one likely would get into trigger-queue size
problems as well)
Andres
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Deferred constraint and delete performance
@ 2010-02-14 09:45 Віталій Тимчишин <tivv00@gmail.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 4+ messages in thread
From: Віталій Тимчишин @ 2010-02-14 09:45 UTC (permalink / raw)
To: ; +Cc: pgsql-performance
2010/2/10 Tom Lane <tgl@sss.pgh.pa.us>
> Franck Routier <franck.routier@axege.com> writes:
> > I am wondering if deferring foreign key constraints (instead of
> > disableing them) would increase performance, compared to non deferred
> > constraints
>
> No, it wouldn't make any noticeable difference AFAICS. It would
> postpone the work from end-of-statement to end-of-transaction,
> but not make the work happen any more (or less) efficiently.
>
> What about disc access? Won't "working" with one table, then another be
faster than working with both at the same time?
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2010-02-14 09:45 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-02-10 10:55 Deferred constraint and delete performance Franck Routier <franck.routier@axege.com>
2010-02-10 14:56 ` Tom Lane <tgl@sss.pgh.pa.us>
2010-02-10 17:36 ` Andres Freund <andres@anarazel.de>
2010-02-14 09:45 ` Віталій Тимчишин <tivv00@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox