Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r50EP-00BMUd-H4 for pgsql-hackers@arkaria.postgresql.org; Mon, 20 Nov 2023 09:06:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1r50EO-006zol-5b for pgsql-hackers@arkaria.postgresql.org; Mon, 20 Nov 2023 09:06:12 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r50EN-006zaL-LH for pgsql-hackers@lists.postgresql.org; Mon, 20 Nov 2023 09:06:11 +0000 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1r50EI-006RuC-IU for pgsql-hackers@lists.postgresql.org; Mon, 20 Nov 2023 09:06:10 +0000 Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-9fa45e75ed9so224283266b.1 for ; Mon, 20 Nov 2023 01:06:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20230601.gappssmtp.com; s=20230601; t=1700471165; x=1701075965; darn=lists.postgresql.org; h=message-id:date:mime-version:subject:to:from:from:to:cc:subject :date:message-id:reply-to; bh=RXvz52afW1GSCIV0HU1i95A26ogxjbV2W3yCLCZzy6s=; b=tzWc0GohLGQLqYdtjIpgjTS1vKkGaEl7jXB94v4k/MPCYEMRo7Tg9ebOp+qefOHNQd iWBkiFN2oBuOeOuvQ9IkO9ISQ2dDYs+Jb/+53drJb8xvZAjeXP1i8KqW51fXdjwZAxpt 2ssj8jdedBGFEd6+hNHjGnYNauqwElO8AEdOgLcvj3HngRTMOPsHXYkJob1JAoRoZHPx OVwvNlpIh32SvTBV6q6daB4aNmD+NJCytSxs6EPdYu5w4UCLnldRCLkYPjWOdx15tFgS 5t8FBUX0tqxtehm9jmIUs8uzuZtzmNPxDfbYxIfUuxmgn80f1X36hc+SnH2CYnjj2WhW 38CA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700471165; x=1701075965; h=message-id:date:mime-version:subject:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=RXvz52afW1GSCIV0HU1i95A26ogxjbV2W3yCLCZzy6s=; b=vfTdS3dlGGnIlzgr/NZVEXsW4YGH9H6j2ttiqfHf2veXbvnAw392jFjv6/l5w4jb4M 3McPSPjFonivXv38XRUQTatjpQAk+2dlZ5BiGEBGENOoiunJgBBU2I+TaGcfXRn5Y3R4 AsbaMznsEE0HlzEGPqVTENLt2x/gJYJgZId/Bjvm2+WY7rpzKZn6RmIgdEmcmk00HyRG rb39uDikuuU6obZEtDp7z0CCODCVFOaqpLdrZOnpUKwY+nBw7ShQhmd0gybfzMXCKADE 3xyJSpcisjmIO77mcutCa1gQbscRibfKyh3lPw0HRWVJ7/TarnFZ1GLzzciKqA9XX5qp Ef0A== X-Gm-Message-State: AOJu0YyVkIO9x2QZYIVxRFfRJ99QD+Aq07y6RX0CS5pRfhEu2xUyf9iA DNmkwYjk7fT+tT768A9OrJLMW9bTaaLP9HLwL10= X-Google-Smtp-Source: AGHT+IG6w8nu5y3pd0usgphRNx7ceL+fHGMw2Vyzx8BtDafhYRh1tPj4POSWeDFLS/nc3eIxFf4btQ== X-Received: by 2002:a17:906:1f06:b0:9ce:96db:c83e with SMTP id w6-20020a1709061f0600b009ce96dbc83emr5292608ejj.42.1700471164641; Mon, 20 Nov 2023 01:06:04 -0800 (PST) Received: from antos (109-81-174-152.rct.o2.cz. [109.81.174.152]) by smtp.gmail.com with ESMTPSA id l18-20020a170906645200b009ad89697c86sm3717045ejn.144.2023.11.20.01.06.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 01:06:04 -0800 (PST) From: Antonin Houska To: pgsql-hackers@lists.postgresql.org Subject: Stop the search once replication origin is found X-Mailer: MH-E 8.6+git; nmh 1.8; GNU Emacs 28.2.50 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Date: Mon, 20 Nov 2023 10:07:53 +0100 Message-ID: <2694.1700471273@antos> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --=-=-= Content-Type: text/plain Although it's not performance-critical, I think it just makes sense to break the loop in replorigin_session_setup() as soon as we've found the origin. -- Antonin Houska Web: https://www.cybertec-postgresql.com --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=replorigin_session_setup_break.diff diff --git a/src/backend/replication/logical/origin.c b/src/backend/replication/logical/origin.c index b0255ffd25..460e3dcc38 100644 --- a/src/backend/replication/logical/origin.c +++ b/src/backend/replication/logical/origin.c @@ -1144,6 +1144,7 @@ replorigin_session_setup(RepOriginId node, int acquired_by) /* ok, found slot */ session_replication_state = curstate; + break; } --=-=-=--