Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Y1GUy-0005lI-U5 for pgsql-performance@arkaria.postgresql.org; Wed, 17 Dec 2014 15:26:49 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Y1GUx-0006P5-LJ for pgsql-performance@arkaria.postgresql.org; Wed, 17 Dec 2014 15:26:47 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Y1GUt-0006IW-C4 for pgsql-performance@postgresql.org; Wed, 17 Dec 2014 15:26:43 +0000 Received: from mail.toco-domains.de ([176.9.39.170] helo=toco-domains.de) by magus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Y1GUk-0002ny-Rd for pgsql-performance@postgresql.org; Wed, 17 Dec 2014 15:26:42 +0000 Received: from [0.0.0.0] (mail.toco-domains.de [176.9.39.170]) by toco-domains.de (Postfix) with ESMTPA id 0C0381B22037; Wed, 17 Dec 2014 16:26:32 +0100 (CET) Message-ID: <5491A0A8.7010506@toco-domains.de> Date: Wed, 17 Dec 2014 16:26:32 +0100 From: Torsten Zuehlsdorff User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: pgsql-performance@postgresql.org CC: Alessandro Ipe Subject: Re: Excessive memory used for INSERT References: <2163931.4eVnXNjHa3@snow.oma.be> In-Reply-To: <2163931.4eVnXNjHa3@snow.oma.be> Content-Type: text/plain; charset=iso-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org Hello Alessandro, > 2014-12-15 17:54:07 GMT DETAIL: Failed process was running: WITH upsert > AS (update MSG set > (slot,MSG,HRV,VIS006,VIS008,IR_016,IR_039,WV_062,WV_073,IR_087,IR_097,IR_108,IR_120,IR_134,PRO,EPI,CLM,TAPE) > = (to_timestamp('201212032145', > 'YYYYMMDDHH24MI'),2,'\xffffff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\x01','\x01','\x7f','LTO5_020') > where slot=to_timestamp('201212032145', 'YYYYMMDDHH24MI') and MSG=2 > RETURNING *) insert into MSG > (slot,MSG,HRV,VIS006,VIS008,IR_016,IR_039,WV_062,WV_073,IR_087,IR_097,IR_108,IR_120,IR_134,PRO,EPI,CLM,TAPE) > select to_timestamp('201212032145', > 'YYYYMMDDHH24MI'),2,'\xffffff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\x01','\x01','\x7f','LTO5_020' > WHERE NOT EXISTS (SELECT * FROM upsert); How many rows is "(SELECT * FROM upsert)" returning? Without knowing more i would guess, that the result-set is very big and that could be the reason for the memory usage. I would add an WHERE clause to reduce the result-set (an correct index can fasten this method even more). Greetings, Torsten -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance