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 1jsMBh-00049M-BK for pgsql-novice@arkaria.postgresql.org; Mon, 06 Jul 2020 08:09:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jsMBf-0002uG-VI for pgsql-novice@arkaria.postgresql.org; Mon, 06 Jul 2020 08:09:15 +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 1jsMBf-0002u9-KT for pgsql-novice@lists.postgresql.org; Mon, 06 Jul 2020 08:09:15 +0000 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jsMBc-0003xC-9x for pgsql-novice@lists.postgresql.org; Mon, 06 Jul 2020 08:09:15 +0000 Received: by mail-wm1-x341.google.com with SMTP id o2so40858809wmh.2 for ; Mon, 06 Jul 2020 01:09:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:date:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=bEv4xvH03cbI5V8Or7HHPfcmpQ37MV7q+T0722JucE4=; b=SrXbLfb78IZkv53CXk58Rv83uzEg46FxR5ATPmII7LM9F0ABvRHMTdVx4r7ZeIJSbm bk4pOvtlZCKTlPJGZVHxMdFRYQybalAt/Rv7+Az0NRd+pz6F4tKXrYa6e+F3wx8lyBOe TAqi3kAK5mPMVhqf3v/iIrLXu9ZewG74JYyn7EXIDLKMZ/GdkB7u7brVt9E2NdMTx/NK r2qq22rYfkL0r29gNkTB6BM9wlcJwesYQMj5rvBizTFe2JkdAsMPEY6xyxqninkp8097 5NDhpfHqVTUkc58lnMaD0wymV84YF9sRxBezGzOLyfu7UloxUkLcXMCZoIvfhrz0Q6T2 zd5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=bEv4xvH03cbI5V8Or7HHPfcmpQ37MV7q+T0722JucE4=; b=k+ZYaJK+24j12JtehsaKpCZrwbMtlVHn3WtsrW7B49LvrlpX2hdSkIYcjl1Pz28a7y 6YRjkTyVR2sSnqxFxFtyhRgnEbRcLkzHVRnKN5l1u6HI6yLEaBPQrs15H7ZF/gXzwG9d 0Oe9ExwMcom6coCU+qICipupFFdy/sfnLcqbplZlmyQ0iMtZZnoH9YTwixQSKc2Pmu71 2VN9FoQoZix3fNBHOvQb8gIKYzqE44mhaIvzYBapYz4b0j2rzkkR2VkvIEVN2AbUGDv9 nCKZho8s+KzOQIgEKdvkPGn04UeEytfbhf/4rsTXKDoXhvnK5/dN419i8f/xhojQVXka 361g== X-Gm-Message-State: AOAM532T9yg48fu8DAjh+Wckv5653ZzRKHVdTD2/Siz2K319n1+bB4NA 8T90WSS2iBmvdJGAGeMly77tMw== X-Google-Smtp-Source: ABdhPJxYdvrYu5qTZSvyhpflwBOFQT2FZVEIZmhCK/CB25hAUCXveqxepaw1f3i59gitvqLSQ+5g7A== X-Received: by 2002:a1c:7c19:: with SMTP id x25mr37728792wmc.176.1594022950467; Mon, 06 Jul 2020 01:09:10 -0700 (PDT) Received: from localhost.localdomain ([212.186.219.234]) by smtp.gmail.com with ESMTPSA id g3sm14047721wrb.59.2020.07.06.01.09.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2020 01:09:10 -0700 (PDT) Message-ID: <0bf46f63bd9f7e57a83710644a0ed4cf5f6c52f0.camel@cybertec.at> Subject: Re: What's the best practice to compare the transaction with the checkpoint? From: Laurenz Albe To: Jialun Zhang , pgsql-novice@lists.postgresql.org Date: Mon, 06 Jul 2020 10:09:09 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.32.5 (3.32.5-1.fc30) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Sat, 2020-07-04 at 12:19 -0400, Jialun Zhang wrote: > I am trying to add code to determine whether the transaction is checkpointed or not. > So I think I need to compare the transaction ID with the checkpoint's and determine > whether it is older or not. Could anyone tell me what's the best practice of doing > this in Postgres? Is it done somewhere in the existing code? You could use SELECT next_xid FROM pg_control_checkpoint(); to get information about the last checkpoint. I refrain from asking what the point of the exercise is... Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com