Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fcvk1-0003qY-Va for pgsql-general@arkaria.postgresql.org; Tue, 10 Jul 2018 16:43:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fcvjz-0002cl-PN for pgsql-general@arkaria.postgresql.org; Tue, 10 Jul 2018 16:43:51 +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_SHA384:256) (Exim 4.89) (envelope-from ) id 1fcvjx-0002cW-M8 for pgsql-general@lists.postgresql.org; Tue, 10 Jul 2018 16:43:51 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fcvjs-00081u-MQ for pgsql-general@lists.postgresql.org; Tue, 10 Jul 2018 16:43:48 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 6143E21C08; Tue, 10 Jul 2018 12:43:42 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Tue, 10 Jul 2018 12:43:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=2sKErU7YeRQIoTrF//Lh8JSdwueLd dx9K8h19RREbuY=; b=b/D1niwgQkmyuyPtTlqwJPGJFmA+Q+7hZFnpF813XOo19 DHsU1TR8Tr8sNE4BvL0O4QjkVPaF7VIZ3lWwOtiEzd3IbIDX9v9zg58SDIpQmPzc +BzmJ2UX7XlrJfhH/H8B1Kuqcbw8JB3pWVx73u/O+trlATvi6meVHQozRuoc5uHf WhacQtFDHCx1WY7Ud6klB48TBlhmKZKuufwmybzGNUPBEp7aB05B8PP7GT6M9lUV zPoSQdXMOJeNkdeidhqI4u8JG6t/TWDfHdGAtKJyQzqXwcSg8yOCH8Xy6LdoyjJR bJybqZfaPBkv6aAZcHeIwJ7zjoK3z2WEVPxiz4bNQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=2sKErU 7YeRQIoTrF//Lh8JSdwueLddx9K8h19RREbuY=; b=RyJ4OS1108zTn7atpUdwEY ku0OeDxOEihNIYZfNHxhwOOi2+41/DWY3AF4bo9+EophYuy1aHo5J9jqbo1ndNya ogT9jZLC856Mxj8Xvu8PKd7WDkxaO51OVNk7L19xl4PDFHT8rW1m5XbOSNbuFljA NvVExVdDZwyWHztV9x68BjT+4lU44vGwrKEGrxM7T0WiJ6dBVQmDXxTFr0cG/7nz OBrbGhXZ4/h4TOASgNzzGYOVSqhLpa3urmlmBsMMUGiKKpPiAkuw7Bva1zt5fa4X bKDWmNBvUg9c6KnrQufE0KqasAcm/YDwaJsd6/GDtWpDo21HUAgVHJLRsKnqxxOQ == X-ME-Proxy: X-ME-Sender: Received: from [192.168.1.3] (unknown [71.212.134.181]) by mail.messagingengine.com (Postfix) with ESMTPA id B3F3EE455B; Tue, 10 Jul 2018 12:43:41 -0400 (EDT) Subject: Re: Disabling/Enabling index before bulk loading To: Ravi Krishna , PG mailing List References: <67D408BB-5BF7-4607-A730-6F262F65811A@yahoo.com> From: Adrian Klaver Message-ID: <97b32f41-a133-d9d1-2dfa-0289038b25bf@aklaver.com> Date: Tue, 10 Jul 2018 09:43:40 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.0 MIME-Version: 1.0 In-Reply-To: <67D408BB-5BF7-4607-A730-6F262F65811A@yahoo.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 07/10/2018 07:08 AM, Ravi Krishna wrote: > > We recently did a test on COPY and found that on large tables (47 million rows , 20GB of raw data) the > difference in COPY with 16 indexes and COPY without any index is 1:14. That is, COPY is 14 times slower > when data is ingested with all indexes as opposed to COPY first without index and then create all index. Did you include the time to CREATE INDEX after the COPY or is the 1:14 only for the COPY stage? > > I googled for earlier posting on this and it looks like this has been asked before too. > > This is what I am thinking to do: > > 1 - Extract index definition and save it as a SQL somewhere, either a file or a table. > 2 - Drop all indexes. > 3 - Ingest data via COPY > 4 - Recreate all indexes saved in (1). > > Is there a generic sql or script or tool to accomplish (1). > > thanks > -- Adrian Klaver adrian.klaver@aklaver.com