Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 5589363360A for ; Mon, 21 Dec 2009 04:16:29 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 29714-02-9 for ; Mon, 21 Dec 2009 08:16:11 +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 217276347B1 for ; Mon, 21 Dec 2009 03:52:34 -0400 (AST) Received: from [10.0.0.53] (wallace.localnet [10.0.0.53]) by mail.postnewspapers.com.au (Postfix) with ESMTP id 1D3D41E044A; Mon, 21 Dec 2009 15:52:30 +0800 (WST) Message-ID: <4B2F293E.5090103@postnewspapers.com.au> Date: Mon, 21 Dec 2009 15:52:30 +0800 From: Craig Ringer User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: Maciek Sakrejda CC: PG-JDBC Mailing List Subject: Re: Cheapest way to poll for notifications? & Driver improvement question re SSL and notify References: <4B2267A9.1080302@postnewspapers.com.au> <4B2C7A13.9080807@postnewspapers.com.au> <895e58dd0912201724r6b798469t4879e48a0d0abae2@mail.gmail.com> In-Reply-To: <895e58dd0912201724r6b798469t4879e48a0d0abae2@mail.gmail.com> X-Enigmail-Version: 0.95.7 Content-Type: multipart/mixed; boundary="------------060308010507050607030202" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.345 tagged_above=-10 required=5 tests=AWL=0.254, BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200912/73 X-Sequence-Number: 20154 This is a multi-part message in MIME format. --------------060308010507050607030202 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Maciek Sakrejda wrote: >> So my question is: is there any particularly low-overhead statement that >> might be suitable for generating pointless client/server chat to check for >> received async notifications? Should I just use "SELECT 1" ? Or would I be >> better off using a SHOW statement like "SHOW role" to avoid creating a >> snapshot etc? >> > > Does the jdbc driver work with EmptyQueryResponse? It seems to. > At the protocol > level, if you send a Query message with an all-whitespace sql string, > the backend is supposed to reply with a single EmptyQueryResponse > message and then issue ReadyForQuery again. I have a feeling that jdbc > is probably "too smart" for this to work, but it could be worth a > shot. The JDBC driver isn't too smart for this - it doesn't catch the empty query, but instead merrily passes it on to the backend as part of an extended query request. See the attached text file - it shows the client/server chat for one such round trip. So: the server doesn't consider the empty query an error, so it won't affect any currently running transactions. It's a cheap single-message each way round-trip, and it doesn't have any planning or snapshot creation costs. Looks good to me :-) Since I can't imagine an app _needing_ the JDBC driver to ignore empty queries, is this something that it might be reasonable to document as expected behavior from the driver - that it _will_ send even empty queries to the server? Thanks _VERY_ much for the tip. You've saved me and my logs quite a bit of pain. It's not as good as client-side-only polling, but it's a whole nicer than a full dummy statement, and I can easily do it only when an SSL connection is detected. -- Craig Ringer --------------060308010507050607030202 Content-Type: text/plain; name="trace.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="trace.txt" No. Time Source Destination Protocol Info 178 40.633175 127.0.0.1 127.0.0.1 PGSQL >P/B/D/E/S Frame 178 (110 bytes on wire, 110 bytes captured) Ethernet II, Src: 00:00:00_00:00:00 (00:00:00:00:00:00), Dst: 00:00:00_00:00:00 (00:00:00:00:00:00) Internet Protocol, Src: 127.0.0.1 (127.0.0.1), Dst: 127.0.0.1 (127.0.0.1) Transmission Control Protocol, Src Port: 59141 (59141), Dst Port: postgresql (5432), Seq: 3574, Ack: 53702, Len: 44 PostgreSQL Type: Parse Length: 8 Statement: Query: Parameters: 0 PostgreSQL Type: Bind Length: 12 Portal: Statement: Parameter formats: 0 Parameter values: 0 Result formats: 0 PostgreSQL Type: Describe Length: 6 Portal: PostgreSQL Type: Execute Length: 9 Portal: Returns: all rows PostgreSQL Type: Sync Length: 4 No. Time Source Destination Protocol Info 179 40.633290 127.0.0.1 127.0.0.1 PGSQL <1/2/n/I/Z Frame 179 (92 bytes on wire, 92 bytes captured) Ethernet II, Src: 00:00:00_00:00:00 (00:00:00:00:00:00), Dst: 00:00:00_00:00:00 (00:00:00:00:00:00) Internet Protocol, Src: 127.0.0.1 (127.0.0.1), Dst: 127.0.0.1 (127.0.0.1) Transmission Control Protocol, Src Port: postgresql (5432), Dst Port: 59141 (59141), Seq: 53702, Ack: 3618, Len: 26 PostgreSQL Type: Parse completion Length: 4 PostgreSQL Type: Bind completion Length: 4 PostgreSQL Type: No data Length: 4 PostgreSQL Type: Empty query Length: 4 PostgreSQL Type: Ready for query Length: 5 Status: Idle (73) --------------060308010507050607030202--