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.92) (envelope-from ) id 1jGKGN-0005XW-Lk for pgsql-general@arkaria.postgresql.org; Mon, 23 Mar 2020 10:24:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jGKGM-0005NT-Gc for pgsql-general@arkaria.postgresql.org; Mon, 23 Mar 2020 10:24:54 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jGKGM-0005JV-3G for pgsql-general@lists.postgresql.org; Mon, 23 Mar 2020 10:24:54 +0000 Received: from n3.nabble.com ([162.255.23.22]) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jGKGI-00080p-Lv for pgsql-general@postgresql.org; Mon, 23 Mar 2020 10:24:52 +0000 Received: from n3.nabble.com (localhost [127.0.0.1]) by n3.nabble.com (Postfix) with ESMTP id 99A021BEDE3AC for ; Mon, 23 Mar 2020 03:24:48 -0700 (MST) Date: Mon, 23 Mar 2020 03:24:48 -0700 (MST) From: pinker To: pgsql-general@postgresql.org Message-ID: <1584959088557-0.post@n3.nabble.com> Subject: Loading 500m json files to database MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, do you have maybe idea how to make loading process faster? I have 500 millions of json files (1 json per file) that I need to load to db. My test set is "only" 1 million files. What I came up with now is: time for i in datafiles/*; do psql -c "\copy json_parts(json_data) FROM $i"& done which is the fastest so far. But it's not what i expect. Loading 1m of data takes me ~3h so loading 500 times more is just unacceptable. some facts: * the target db is on cloud so there is no option to do tricks like turning fsync off * version postgres 11 * i can spin up huge postgres instance if necessary in terms of cpu/ram * i tried already hash partitioning (to write to 10 different tables instead of 1) Any ideas? -- Sent from: https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html