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 1ubptK-005tDh-MT for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Jul 2025 00:20:58 +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 1ubptI-006mzQ-PF for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Jul 2025 00:20:57 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ubptI-006mzH-Ft for pgsql-hackers@lists.postgresql.org; Wed, 16 Jul 2025 00:20:57 +0000 Received: from mail-yb1-xb2d.google.com ([2607:f8b0:4864:20::b2d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1ubptG-007y5L-2N for pgsql-hackers@postgresql.org; Wed, 16 Jul 2025 00:20:56 +0000 Received: by mail-yb1-xb2d.google.com with SMTP id 3f1490d57ef6-e8bbfef1fffso553057276.1 for ; Tue, 15 Jul 2025 17:20:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752625253; x=1753230053; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=7pMOMvlyI+/RbSL7Gj7oQACDhXXbnbfj61E3UGTZ5cQ=; b=STSui40b74c7lahKJc9BGrhJkwkVOY1jGNH7jMs8KUS8CYQug1VE094mEO33pSim0d VCGT7mU3ezSbGQBm1don2iKbJgTN8Fh/zq3VLz052fCXQtgbBnDOPJ0OYFixpYjO0Fu0 /vwnwOzDzfUSzA5jZmPi+RqRYjCUS/zTZXWCYnk0i1Lurtn/Om7BCzUAOkfCdbOM6eGx hmnELZL5cO8TV3i0/SC17aqqi+3bzEuQ6EObjP0PnYNtmuAwgkRH5Igc3lFyI4Jyy+Yx 2y8VnGlSzbNnIejv4bICMObZWSJJAYSQ0J5XPGe1AEdYHdOu3PWls1Bhpw24e0morlKg tQMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752625253; x=1753230053; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7pMOMvlyI+/RbSL7Gj7oQACDhXXbnbfj61E3UGTZ5cQ=; b=CIU9cuqyn/4cELCeDrdWPn/FuIbn2EikoP0qgjmRVvHEziNPqtdk6qFseqKlLXSqhW 9psKMqXlnUK1Ioxi6KlyM+Ur1EmwyGp55D3G26Qy2l4F4infNCgoZU16zcbNqMu/7u8a kEnbCYmsPVaoHbH5GZqM99Vzlr/4k8Vr3zeziDZGJUUPos5x6hlUc3p9CKxaQQYv6c2R o5mDqZ6VwwjZpKCAEWdwrn9s1J9Pec67Vyrd/wOcFZBii//KD6aAQYN3FiJTjges/XuM p9hPnAe5llAnT2FuQCP8rciHMlrsZd3smZT4nTU+O86lrhtT+5zHapyjmRQ4Ot9Pq0t8 Wnpw== X-Gm-Message-State: AOJu0YxM/04gkQRUiGchLupcfF+oGyg+NxGNpHVd4hGhGglxzFhoKT3Z WefWTvX+GfA++n3GPMQyivmeZMvoC1Ah01kfnwU72+SgR7GVt7XWldVh6LeMn+5r/vaQ4QSxmIV LfGAPEgr4xeLXzBSrq93c4Pjft+MC5bDrKJLA X-Gm-Gg: ASbGncsXfURxZzhPsR/98INd7liZ+ypVjpFbBNlLyJRyH09nnpXB3j7lMJHRsrIEhsr IUEAaC9Hj3gnjHvgf59iSLzn19U/lmDq/Xm9Vlz/ULLIYV+QzP8QOTHhPLOYfwHgf8qOBItKZ5D P3JdT+fCBJYn2Tr4V/rfYw420z4uP9WdHB3WAp+1Xppol80avZq+gwp2IFYoTQuau18/CnloBY1 xF0oke7Ag== X-Google-Smtp-Source: AGHT+IG33iVzPk72zIgeLY36o/chbln0Of4KSt2wMCi8QNPD2X1r84CJFEuGXI+/gTlKIpemxztI6VSGVwbTKTPiMCc= X-Received: by 2002:a05:690c:6385:b0:710:f1da:1b5f with SMTP id 00721157ae682-7183753967bmr10553167b3.34.1752625253101; Tue, 15 Jul 2025 17:20:53 -0700 (PDT) MIME-Version: 1.0 References: <6899c044-4a82-49be-8117-e6f669765f7e@app.fastmail.com> <165530.1752362320@sss.pgh.pa.us> <02a7cd37-e2fc-4212-8b19-f8c239c95fb8@app.fastmail.com> In-Reply-To: From: Rishu Bagga Date: Tue, 15 Jul 2025 17:20:42 -0700 X-Gm-Features: Ac12FXy_KGphL6P4atH8xNTAxzuuMkZjXCRYiO4Mg2yf-pFrNdWEROJdDu9eZSY Message-ID: Subject: Re: Optimize LISTEN/NOTIFY To: Joel Jacobson Cc: pgsql-hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Joel, Thanks for sharing the patch. I have a few questions based on a cursory first look. > If a single listener is found, we signal only that backend. > Otherwise, we fall back to the existing broadcast behavior. The idea of not wanting to wake up all backends makes sense to me, but I don=E2=80=99t understand why we want this optimization only for the c= ase where there is a single backend listening on a channel. Is there a pattern of usage in LISTEN/NOTIFY where users typically have either just one or several backends listening on a channel? If we are doing this optimization, why not maintain a list of backends for each channel, and only wake up those channels? Thanks, Rishu