Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 11C379FB6FA for ; Fri, 25 May 2007 12:06:20 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 36102-03 for ; Fri, 25 May 2007 12:06:15 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from pop5-1.us4.outblaze.com (pop5-1.us4.outblaze.com [205.158.62.125]) by postgresql.org (Postfix) with SMTP id 96A4F9FB5E4 for ; Fri, 25 May 2007 12:06:14 -0300 (ADT) Received: (qmail 25771 invoked from network); 25 May 2007 15:06:36 -0000 Received: from unknown (HELO nbd.it.uc3m.es) (ptb:linuxmail.org?linuxmail.org@linuxmail.org@163.117.139.192) by pop5-1.us4.outblaze.com with SMTP; 25 May 2007 15:06:35 -0000 Received: from inv.it.uc3m.es (oboe.it.uc3m.es [163.117.139.101]) by nbd.it.uc3m.es (8.13.1/8.13.1/Debian-15) with ESMTP id l4PF6BbY021916; Fri, 25 May 2007 17:06:11 +0200 Received: (from ptb@localhost) by inv.it.uc3m.es (8.11.0/8.11.0) id l4PF6AW08031; Fri, 25 May 2007 17:06:10 +0200 From: "Peter T. Breuer" Message-Id: <200705251506.l4PF6AW08031@inv.it.uc3m.es> Subject: Re: general PG network slowness (possible cure) (repost) In-Reply-To: <20070525141013.GC4239@alvh.no-ip.org> from "Alvaro Herrera" at "May 25, 2007 10:10:13 am" To: "Alvaro Herrera" Date: Fri, 25 May 2007 17:06:10 +0200 (MET DST) CC: "Peter T. Breuer" , "Richard Huxton" , pgsql-performance@postgresql.org X-Anonymously-To: Reply-To: ptb@inv.it.uc3m.es X-message-flag: Had your Outlook virus, today? http://www.counterpane.com/crypto-gram-0103.html#4 X-WebTV-Stationery: Standard\; BGColor=black\; TextColor=black Reply-By: Sat, 1 Apr 2006 14:21:08 -0700 X-Mailer: ELM [version 2.4ME+ PL66 (25)] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200705/514 X-Sequence-Number: 24904 "Also sprach Alvaro Herrera:" > > I really think it would be worthwhile getting some developer to tell me > > where the network send is done in PG. > > See src/backend/libpq/pqcomm.c (particularly internal_flush()). Yes. Thanks. That looks like it. It calls secure_write continually until the buffer is empty. Secure_write is located ibe-secure.c, but I'm not using ssl, so the call reduces to just n = send(port->sock, ptr, len, 0); And definitely all those could be grouped if there are several to do. But under normal circumstances the send will be pushing against a lttle resistance (the copy to the driver/protocol stack buffer is faster than the physical network send, by a ratio of GB/s to MB/s, or 1000 to 1), and thus all these sends will probably complete as a single unit once they have been started. It's worth a try. I thought first this may be too low level, but it looks as though internal_flush is only triggered when some other buffer is full, or deliberately, so it may be useful to block until it fires. I'll try it. Peter