Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id BF429635269 for ; Fri, 15 Jan 2010 20:14:41 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 20171-08 for ; Sat, 16 Jan 2010 00:14:24 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from web2.nidhog.com (web2.nidhog.com [66.207.132.3]) by mail.postgresql.org (Postfix) with ESMTP id 1451463359F for ; Fri, 15 Jan 2010 20:14:30 -0400 (AST) Received: from XP2 (pool-71-253-4-223.pitbpa.east.verizon.net [71.253.4.223]) (authenticated bits=0) by web2.nidhog.com (8.14.3/8.13.8) with ESMTP id o0G0EJWO035231; Fri, 15 Jan 2010 19:14:21 -0500 (EST) (envelope-from john@johntdow.com) Message-Id: <201001160014.o0G0EJWO035231@web2.nidhog.com> From: "John T. Dow" To: "Oliver Jowett" Cc: "pgsql-jdbc@postgresql.org" Date: Fri, 15 Jan 2010 19:13:57 -0500 X-Mailer: PMMail 2000 Professional (2.20.2717) For Windows 2000 (5.1.2600;3) In-Reply-To: <4B50F92D.5020403@opencloud.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Subject: Re: refreshRow is slow X-Nidhog-MailScanner-Information: Please contact the ISP for more information X-Nidhog-MailScanner: Found to be clean X-Nidhog-MailScanner-From: john@johntdow.com 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: 201001/32 X-Sequence-Number: 20228 >> I repeated this with another table. The original query had 792 rows. I went to the last row and made a change. This time there were 408 repetitions. Again, it used the primary key for the $1 parameter shown above. >> >> So why 408 repetitions this time? > >408 columns. Is this a very wide SELECT? > >I can see that 408 roundtrips would slow things down a lot over a >high-latency connection such as over the internet. Perhaps that's the >cause of the slowdown you see.. While your email was on its way to me, I was looking at the source for refreshrow and came to the conclusion that it's the number of columns. (Actually, 408 is a bit high, but close. Not important.) Yes, it is a wide select. Virtually every column in a table is displayable so they all have to be retrieved. The user who has been complaining (virtually identical code) has a table with only 93 columns, but still that's a lot of round trips. Certainly that piece of code can be made more efficient. One query ought to be able to return all the primary keys. I guess something like this won't work, unless "pkey" is reserved: select * from pg_indexes where tablename = 'patinfo' and indexname = 'patinfo_pkey'. That returns indexdev, which can be parsed to get the columns if needed. John