Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1glz4m-0002s3-Vb for pgsql-general@arkaria.postgresql.org; Tue, 22 Jan 2019 16:39:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1glz4l-0008Cv-G3 for pgsql-general@arkaria.postgresql.org; Tue, 22 Jan 2019 16:38:59 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1glz4j-0008Az-Us for pgsql-general@lists.postgresql.org; Tue, 22 Jan 2019 16:38:59 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1glz4g-0006bA-11 for pgsql-general@lists.postgresql.org; Tue, 22 Jan 2019 16:38:57 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 212BA20ED2; Tue, 22 Jan 2019 11:38:51 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Tue, 22 Jan 2019 11:38:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.com; h= content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; s=fm1; bh=E bgeHNgYtz0ZSn5Bw/tWsQ8t+tDmb5I0rmDt9tYo10w=; b=nzSdW/o1GpGLLEhgY p7wfWEiJ6mdVlhjadUZtpi5V+pO2EeUsOTd621beQiCmSwTHAl2gCLYlcrCuWP4U i8Tziu/yRxYwfLhZz7TdCi09IuyxgYoWHbiDu6o7DiM5UbmmSd7netRo4ohuvuWk BptLkjpnxuKRfuy1pIUBB/mZldVPOeBpSzfqVeYPp41oAkZdHkjtqy+MJurvmfbC 5qJ6Jfd7oJJvzaj4fCdDmgNdlznNhn03byZv392dqKc5pKJ/FK0XY3cP/FabR9wR fXQUHgRRH5p5QTwbBXVPcanoShPPkTavyecG3Lj6QPZf3SP78ahoSJT9+UfyFJYd ojdGg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=EbgeHNgYtz0ZSn5Bw/tWsQ8t+tDmb5I0rmDt9tYo1 0w=; b=kviShlenDm2YRVUUjRm9JfIP5vHdpqkAIdjQRNdkH7eCPWT7Tp9Nl9OEQ /h660SjlZdOetlurqnDBbe/Ct4iBvCBhTX1I+Zzvs47Z29phUNpjS+qwSj5kN1Kq INanQs4MLFdX0dATgywBk9nMJpPZr7Ww0RIWxbb+QDDQD9Yu1zVMA/g0zI+Yyptr w0aT11rVDrUF8ds2M+/ezf6k0Cm1kJJ/5MIHN00A6I9R9NRx7EFw/MD3ZQKrLgIF cAZkoTF+x1OXROqaBr9F36BmUk6mhFN49UgmSSAQIplz4qmNwjUDZBHcxnU1tDQ7 cjZ/tvW0rhb+vRKFB5lmIL6L7uCZw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtledrheekgdeklecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecufedt tdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurheptggguffhjgffgf fkfhfvofesthhqmhdthhdtvdenucfhrhhomheptfgrvhhiucfmrhhishhhnhgruceoshhr khhrihhshhhnrgesfhgrshhtmhgrihhlrdgtohhmqeenucfkphepvddtkedrudekhedrud elrddvhedunecurfgrrhgrmhepmhgrihhlfhhrohhmpehsrhhkrhhishhhnhgrsehfrghs thhmrghilhdrtghomhenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from [192.168.1.28] (unknown [208.185.19.251]) by mail.messagingengine.com (Postfix) with ESMTPA id 53100E4046; Tue, 22 Jan 2019 11:38:50 -0500 (EST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) Subject: Re: Decrease time needed to CREATE INDEX and FOREIGN KEY on new table column which has all values NULL From: Ravi Krishna In-Reply-To: Date: Tue, 22 Jan 2019 11:38:46 -0500 Cc: "pgsql-general@lists.postgresql.org" Content-Transfer-Encoding: quoted-printable Message-Id: <038B7823-6C23-4606-9F1B-2B6BA097FDF9@fastmail.com> References: To: Denisa Cirstescu X-Mailer: Apple Mail (2.3445.102.3) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > The table is huge and it takes a lot of time to add the INDEX and the = FOREIGN KEY although all values are NULL. > Considering that the new DepartmentId column is NULL for all rows at = this point, is there a way to make the INDEX and FOREIGN KEY creation = run faster? In your script to create index add this: set maintenance_work_mem =3D '1GB' or any other figure you feel comfortable.