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 1i9y3t-0000XX-Qc for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Sep 2019 20:57:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i9y3r-0001n7-N4 for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Sep 2019 20:57: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_SHA1:256) (Exim 4.89) (envelope-from ) id 1i9y3r-0001mk-At for pgsql-hackers@lists.postgresql.org; Mon, 16 Sep 2019 20:57:27 +0000 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i9y3o-0004Jd-1X for pgsql-hackers@postgresql.org; Mon, 16 Sep 2019 20:57:26 +0000 Received: by mail-wm1-x341.google.com with SMTP id i16so807527wmd.3 for ; Mon, 16 Sep 2019 13:57:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=B9fYJXVB4Z8JAAdSKIwFYgR9Mh9ZcW8I2c8QUS1t7lc=; b=q/BuRqmmXv0teonT/okb1urVzXa0ddQwwz8UsHh51iHAmaTEtrTF6Jl5nj7HneIarH hHP7wIo+zk2viTD3mGY4ntWlSNxV5oqgJ/MVxVj/3/8femqKzw6dGdL8CK2FZTKoyj8y dkDoAmgFUv7yJ5ERmP4/5NKXFaJ755Mxk+0EJDtQoGMmvesjNBslOBTa22DNKLXzuZ1F WxrmJ5Bo23aof0uH8X1Btx0R/VliYMTsCnvPVKyu/bVZxGOlgWqlDI9th0pHZWtA36Ao gJ4iUhu/6jqC4rtHqXZem5ZdfYoSkZA9MMnIsr5jcTTP+svI4hVKreickSan1w2U4E81 7nZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=B9fYJXVB4Z8JAAdSKIwFYgR9Mh9ZcW8I2c8QUS1t7lc=; b=QoKmlnHmToZdEdfre9ejch6CUogKsa+6Jlw8zJ/4LajCWsUjEd5CwoteuvmH9Mdnh9 aHV31c0/jWztK53XVXp6PP0kqUr91ODbEjuZxVFOjzDUm44r/yOmydhUJ497Fwq6ydYu lF837LKAQda4AAWNLQBINo1MDJ843rzOpAr1kVE7Fddi6bj5TWljXOuOpG1Gi8MjhZTE oLPsgFC9yBIucM7HamLM0gjmYOqXn/eQTvY1AgGhGEugTa5Qo40chzS6hI9lMBhWkeph nmEBqXstgs8BZ9s8ExnceE3X0sENBCA3FfQmoBtIjWchzZmEdFN2Vv541F45oLSKQ5Dm YJtg== X-Gm-Message-State: APjAAAUP5DJNmImHhoNjuR3a4VYgD26TkYezSWz9Ewau2vZOHCcdoTby ldL4xP7P5YkZJ9g1CFQqlmthuA== X-Google-Smtp-Source: APXvYqw9pkcLHFsl7HzgBfnzcT7488cM8CM0YrJHkNxJS1GzUvvFt0qVaqIoilX+gndbPsf1Y6jb8w== X-Received: by 2002:a1c:f209:: with SMTP id s9mr767623wmc.60.1568667442061; Mon, 16 Sep 2019 13:57:22 -0700 (PDT) Received: from localhost (ip-86-49-253-183.net.upcbroadband.cz. [86.49.253.183]) by smtp.gmail.com with ESMTPSA id s12sm68498wra.82.2019.09.16.13.57.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2019 13:57:21 -0700 (PDT) Date: Mon, 16 Sep 2019 22:57:19 +0200 From: Tomas Vondra To: Konstantin Knizhnik Cc: Alexey Kondratov , Peter Eisentraut , Erik Rijkers , Masahiko Sawada , PostgreSQL Hackers Subject: Re: PATCH: logical_work_mem and logical streaming of large in-progress transactions Message-ID: <20190916205719.mnyytrsredcuf2or@development> References: <126e3a30-a7f5-ede4-2bd0-b217749c8b33@postgrespro.ru> <8eda5118-2dd0-79a1-4fe9-eec7e334de17@postgrespro.ru> <20190828190646.s3bjs22urff32k56@development> <20190829184824.kmrbchrk2ged6vjw@development> <322e40c4-8ca7-6c34-2544-28a6d95989c2@postgrespro.ru> <50a87b09-a5cd-bb13-1d10-41d4147a8a95@postgrespro.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <50a87b09-a5cd-bb13-1d10-41d4147a8a95@postgrespro.ru> User-Agent: NeoMutt/20180716 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Mon, Sep 16, 2019 at 10:29:18PM +0300, Konstantin Knizhnik wrote: > > >On 16.09.2019 19:54, Alexey Kondratov wrote: >>On 30.08.2019 18:59, Konstantin Knizhnik wrote: >>> >>>I think that instead of defining savepoints it is simpler and more >>>efficient to use >>> >>>BeginInternalSubTransaction + >>>ReleaseCurrentSubTransaction/RollbackAndReleaseCurrentSubTransaction >>> >>>as it is done in PL/pgSQL (pl_exec.c). >>>Not sure if it can pr >>> >> >>Both BeginInternalSubTransaction and DefineSavepoint use >>PushTransaction() internally for a normal subtransaction start. So >>they seems to be identical from the performance perspective, which >>is also stated in the comment section: > >Yes, definitely them are using the same mechanism and most likely >provides similar performance. >But BeginInternalSubTransaction does not require to generate some >savepoint name which seems to be redundant in this case. > > >> >>Anyway, I've performed a profiling of my apply worker (flamegraph is >>attached) and it spends the vast amount of time (>90%) applying >>changes. So the problem is not in the savepoints their-self, but in >>the fact that we first apply all changes and then abort all the >>work. Not sure, that it is possible to do something in this case. >> > >Looks like the only way to increase apply speed is to do it in >parallel: make it possible to concurrently execute non-conflicting >transactions. > True, although it seems like a massive can of worms to me. I'm not aware a way to identify non-conflicting transactions in advance, so it would have to be implemented as optimistic apply, with a detection and recovery from conflicts. I'm not against doing that, and I'm willing to spend some time on revies etc. but it seems like a completely separate effort. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services