Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id D084F1337B43 for ; Sat, 19 Feb 2011 08:30:08 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 03958-04 for ; Sat, 19 Feb 2011 12:30:01 +0000 (UTC) X-Greylist: delayed 00:06:38.079534 by SQLgrey-1.7.6 Received: from 63.mail-out.ovh.net (63.mail-out.ovh.net [91.121.185.56]) by mail.postgresql.org (Postfix) with SMTP id 1517F1336FA7 for ; Sat, 19 Feb 2011 08:30:00 -0400 (AST) Received: (qmail 11501 invoked by uid 503); 19 Feb 2011 13:06:25 -0000 Received: from b6.ovh.net (HELO mail610.ha.ovh.net) (213.186.33.56) by 63.mail-out.ovh.net with SMTP; 19 Feb 2011 13:06:25 -0000 Received: from b0.ovh.net (HELO queueout) (213.186.33.50) by b0.ovh.net with SMTP; 19 Feb 2011 14:23:20 +0200 Received: from par69-8-88-161-102-87.fbx.proxad.net (HELO apollo13) (lists%peufeu.com@88.161.102.87) by ns0.ovh.net with SMTP; 19 Feb 2011 14:23:19 +0200 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: pgsql-performance@postgresql.org, "Clemens Eisserer" Subject: Re: Slow query execution over high latency network References: Date: Sat, 19 Feb 2011 13:23:18 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: "Pierre C" Message-ID: In-Reply-To: User-Agent: Opera Mail/10.63 (Linux) X-Ovh-Tracer-Id: 13129963239393527345 X-Ovh-Remote: 88.161.102.87 (par69-8-88-161-102-87.fbx.proxad.net) X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-Spam-Check: DONE|U 0.5/N X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201102/444 X-Sequence-Number: 42582 > > When executing huge (10kb), hibernate-generated queries I noticed that > when executed remotly over high-latency network (ping to server > 200-400ms), the query takes a lot longer to complete. > > When the query is executed remotly (psql or jdbc) it takes 1800ms to > execute, when I issue the query in an ssh terminal, I see the results > almost immediatly. > So although I should see the same latency over ssh , its way faster over > ssh. > The transmitted data is small (the wireshard-file has 22kb, attached), > and even though the umts-network is high-latency its relativly high > bandwith (~512kbit/s up, ~2mbit/s down). Well, if your upload bandwidth is really 512 kbits, uncompressed transmission of your query text should take about 0.2s, not too bad. SSH normally uses compression, so it should be a lor faster. Your attached file didn't come through. Anyway, there are several options : - different execution plan between your app and ssh+psql, which can happen if the planning uses/doesn't use your specific parameters, or if some wrong type bindings in your app force postgres not to use an index (there's been a few messages on that lately, check the archives). - dumb client versus smart client : smart client : use the protocol which sends the query text + parameters + prepare + execute in 1 TCP message, 1 ping, postgres works, 1 ping, get reply dumb client : - send prepare - wait for reply - send execute - wait for reply - send "gimme result" - wait for reply - etc > Any idea whats causing this? Maybe too small buffers somewhere? > For me it poses problem, because I am working on a 2-Tier java > application which should connect to postgres remotly - however with > every more complex query taking 2s its almost unuseable over wireless > networks (umts). If you want to ensure the fastest response time you need to ensure than one user action (click) needs one and only one roundtrip to the server before all the results are displayed. If said action needs 2 SQL queries, it ain't possible, unless (maybe) you use the asynchronous query protocol. You can also stuff multiple queries in stored procedures (but Hibernate won't be able to generate them obviously). One solution could be to put the database handling stuff inside an appserver, make your app communicate to it with a low-overhead RPC protocol (ie, not raw uncompressed XML) that minimizes the number of roudtrips, and compresses data thoroughly.