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 1kNIjq-0006Lo-5H for pgsql-hackers@arkaria.postgresql.org; Tue, 29 Sep 2020 16:44:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kNIjo-0008UD-Ii for pgsql-hackers@arkaria.postgresql.org; Tue, 29 Sep 2020 16:44:24 +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 1kNIjo-0008U6-79 for pgsql-hackers@lists.postgresql.org; Tue, 29 Sep 2020 16:44:24 +0000 Received: from mail-qt1-x82d.google.com ([2607:f8b0:4864:20::82d]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kNIjh-00041O-Jf for pgsql-hackers@lists.postgresql.org; Tue, 29 Sep 2020 16:44:23 +0000 Received: by mail-qt1-x82d.google.com with SMTP id z2so4056576qtv.12 for ; Tue, 29 Sep 2020 09:44:17 -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:user-agent; bh=EAoRB1/2SbkK/a/PCBKT4I7oFWlSzNfGv8sxnI+u91o=; b=m12lLZtsLSrJHHDp6VGLaRNoF+wZE6N7wEDjd94gAUFMTXHkSRRUXkVJ908oKPhB52 FXUUun1sn6iBVW5qwcJ8T79FMw20xfmxhiVnbGG7023tdf7jFxU+sxGI8Pd4ayUn7tvO 0N2rKMakGmmkzhHVchDO8KagenXgfDgGR6vlK81AK3iG/khGQtuk9jLoFlgMOxwY5kRW QgNoNKl/yg/W6XIbOfKQN2LxmDrv9IyoaKsPRyibT/Qrm1l+hXBWPUQCp8nQxG1Jrwch oGRZC5JnNiq+d3pIIVRHvBRt9cbtRcWUmyeIAWgEaQ+gAliJIBF6G6s+PGtRZZhar3MM iZ9A== 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:user-agent; bh=EAoRB1/2SbkK/a/PCBKT4I7oFWlSzNfGv8sxnI+u91o=; b=VWbFPA6xJYIrcpfZnZfUwlv2zKVyykqT/oQwLY/O1BmWo7DQ5RQAISXzDGxG51cBBh JEjblFrs69mY62Th1D0rJeZaic77OTOTwRmRIReFgPAKeAe453VKUOzblOFLsPHMZW8W ladwa0XxcwHNLO+vk2SsssAFf4gxpm7p5lsua9cb4W3KkJXAh4KMgswZG3ctVYzuydXR DDGyc9ReJ0dX6ngqN+HKeDtBm3sUt/82jJa410Wf6rpBC5q5pw0wyRwJCmj1NOZ8tKP/ 1tPqImA5BMf0FvGBdcLHbFJOP0zP1dU6MSUDjVOBo16krw5/1tlGuGmmtgT3XeDqwcKl Te5Q== X-Gm-Message-State: AOAM531HkyMx7o4JhfztCyAYg1hv2i9blhHXwcYbEsTVX1JPAJWG7Vdw PDDT4eO76re2dbU0o/VZ+NLRvw== X-Google-Smtp-Source: ABdhPJzNaInaZNqDw9+IczRcRW4MJh5NGiCl+Oh4uZogzmDUIzPZ9yDm2L+L5KD4uqSk4ToA8a5puA== X-Received: by 2002:ac8:4a93:: with SMTP id l19mr4279086qtq.163.1601397855378; Tue, 29 Sep 2020 09:44:15 -0700 (PDT) Received: from perhan.alvh.no-ip.org ([190.95.19.148]) by smtp.gmail.com with ESMTPSA id d13sm5997180qti.6.2020.09.29.09.44.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Sep 2020 09:44:14 -0700 (PDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id AB8852A14FE; Tue, 29 Sep 2020 13:44:11 -0300 (-03) Date: Tue, 29 Sep 2020 13:44:11 -0300 From: Alvaro Herrera To: Pg Hackers Cc: Pavan Deolasee , Andres Freund Subject: some pointless HeapTupleHeaderIndicatesMovedPartitions calls Message-ID: <20200929164411.GA15497@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="y0ulUmNC+osPPQO6" Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --y0ulUmNC+osPPQO6 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit Hello Pavan Deolasee recently noted that a few of the HeapTupleHeaderIndicatesMovedPartitions calls added by commit 5db6df0c0117 are useless, since they are done after comparing t_self with t_ctid. That's because t_self can never be set to the magical values that indicate that the tuple moved partition. If the first test fails (so we know t_self equals t_ctid), necessarily the second test will also fail. So these checks can be removed and no harm is done. -- Álvaro Herrera 39°49'30"S 73°17'W --y0ulUmNC+osPPQO6 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-Remove-pointless-HeapTupleHeaderIndicatesMovedPartit.patch" From 953eceb701ca35c5a3c731c4318ed1465f205811 Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Tue, 29 Sep 2020 10:47:45 -0300 Subject: [PATCH] Remove pointless HeapTupleHeaderIndicatesMovedPartitions calls --- src/backend/access/heap/heapam.c | 12 ++++-------- src/backend/access/heap/heapam_visibility.c | 9 +++------ 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c index 1585861a02..868ff13453 100644 --- a/src/backend/access/heap/heapam.c +++ b/src/backend/access/heap/heapam.c @@ -2618,8 +2618,7 @@ l1: HEAP_XMAX_IS_LOCKED_ONLY(tp.t_data->t_infomask) || HeapTupleHeaderIsOnlyLocked(tp.t_data)) result = TM_Ok; - else if (!ItemPointerEquals(&tp.t_self, &tp.t_data->t_ctid) || - HeapTupleHeaderIndicatesMovedPartitions(tp.t_data)) + else if (!ItemPointerEquals(&tp.t_self, &tp.t_data->t_ctid)) result = TM_Updated; else result = TM_Deleted; @@ -3248,8 +3247,7 @@ l2: if (can_continue) result = TM_Ok; - else if (!ItemPointerEquals(&oldtup.t_self, &oldtup.t_data->t_ctid) || - HeapTupleHeaderIndicatesMovedPartitions(oldtup.t_data)) + else if (!ItemPointerEquals(&oldtup.t_self, &oldtup.t_data->t_ctid)) result = TM_Updated; else result = TM_Deleted; @@ -4485,8 +4483,7 @@ l3: HEAP_XMAX_IS_LOCKED_ONLY(tuple->t_data->t_infomask) || HeapTupleHeaderIsOnlyLocked(tuple->t_data)) result = TM_Ok; - else if (!ItemPointerEquals(&tuple->t_self, &tuple->t_data->t_ctid) || - HeapTupleHeaderIndicatesMovedPartitions(tuple->t_data)) + else if (!ItemPointerEquals(&tuple->t_self, &tuple->t_data->t_ctid)) result = TM_Updated; else result = TM_Deleted; @@ -5059,8 +5056,7 @@ test_lockmode_for_conflict(MultiXactStatus status, TransactionId xid, LOCKMODE_from_mxstatus(wantedstatus))) { /* bummer */ - if (!ItemPointerEquals(&tup->t_self, &tup->t_data->t_ctid) || - HeapTupleHeaderIndicatesMovedPartitions(tup->t_data)) + if (!ItemPointerEquals(&tup->t_self, &tup->t_data->t_ctid)) return TM_Updated; else return TM_Deleted; diff --git a/src/backend/access/heap/heapam_visibility.c b/src/backend/access/heap/heapam_visibility.c index 80bd494076..cab6a48a5d 100644 --- a/src/backend/access/heap/heapam_visibility.c +++ b/src/backend/access/heap/heapam_visibility.c @@ -607,8 +607,7 @@ HeapTupleSatisfiesUpdate(HeapTuple htup, CommandId curcid, { if (HEAP_XMAX_IS_LOCKED_ONLY(tuple->t_infomask)) return TM_Ok; - if (!ItemPointerEquals(&htup->t_self, &tuple->t_ctid) || - HeapTupleHeaderIndicatesMovedPartitions(tuple)) + if (!ItemPointerEquals(&htup->t_self, &tuple->t_ctid)) return TM_Updated; /* updated by other */ else return TM_Deleted; /* deleted by other */ @@ -653,8 +652,7 @@ HeapTupleSatisfiesUpdate(HeapTuple htup, CommandId curcid, if (TransactionIdDidCommit(xmax)) { - if (!ItemPointerEquals(&htup->t_self, &tuple->t_ctid) || - HeapTupleHeaderIndicatesMovedPartitions(tuple)) + if (!ItemPointerEquals(&htup->t_self, &tuple->t_ctid)) return TM_Updated; else return TM_Deleted; @@ -714,8 +712,7 @@ HeapTupleSatisfiesUpdate(HeapTuple htup, CommandId curcid, SetHintBits(tuple, buffer, HEAP_XMAX_COMMITTED, HeapTupleHeaderGetRawXmax(tuple)); - if (!ItemPointerEquals(&htup->t_self, &tuple->t_ctid) || - HeapTupleHeaderIndicatesMovedPartitions(tuple)) + if (!ItemPointerEquals(&htup->t_self, &tuple->t_ctid)) return TM_Updated; /* updated by other */ else return TM_Deleted; /* deleted by other */ -- 2.20.1 --y0ulUmNC+osPPQO6--