Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eJjaW-0000lh-DB for pgsql-general@arkaria.postgresql.org; Tue, 28 Nov 2017 17:22:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eJjaV-0001iF-WA for pgsql-general@arkaria.postgresql.org; Tue, 28 Nov 2017 17:22:27 +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.84_2) (envelope-from ) id 1eJjaV-0001i5-OL for pgsql-general@lists.postgresql.org; Tue, 28 Nov 2017 17:22:27 +0000 Received: from mail-wr0-x233.google.com ([2a00:1450:400c:c0c::233]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1eJjaQ-0006mF-LW for pgsql-general@postgresql.org; Tue, 28 Nov 2017 17:22:27 +0000 Received: by mail-wr0-x233.google.com with SMTP id y21so817673wrc.1 for ; Tue, 28 Nov 2017 09:22:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=15HpZrCx9fNM1jiwPjwrhXBd3Rs/1kRsMcjoX08pvcw=; b=rLXKaukaArCrO8z1nlRbpoOtcHQD25oOY3wYwXRanAwIx0fLlb6ZsUNfEeU2b2CRcZ Wge82SW/yYU1xed13i9QpHW2ewTY3p9TAQgMYeK0rWs46vYRuCc///4c3IP65SKaEDAH wq6rS+KzOMckha5BPKlTIOOEeXWqxIZVM3h//Lohksuw4fOtFeQHQwI18CqBOQB1QzS4 vUXn/NvG+Vu/BBV43sTqjDSuWyz9rkxtJZfcEHOcGzo9VPLQCZONW40wD96aCedAXZkK UoCG6OZhGnW1cIB7gxxQ9DuK4eNM8dgMAScbFDzaxMzy0/LIakR6ADC7dnXJ4I7hF7CW Rk6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=15HpZrCx9fNM1jiwPjwrhXBd3Rs/1kRsMcjoX08pvcw=; b=NQJRq2qjPyyjWOf9ZwUBmDgX2YJzdvtqTaFl7R65H5TPBHYaHRsNaxYJfgZ/CijACD WhED7L1csVgWoL9kgDSFQU8zGK1+K+LyW8miFwiuW4TUWCLnJdCk9LOM8B4h/9AH5w6g /xTk9QY/KHO+TpYr2FxhhpY0+Y2GIhUq0Yts1Aqt0odvA906cab7m66tfvViHBDbUusM CKgFuJUJNDA4BLOOSe10T90om7akfYhdyOoEmz1BqJFt5Fj1KA5tQ/ldfoNoPAUwhAJP edC+SkjrgWcxZarw+BKQSi1wQk0pSmllCJEX8h8p4HP/6FHVlOWRoqq5XyxhM+TRknAy 7qJA== X-Gm-Message-State: AJaThX6ctz56CRlqodmvbe3K1JEZ7KJn0Iw4HCyotX1UsFpEyLkblaEd JvVER4Q2WypAd9hr8tkJ0pRI26pI34ETB41NU4uOZ5fNee8XzRtkZb9iH4pTTP2rBHDklE5AlPP QNj9e39p3q1u4GmsWEvHFSRgeQN52LaebfU2OC7CJCqmDcWOXFizoPzRJz7o5EZGm7q3DjiCmJ8 1Jf9UECW4a X-Google-Smtp-Source: AGs4zMZuQiYufsk+5a5B99YTI1KVdPlEolZcj5uYM/vF466ZYjpvGUeMI9u38qZtiYYroX68BgJfbA== X-Received: by 10.223.142.49 with SMTP id n46mr35091919wrb.279.1511889740197; Tue, 28 Nov 2017 09:22:20 -0800 (PST) Received: from [10.137.2.19] (ip-78-102-97-226.net.upcbroadband.cz. [78.102.97.226]) by smtp.gmail.com with ESMTPSA id 186sm19029259wmm.47.2017.11.28.09.22.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Nov 2017 09:22:19 -0800 (PST) Subject: Re: large numbers of inserts out of memory strategy To: Ted Toth , pgsql-general References: From: Tomas Vondra Message-ID: Date: Tue, 28 Nov 2017 18:22:17 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, On 11/28/2017 06:17 PM, Ted Toth wrote: > I'm writing a migration utility to move data from non-rdbms data > source to a postgres db. Currently I'm generating SQL INSERT > statements involving 6 related tables for each 'thing'. With 100k or > more 'things' to migrate I'm generating a lot of statements and when I > try to import using psql postgres fails with 'out of memory' when > running on a Linux VM with 4G of memory. If I break into smaller > chunks say ~50K statements then thde import succeeds. I can change my > migration utility to generate multiple files each with a limited > number of INSERTs to get around this issue but maybe there's > another/better way? > The question is what exactly runs out of memory, and how did you modify the configuration (particularly related to memory). regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services