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.89) (envelope-from ) id 1iUTdF-00082S-DR for pgsql-hackers@arkaria.postgresql.org; Tue, 12 Nov 2019 10:42:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iUTdC-0000Dy-TF for pgsql-hackers@arkaria.postgresql.org; Tue, 12 Nov 2019 10:42:42 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1iUTdC-0000Dr-FW for pgsql-hackers@lists.postgresql.org; Tue, 12 Nov 2019 10:42:42 +0000 Received: from cyclops.postgrespro.ru ([93.174.131.138] helo=mail.postgrespro.ru) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iUTd9-0000J7-Dh for pgsql-hackers@postgresql.org; Tue, 12 Nov 2019 10:42:41 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 6C49921C48A5; Tue, 12 Nov 2019 13:42:37 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=x tagged_above=-99 required=4 WHITELISTED tests=[] autolearn=unavailable Received: from [192.168.27.223] (gw.postgrespro.ru [93.174.131.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id E332121C489C; Tue, 12 Nov 2019 13:42:35 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1573555357; bh=XCenR1hKGv+yqkjqxJKQNy8DdSSbr2DLnf674iYWsPI=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=aMM+a43oJ4FpAhNISsr5CyGso0URqUAZuN34W+nrUIsD5oTj0yKrS+v9ZWc3KjNed ySTi7qK2NIbMy7UdDaMPt/6r26wkQa2QuhGRDAv9zZcGUPQNDAwAFwjXZG5ByouWBO dwwk5KOh7HARutYhvWaYqLI+fIKvdX3a4R/giEmw= Subject: Re: PATCH: logical_work_mem and logical streaming of large in-progress transactions To: Kuntal Ghosh , Dilip Kumar Cc: vignesh C , Tomas Vondra , Amit Kapila , Peter Eisentraut , PostgreSQL Hackers References: <20191001135151.swlspdnkxxnhszhn@development> <20191002223254.wgftz4rzwd2m57gn@development> <20191022172210.26bdiv44vwvunrh3@development> From: Alexey Kondratov Message-ID: <6b0edf8b-0b33-f862-dfb2-d8bb2b568465@postgrespro.ru> Date: Tue, 12 Nov 2019 13:42:35 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 04.11.2019 13:05, Kuntal Ghosh wrote: > On Mon, Nov 4, 2019 at 3:32 PM Dilip Kumar wrote: >> So your result shows that with "streaming on", performance is >> degrading? By any chance did you try to see where is the bottleneck? >> > Right. But, as we increase the logical_decoding_work_mem, the > performance improves. I've not analyzed the bottleneck yet. I'm > looking into the same. My guess is that 64 kB is just too small value. In the table schema used for tests every rows takes at least 24 bytes for storing column values. Thus, with this logical_decoding_work_mem value the limit should be hit after about 2500+ rows, or about 400 times during transaction of 1000000 rows size. It is just too frequent, while ReorderBufferStreamTXN includes a whole bunch of logic, e.g. it always starts internal transaction: /*  * Decoding needs access to syscaches et al., which in turn use  * heavyweight locks and such. Thus we need to have enough state around to  * keep track of those.  The easiest way is to simply use a transaction  * internally.  That also allows us to easily enforce that nothing writes  * to the database by checking for xid assignments. ...  */ Also it issues separated stream_start/stop messages around each streamed transaction chunk. So if streaming starts and stops too frequently it adds additional overhead and may even interfere with current in-progress transaction. If I get it correctly, then it is rather expected with too small values of logical_decoding_work_mem. Probably it may be optimized, but I am not sure that it is worth doing right now. Regards -- Alexey Kondratov Postgres Professional https://www.postgrespro.com Russian Postgres Company