Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id C16AB6332EF for ; Fri, 11 Dec 2009 11:42:47 -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 94034-02 for ; Fri, 11 Dec 2009 15:42:39 +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 C7D8D6341DD for ; Fri, 11 Dec 2009 11:39:33 -0400 (AST) Received: from localhost (access [127.0.0.1]) by mail.postnewspapers.com.au (Postfix) with ESMTP id 10C861E044A for ; Fri, 11 Dec 2009 23:39:26 +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 rYkA+l14mkof for ; Fri, 11 Dec 2009 23:39:22 +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 0854C1E0448 for ; Fri, 11 Dec 2009 23:39:22 +0800 (WST) Message-ID: <4B2267A9.1080302@postnewspapers.com.au> Date: Fri, 11 Dec 2009 23:39:21 +0800 From: Craig Ringer User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: PG-General Mailing List Subject: Re: Cheapest way to poll for notifications? References: 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/493 X-Sequence-Number: 156713 Scott, Tom, Merlin: Thanks for the comments and help. It's all sorted now - the origin of the confusion was some outdated information in the JDBC driver documentation. The question arose because I was originally looking at polling from JDBC (which I know I forgot to mention), where the docs state that: "A key limitation of the JDBC driver is that it cannot receive asynchronous notifications and must poll the backend to check if any notifications were issued." http://jdbc.postgresql.org/documentation/84/listennotify.html .... and show a `SELECT 1' being issued to push any notifications. I'd assumed that was a JDBC limitation until I tested with psql and found that it, too, required some kind of client-initiated communication to see NOTIFY events, at which point I began wondering if the backend pushed them at all rather than waiting for client interaction. Hence my question. Anyway, as pointed out, psql just doesn't bother polling for notifications because it's not important for psql, but it could if it needed to - the notifications are waiting in its recieve buffer for it to notice and care. As for the JDBC driver - it turns out that the documentation is out-of-date and/or misleading. The JDBC driver *does* support reading notifications the backend has pushed to its receive buffer, and does *not* have to poll the backend or issue a statement to receive notifications. Some searching suggests that this changed in 8.0 or 8.1 . The documentation needs adjusting, so I've sent a patch to it off to the JDBC folks. -- Craig Ringer