Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kfeWs-0003g6-Jq for pgsql-general@arkaria.postgresql.org; Thu, 19 Nov 2020 07:38:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kfeWr-0002oF-4F for pgsql-general@arkaria.postgresql.org; Thu, 19 Nov 2020 07:38:53 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kfeWq-0002o8-ST for pgsql-general@lists.postgresql.org; Thu, 19 Nov 2020 07:38:52 +0000 Received: from ms-10.1blu.de ([178.254.4.101]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kfeWn-0006jt-SC for pgsql-general@lists.postgresql.org; Thu, 19 Nov 2020 07:38:52 +0000 Received: from [178.254.11.41] (helo=r314251-amd64) by ms-10.1blu.de with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kfeWl-0003kQ-B3; Thu, 19 Nov 2020 08:38:47 +0100 Date: Thu, 19 Nov 2020 08:38:45 +0100 From: Matthias Apitz To: pgsql-general@lists.postgresql.org Subject: \COPY command and indexes in tables Message-ID: <20201119073845.GA13022@r314251-amd64> Reply-To: Matthias Apitz MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Operating-System: FreeBSD 8.0-CURRENT (i386) User-Agent: Mutt/1.8.0 (2017-02-23) X-Con-Id: 51246 X-Con-U: 0-guru X-Originating-IP: 178.254.11.41 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hello, We load large tables in some customer installation (some millions of rows) from file with: TRUNCATE TABLE tableName ; \COPY tableName FROM 'fileName' WITH ( DELIMITER '|' ) and got to know that the loading nearly stops (without any real CPU consumption) in the middle. The wild guess is that we forgot to DROP the indexes on the tables. The doc https://www.postgresql.org/docs/13/sql-copy.html does not give any hints related indexes. There seems to be even tools available which address this issue on the flight, like https://www.californiacivicdata.org/2018/01/25/index-drop-and-copy/ Any comments on this? matthias -- Matthias Apitz, ✉ guru@unixarea.de, http://www.unixarea.de/ +49-176-38902045 Public GnuPG key: http://www.unixarea.de/key.pub Без книги нет знания, без знания нет коммунизма (Влaдимир Ильич Ленин) Without books no knowledge - without knowledge no communism (Vladimir Ilyich Lenin) Sin libros no hay saber - sin saber no hay comunismo. (Vladimir Ilich Lenin)