Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mMGde-0003Pc-UD for pgsql-admin@arkaria.postgresql.org; Fri, 03 Sep 2021 21:22:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mMGdd-0003eI-Rn for pgsql-admin@arkaria.postgresql.org; Fri, 03 Sep 2021 21:22:17 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mMGdd-0003eA-FJ for pgsql-admin@lists.postgresql.org; Fri, 03 Sep 2021 21:22:17 +0000 Received: from mail-qv1-xf2c.google.com ([2607:f8b0:4864:20::f2c]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mMGdZ-0004wL-PN for pgsql-admin@postgresql.org; Fri, 03 Sep 2021 21:22:16 +0000 Received: by mail-qv1-xf2c.google.com with SMTP id 93so445848qva.7 for ; Fri, 03 Sep 2021 14:22:13 -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:mime-version:content-disposition :content-transfer-encoding:in-reply-to; bh=ZA1yS3/x7pBQNOE5iriBUKSHPdt6suiCB+PRETZ9qLo=; b=XsoiTeHWiwmfXzO2jifDmJuQFFu5JHTsLOmlBQlF5H45L14+RaPeFCJgI+wPcjHkys 8aP2wOHbuor0wKcRM/e6XBjKZngSjT9li84YzRmPDIWiX0cS6WLg8PSvIIlKjkJDPGdE my6U9OJ0tBJ6fVSJEP6VLr+qwlittLgXbasp2LUoIl7GSaU28EpH60e9M2VEiS4dwQux IkO/l+Kp2wgjex9ke5oT3MWXSYsRnDeJe/jNd/h+fU3yl0lIum+UylICnIjYvMroBTqk iWzCSv4gzPUReDBQyaTCzAqqsvoK64QrM1mdNp+BYTgJG0B0+xv8OFDs3J2/p2gfqKPr B87g== 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:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=ZA1yS3/x7pBQNOE5iriBUKSHPdt6suiCB+PRETZ9qLo=; b=JR2pqyG77kXd6I8ZwbknqtMAnTOHZIhqDt/RDfKdrezT7XK/uQRpxem/UJLiNOEd9T kkq6UH2VapcPjFGC2gDUKrqbnSxtDXXmE2cvF35QsRsE/MUjqvvQdqfXkG3d7VQ03eji I7pWDG16ViAS4dfI5Bv2xSTZX40PcArC1jsIAanncOfOtUpZuE2ISiaSNxUxTmrSunDh hE19/414aidCOvfOVk2SLQ4QkkJ3Yp6p306iOQhFFRRCLATfoJ7uR1gg4+bb4kl6VhRU cHIebb94quqcJv4kK0RyV2odM9hQa/jVUEVR8iAsEFCh9YJb7qEax04rg9ClZYXX7FHx eBOA== X-Gm-Message-State: AOAM533Upq1Lo8SayagkEYxDJr5OOZsdA4fUhZeBxu3mRlN7QuhpZ/SM HKtEl3jRqfvC9lP8XyZ7UPxisA== X-Google-Smtp-Source: ABdhPJx2i+QI4jg6U40P6K7c1GJibXa+JZYXyPJ4sqRdNvluSRvATtrW196I9lwbRif/iP59u+kQ/Q== X-Received: by 2002:a0c:f2cc:: with SMTP id c12mr1185676qvm.52.1630704131470; Fri, 03 Sep 2021 14:22:11 -0700 (PDT) Received: from perhan.alvh.no-ip.org ([201.186.208.208]) by smtp.gmail.com with ESMTPSA id r128sm285391qke.98.2021.09.03.14.22.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 14:22:11 -0700 (PDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 69AC92A07D0; Fri, 3 Sep 2021 17:22:09 -0400 (-04) Date: Fri, 3 Sep 2021 17:22:09 -0400 From: Alvaro Herrera To: Henry Francisco Garcia Cortez Cc: pgsql-admin@postgresql.org, Laurenz Albe Subject: Re: bgwriter and checkpoints Message-ID: <202109032122.sym3vzjum5g3@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2021-Sep-03, Henry Francisco Garcia Cortez wrote: > Hi community, I was reading about background writer process and > checkpoints, but I still don't understand very well. How do they work for > instance I understand this if a row was updated,those changes will be on > shared buffers, then those changes will go to path on disk called pg_wall, > then when a checkpoint will be executed and finally, those changes will go > to data files when bgwriter process will be executed but I found a blog on > internet they say that after each search, the BGWRITER chooses some number > of modified pages, writes them to disk, and evicts those pages from the > shared buffer pool. Everything you wrote here is correct. Row changes are logged to WAL (which is a journal -- always written to disk), and initially remain in shared buffers. They can be written down from shared buffers to disk either at a checkpoint, or by bgwriter. If they're not written down by those processes, and the system crashes, then when the system comes back, WAL is read and replayed. This restores the change that was done before the crash. > https://flylib.com/books/en/2.290.1/the_postgresql_bgwriter_process.html I'm not familiar with this book. -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/