Re: Simple delete query is taking too long (never ends)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Merlin Moncure <mmoncure(at)gmail(dot)com>
Cc: Craig James <cjames(at)emolecules(dot)com>, Massalin Yerzhan <yerzhik(at)gmail(dot)com>, postgres performance list <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Simple delete query is taking too long (never ends)
Date: 2015-11-12 22:26:22
Message-ID: 22756.1447367182@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Merlin Moncure <mmoncure(at)gmail(dot)com> writes:
> On Thu, Nov 12, 2015 at 9:48 AM, Craig James <cjames(at)emolecules(dot)com> wrote:
>> What about a warning on creation?
>>
>> db=> create table foo(i integer primary key);
>> db=> create table bar(j integer primary key, i integer);
>> db=> alter table bar add constraint fk_bar foreign key(i) references foo(i);
>> WARNING: fk_bar: column bar(i) has no index, deletions on table foo may be
>> slow.
>>
>> It might save some fraction of these questions.

> Maybe, but I wonder if this would cause pg_restore to bleat warnings
> when restoring.

We could probably teach pg_dump to put index definitions before FKs, if it
doesn't already. But I'm suspicious of this sort of "training wheels"
warning --- we've had roughly similar messages in the past and removed
them because too many people complained about them.

Worth noting in particular is that there would be no way to avoid the
warning unless you split out the FK declaration to a separate "alter table
add constraint" step. pg_dump does that anyway, but manual schema
definitions likely would look more like

create table foo(i integer primary key);
create table bar(j integer primary key, i integer references foo);
create index on bar(i);

which would provoke the warning. I fear a warning like that would have
a very short life expectancy.

regards, tom lane

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Merlin Moncure 2015-11-13 14:15:06 Re: Simple delete query is taking too long (never ends)
Previous Message Merlin Moncure 2015-11-12 22:07:29 Re: Simple delete query is taking too long (never ends)