Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id F21B3633311 for ; Thu, 10 Dec 2009 12:14:50 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 91048-04 for ; Thu, 10 Dec 2009 16:14:43 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.postnewspapers.com.au (202-89-185-120.static.dsl.amnet.net.au [202.89.185.120]) by mail.postgresql.org (Postfix) with ESMTP id 817946332EF for ; Thu, 10 Dec 2009 12:14:43 -0400 (AST) Received: from localhost (access [127.0.0.1]) by mail.postnewspapers.com.au (Postfix) with ESMTP id 3C2211E0442; Fri, 11 Dec 2009 00:14:42 +0800 (WST) X-Virus-Scanned: Debian amavisd-new at postnewspapers.com.au Received: from mail.postnewspapers.com.au ([127.0.0.1]) by localhost (access.postnewspapers.com.au [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 8Y0iTdIYv8fH; Fri, 11 Dec 2009 00:14:40 +0800 (WST) Received: from [10.1.1.5] (124-169-88-117.dyn.iinet.net.au [124.169.88.117]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "Craig Ringer", Issuer "POST Certificate Authority" (verified OK)) by mail.postnewspapers.com.au (Postfix) with ESMTPSA id 5FB681E0440; Fri, 11 Dec 2009 00:14:40 +0800 (WST) Message-ID: <4B211E6F.1070700@postnewspapers.com.au> Date: Fri, 11 Dec 2009 00:14:39 +0800 From: Craig Ringer User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: Merlin Moncure CC: PG-General Mailing List Subject: Re: Cheapest way to poll for notifications? References: <4B20F639.4070706@postnewspapers.com.au> In-Reply-To: X-Enigmail-Version: 0.95.7 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200912/442 X-Sequence-Number: 156662 Merlin Moncure wrote: > On Thu, Dec 10, 2009 at 8:23 AM, Craig Ringer > wrote: >> Hi >> >> As Pg doesn't presently support client push for notifications arising from >> LISTEN/NOTIFY, I'm wondering if anybody here has done any research into the >> cheapest statement to issue to check for such notifications. > > notifications are sent to the client as soon as they are generated and > the socket is not otherwise being used. psql just prints the > notifcation message following a query because that happens to be a > convenient place to do it. The only polling that has to be done (if > any) is 100% client side. There is an excellent example (in C) in the > documentation showing a method of waiting on the connection socket for > notification events when the connection is not in use by the client. Aah, that makes sense. So psql is being sent (and buffering) the notification immediately, and could choose to report it promptly - say by calling recv(...) on its socket periodically using an alarm signal. Since it's not important for psql to report notifications immediately though, it only checks after statements. Right? Anyway, thanks for the explanation, it's appreciated. -- Craig Ringer