pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alexey Kondratov <a.kondratov@postgrespro.ru>
To: Kuntal Ghosh <kuntalghosh.2007@gmail.com>
To: Dilip Kumar <dilipbalaut@gmail.com>
Cc: vignesh C <vignesh21@gmail.com>
Cc: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Cc: Amit Kapila <amit.kapila16@gmail.com>
Cc: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Subject: Re: PATCH: logical_work_mem and logical streaming of large in-progress transactions
Date: Tue, 12 Nov 2019 13:42:35 +0300
Message-ID: <6b0edf8b-0b33-f862-dfb2-d8bb2b568465@postgrespro.ru> (raw)
In-Reply-To: <CAGz5QCKwfgGnuzzJ3wRi=4Afpgen4Ar7gJqJqEsSzDfM1+zrAw@mail.gmail.com>
References: <CAA4eK1J7NajKPE58Vnf5pBtwR3upxATUCRFoR04BPKbKBes5hw@mail.gmail.com>
	<CAA4eK1LCk4aAeTv8SofwgmKLaFakj+Sn4Y7MLEJORX0BjY2hGw@mail.gmail.com>
	<CAA4eK1+-F_ELz+n3S9bBN8kOgZ6ww67tOoy99f8Ug39RWXH20w@mail.gmail.com>
	<20191001135151.swlspdnkxxnhszhn@development>
	<CAA4eK1KB_N-gUNgUN9KysJyBnnVWd7_sE9x53EYQyv3XjVGojw@mail.gmail.com>
	<20191002223254.wgftz4rzwd2m57gn@development>
	<CAFiTN-vHoksqvV4BZ0479NhugGe4QHq_ezngNdDd-YRQ_2cwug@mail.gmail.com>
	<CAA4eK1KAaiGBwZ=aDJ4f+Pazq3UJ8fsjPqa0+JfpM49ieSjtBA@mail.gmail.com>
	<CAFiTN-vdWS66KQDkz+Xf4KK3hWBJs6durSwTUuG+PQs-P29hxA@mail.gmail.com>
	<20191022172210.26bdiv44vwvunrh3@development>
	<CALDaNm02dKYU6Kt8we9WeGgYWzpYvTSPkxU9hXqwzvCkNGATnw@mail.gmail.com>
	<CAFiTN-vrSNkAfRVrWKe2R1dqFBTubjt=DYS=jhH+jiCoBODdaw@mail.gmail.com>
	<CAGz5QC+WsBwdY3=qH6qZ38siocF1T1Ub7xB0JnPZiDjrOuFLTQ@mail.gmail.com>
	<CAFiTN-uvs1jO4QTvnR-UDxZHuE47-tSLc-BRzayjzyA0Zyz0pg@mail.gmail.com>
	<CAGz5QCKwfgGnuzzJ3wRi=4Afpgen4Ar7gJqJqEsSzDfM1+zrAw@mail.gmail.com>

On 04.11.2019 13:05, Kuntal Ghosh wrote:
> On Mon, Nov 4, 2019 at 3:32 PM Dilip Kumar <dilipbalaut@gmail.com> 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






view thread (536+ messages)  latest in thread

Message-ID: <6b0edf8b-0b33-f862-dfb2-d8bb2b568465@postgrespro.ru>
Permalink:  ../6b0edf8b-0b33-f862-dfb2-d8bb2b568465@postgrespro.ru/
Also on:    postgresql.org/message-id/6b0edf8b-0b33-f862-dfb2-d8bb2b568465@postgrespro.ru

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: a.kondratov@postgrespro.ru, kuntalghosh.2007@gmail.com, dilipbalaut@gmail.com, vignesh21@gmail.com, tomas.vondra@2ndquadrant.com, amit.kapila16@gmail.com, peter.eisentraut@2ndquadrant.com
  Subject: Re: PATCH: logical_work_mem and logical streaming of large in-progress transactions
  In-Reply-To: <6b0edf8b-0b33-f862-dfb2-d8bb2b568465@postgrespro.ru>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox