title: What is the difference between restart_lsn and confirmed_flush_lsn in Postgresql?
body: <p>As <a href="https://www.postgresql.org/docs/14/view-pg-replication-slots.html" rel="noreferrer">documentation</a> said - <code>restart_lsn</code> is:</p>
  <blockquote>
  <p>The address (LSN) of oldest WAL which still might be required by the consumer of this slot and thus won't be automatically removed during checkpoints unless this LSN gets behind more than max_slot_wal_keep_size from the current LSN. NULL if the LSN of this slot has never been reserved.</p>
  </blockquote>
  <p>And <code>confirmed_flush_lsn</code> is:</p>
  <blockquote>
  <p>The address (LSN) up to which the logical slot's consumer has confirmed receiving data. Data older than this is not available anymore. NULL for physical slots.</p>
  </blockquote>
  <p>The thing i do not understand (in case of logical slots) is - how do this both properties connected to each other? <code>confirmed_flush_lsn</code> description said that older logs are deleted, but <code>restart_lsn</code> sound like it is not 100% right. If not and there is some number of transaction logs between <code>restart_lsn</code> and <code>confirmed_flush_lsn</code> - how much could this number be? Is it some predefined and immutable value, lets say several MBs or it could it really raise up to <code>max_slot_wal_keep_size</code>? How it is decided - what <code>WAL still might be required by the consumer</code> and what not?</p>