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 1jGP3a-00027v-9p for pgsql-general@arkaria.postgresql.org; Mon, 23 Mar 2020 15:32:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jGP3X-000106-KR for pgsql-general@arkaria.postgresql.org; Mon, 23 Mar 2020 15:31:59 +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 1jGP3V-0000yV-Qb for pgsql-general@lists.postgresql.org; Mon, 23 Mar 2020 15:31:59 +0000 Received: from [64.147.123.24] (helo=wout1-smtp.messagingengine.com) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jGP3O-00025e-Fk for pgsql-general@postgresql.org; Mon, 23 Mar 2020 15:31:56 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id E3D2F3C5; Mon, 23 Mar 2020 11:31:38 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Mon, 23 Mar 2020 11:31:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm2; bh=s DQQmUQUSsSqzbaS351qU7iQC/iGhmNMuTNtVU3RFhw=; b=fPbn1DRyP2AIZoPF/ AOArUJ5KwUCQkOp/KA6wszjKKNcY1NdBP5Cf3Qal00Yf8F0BqGoDE9uifPOwbBks HkDtJ7iW8Zw9Mx75FlABUB9SRhYKCdrXZUe+Yx814bb9jH5x1yCURQPRvBYQRw/A oS13xx9FQy5O5vsmJA+/eGEwnu02f+AV2Ta/1clPuAl9PU8A/hWDHwAjJ65AwLrm bxxIs8m6eBHnd8KldE/9dHGNO9TtnFLq0tIrqddNxTksX+8U1cJCnDfV2ZLtOKrA HAuHE6BF/S+LBaY6J2SHInEnu2eRzaBo5OxKihuCa2GO/M/CVUrMUhKtVzhYBnvt XdXEQ== 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-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=sDQQmUQUSsSqzbaS351qU7iQC/iGhmNMuTNtVU3RF hw=; b=arch3noY8z2zFuXraQBsphCFdpgLn6HVUdrU81lxpJKh+D656GS8/hroL TOZ0XgydC8NXNB8wBkvHtEyOoX6ZQ+3XyIDHLyMweHkHDgPq1ADM1HhyAC9aCOqi cIOEzkA38Pf1zoTHdAxLeG8mhxs06HL4hlY62qQWrSLEHZNkzLT/gKymAprkNRTo N3PLxwrm0j05FHU9n8QupA/ErECefum3VtX4EDG3E+C+zvHK7a1rpzVRRv3+wxBY XHmH34UrflsrKzEJK/SDhjTXTXiRsD25aHbEcJwdlUtnQDBH/YXY++9rvtV0SOlw 7BLO9XdSY+9BBPDZQN/tLmpY4hjmg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrudegkedgjeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefuvfhfhffkffgfgggjtgfgsehtje ertddtfeejnecuhfhrohhmpeetughrihgrnhcumfhlrghvvghruceorggurhhirghnrdhk lhgrvhgvrhesrghklhgrvhgvrhdrtghomheqnecuffhomhgrihhnpehpohhsthhgrhgvsh hqlhdqrghrtghhihhvvgdrohhrghenucfkphepjedurddvuddvrdduvdelrdduleefnecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprggurhhirg hnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh X-ME-Proxy: Received: from [192.168.1.10] (unknown [71.212.129.193]) by mail.messagingengine.com (Postfix) with ESMTPA id 8EE6030618C1; Mon, 23 Mar 2020 11:31:37 -0400 (EDT) Subject: Re: Loading 500m json files to database To: pinker , pgsql-general@postgresql.org References: <1584959088557-0.post@n3.nabble.com> From: Adrian Klaver Message-ID: Date: Mon, 23 Mar 2020 08:31:36 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <1584959088557-0.post@n3.nabble.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 64.147.123.24 (deferred) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 3/23/20 3:24 AM, pinker wrote: > 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. Aggregating the JSON files as others have suggested would help greatly. Knowing what is happening in json_parts() might help folks provide further tips. > > 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 > > -- Adrian Klaver adrian.klaver@aklaver.com