Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Yl0VQ-0006WI-Nu for pgsql-bugs@arkaria.postgresql.org; Wed, 22 Apr 2015 19:40:20 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Yl0VQ-00061Q-57 for pgsql-bugs@arkaria.postgresql.org; Wed, 22 Apr 2015 19:40:20 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Ykwtx-0004a7-Dc for pgsql-bugs@postgresql.org; Wed, 22 Apr 2015 15:49:25 +0000 Received: from mail-wi0-x230.google.com ([2a00:1450:400c:c05::230]) by makus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1Ykwtu-00065o-BZ for pgsql-bugs@postgresql.org; Wed, 22 Apr 2015 15:49:23 +0000 Received: by wiun10 with SMTP id n10so62364296wiu.1 for ; Wed, 22 Apr 2015 08:49:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:organization:user-agent:mime-version:to:cc :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=DU1gWcGrnyfux+yTvEg/67Nb11k0qjtwUMe5n7JUms0=; b=I3iTaUQEn5dRNtUN2ZZ+Rz6Tz7CVXqCqy3uPYSWOktkc+nDo1Rif72cySXRnDaQLhu ZubLB1S9Fl7RGz4HEJFoIRi2Hc2OX+FLs4yk4iwNRR10h2QubfLXiuCiDsPJkz/tgxLX t72msF5ExWJ9dX+a58vrYhlzq4Ol6yY69JF37dw5t6YUI8ielENSWIUu9G9nlG/FAdts hl6A12mL9bVNB7ToDqZReZUrRq7li4L90axAx5xoZDwm+PDhLpb5jIsN8kSB+L3+8LRD GUzzD9Wgs/7QTE0w+szmPDxWPEEw8M5Z8CTqzUv/1U3GuqGkCvcFe1H2g7Z2sTIl3zJZ wMAQ== X-Received: by 10.180.73.230 with SMTP id o6mr7102751wiv.30.1429717760253; Wed, 22 Apr 2015 08:49:20 -0700 (PDT) Received: from [192.168.1.7] ([92.247.26.34]) by mx.google.com with ESMTPSA id fa8sm8303145wib.14.2015.04.22.08.49.18 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Apr 2015 08:49:19 -0700 (PDT) Message-ID: <5537C2FE.7070907@gmail.com> Date: Wed, 22 Apr 2015 18:49:18 +0300 From: Peter Slavov Organization: sumup User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:36.0) Gecko/20100101 Icedove/36.0 MIME-Version: 1.0 To: Andres Freund CC: pgsql-bugs@postgresql.org Subject: Re: BUG #12910: Memory leak with logical decoding References: <20150327094757.2488.58808@wrigleys.postgresql.org> <20150331144048.GL4878@alap3.anarazel.de> <55227D87.9080007@gmail.com> <20150406135026.GJ17586@awork2.anarazel.de> <5526969F.4050704@gmail.com> <20150409173455.GE9764@awork2.anarazel.de> In-Reply-To: <20150409173455.GE9764@awork2.anarazel.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Hi, Sorry for the late answer - I got mixed up with the wrong Postgres version and waste time testing on code that is not pached. I did testing after that on the patched version and basically I don't see difference when I use simple sql statement like before. Psql is putting all in RAM/swap before dumping it out ( the size is again ~15-16 GB - no change there). I tried with copy - much better memory footprint of course. I guess I will have to forget using the SQL interface. I will try using pg_recvlogical or some other way to connect my python script to the slot using the streaming protocol .. thanks Peter На 9.04.2015 в 20:34, Andres Freund написа: > Hi, > > On 2015-04-09 18:11:27 +0300, Peter Slavov wrote: >> I prepared a test case, that can reproduce the problem. > Yup. I can reproduce it... I did not (yet) have the time to run the test > to completion, but i believe the attached patch should fix the problem > (and also improve performance a bit...). > > Using the SQL interface for such large transactions isn't going to be > fun as all of the data, due to the nature of the set returning function > implementation in postgres, will be additionally written into a > tuplestore. The streaming interface doesn't have that behaviour. > > Additionally it's probably not a good idea to stream such a large > resultset via SELECT using psql - IIRC it'll try to store all that data > in memory :). Try something like > \copy (select * from pg_logical_slot_peek_changes('testing', null, 1)) TO /tmp/f > or such. > > Greetings, > > Andres Freund -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs