Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Zx0Ll-0005Cd-RH for pgsql-performance@arkaria.postgresql.org; Thu, 12 Nov 2015 22:28:13 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1Zx0Ll-0007ip-8P for pgsql-performance@arkaria.postgresql.org; Thu, 12 Nov 2015 22:28:13 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1Zx0K4-0001Me-7a for pgsql-performance@postgresql.org; Thu, 12 Nov 2015 22:26:28 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1Zx0K1-0004ao-LE for pgsql-performance@postgresql.org; Thu, 12 Nov 2015 22:26:27 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id tACMQM8X022757; Thu, 12 Nov 2015 17:26:22 -0500 From: Tom Lane To: Merlin Moncure cc: Craig James , Massalin Yerzhan , postgres performance list Subject: Re: Simple delete query is taking too long (never ends) In-reply-to: References: <17089.1447270415@sss.pgh.pa.us> Comments: In-reply-to Merlin Moncure message dated "Thu, 12 Nov 2015 16:07:29 -0600" Date: Thu, 12 Nov 2015 17:26:22 -0500 Message-ID: <22756.1447367182@sss.pgh.pa.us> X-Pg-Spam-Score: -2.3 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org Merlin Moncure writes: > On Thu, Nov 12, 2015 at 9:48 AM, Craig James 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 -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance