Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id E1EA61337BDB for ; Thu, 24 Feb 2011 17:55:04 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 14495-02-7 for ; Thu, 24 Feb 2011 21:54:55 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.softperience.eu (static-ip-217-118-26-141.inaddr.intergenia.de [217.118.26.141]) by mail.postgresql.org (Postfix) with ESMTP id 1318C1337C19 for ; Thu, 24 Feb 2011 17:54:32 -0400 (AST) Received: from radek.localnet (87-204-194-135.dg-net.pl [87.204.194.135]) by mail.softperience.eu (Postfix) with ESMTPA id B59BAC000CA; Thu, 24 Feb 2011 22:54:33 +0100 (CET) From: =?utf-8?q?Rados=C5=82aw_Smogura?= To: pgsql-jdbc@postgresql.org Subject: Re: Slow query execution over WAN network Date: Thu, 24 Feb 2011 22:55:09 +0100 User-Agent: KMail/1.13.5 (Linux/2.6.36-gentoo-r5; KDE/4.4.5; x86_64; ; ) Cc: Clemens Eisserer References: <201102241807.51960.rsmogura@softperience.eu> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <201102242255.10017.rsmogura@softperience.eu> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.899 tagged_above=-10 required=5 tests=BAYES_00=-1.9, NORMAL_HTTP_TO_IP=0.001 X-Spam-Level: X-Archive-Number: 201102/147 X-Sequence-Number: 21545 Clemens Eisserer Thursday 24 February 2011 22:06:13 > Hi, > > I tried to analyze it further, this time the query executed over UMTS > - where it took 2000ms. (ping tp server 130ms, about 2mbit/s down): > http://93.190.88.182/wireshark_umts.tcpdump > > 0-490ms: Some TCP magic going on (tcp segment of a reassembled PDU??) > 491 ms - Postgres query is sent > 680ms - 1472ms - TCP ACKs > 1642ms - Postgres - parse/bind completition > 1873ms - Postgres - Row description > 1893ms - First data Row > Row / ACK > 2053ms - Last data Row > > What makes me wonder is: > - Why does it take 500ms until the query is sent, what is that tcp > stuff happening before > - It seems until 1472ms the server is sending ACKs for the query > request, so does it take ~1000ms for the server to receive the query? > So is the query-upload the problem? > - Actual Row-Data transmission only takes 150ms. > > If its indeed the query-data upload, are there any options to compress > the stream between the jdbc-driver and postgres-server? > > Thanks, Clemens > > > You truncated times in profiler window. May I ask what time was measured > > for socket.read(), and what kind of connection did you used for this > > (dsl, umts), connection speed and min/max/avg ping time to database > > server? > > Sorry, I've deleted the profile - but about 70% were spent in > socket.read(). Ping to the db-server was about ~30ms, it was a 8mbit ADSL > line with 1M upstream. > Looking at the profile it seems reading back the data (~25kb/request) > is the problem. > > > What other operations are performed inside benchamrkQuery(), > > commit/rollback, connection open? > > Nothing, its just a: > > ResultSet rs = st.executeQuery(query); > > while (rs.next()); > > > > Did fetch size wa,s when you was making this test, enaught to get all > > records at once? > > Yes, I tried setting it higher a bit but nothing changed. > However the query only returned 12 rows - so I guess it should be > covered by default fetch size. > > Thanks, Clemens I thought about ACK, and all of this TCP stuff. Query execution should take no more then ping*4 + processing time. 1sek for send 8k and receive 30k is to big value. Execution of such simple query, with base types, works in same way like for HTTP request, request and response. No itermediate talking. Tomorrow I check exactly TCP dump. What version of PG do you use? Regards, Radek