Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id EC64B6376C6 for ; Fri, 15 Jan 2010 19:07:38 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 20128-07 for ; Fri, 15 Jan 2010 23:07:28 +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 3C0E26375EC for ; Fri, 15 Jan 2010 19:07:28 -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 o0FN7Aw2027525; Fri, 15 Jan 2010 18:07:11 -0500 (EST) (envelope-from john@johntdow.com) Message-Id: <201001152307.o0FN7Aw2027525@web2.nidhog.com> From: "John T. Dow" To: "Oliver Jowett" Cc: "pgsql-jdbc@postgresql.org" Date: Fri, 15 Jan 2010 18:06:49 -0500 X-Mailer: PMMail 2000 Professional (2.20.2717) For Windows 2000 (5.1.2600;3) 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=-1.11 tagged_above=-10 required=5 tests=BAYES_05=-1.11 X-Spam-Level: X-Archive-Number: 201001/29 X-Sequence-Number: 20225 I observe the following in the jdbc log. There's the original read only query, with 722 rows. The actual query was "SELECT * FROM doctor WHERE 1 = 1". Yes, I know it could just be "SELECT * FROM doctor" but the query is generated based on user input, and that's my version of a null where clause. After the first row of the result set was displayed, I changed a field and updated the table. The log shows the query "for update" and later a commit. Following that, where my program would do the refreshRow on the original resultset, I find a 21 instances of this block (some lines omitted): 17:25:50.812 (1) simple execute, handler=org.postgresql.jdbc2.AbstractJdbc2Statement$StatementResultHandler@1142196, maxRows=0, fetchSize=0, flags=17 17:25:50.812 (1) FE=> Parse(stmt=null,query="SELECT attname FROM pg_catalog.pg_attribute WHERE attrelid = $1 AND attnum = $2",oids={23,23}) 17:25:50.812 (1) FE=> Bind(stmt=null,portal=null,$1=<16404>,$2=<1>) 17:25:50.812 (1) FE=> Describe(portal=null) 17:25:50.812 (1) FE=> Execute(portal=null,limit=0) 17:25:50.812 (1) FE=> Sync 17:25:50.812 (1) <=BE ParseComplete [null] 17:25:50.812 (1) <=BE BindComplete [null] 17:25:50.812 (1) <=BE RowDescription(1) 17:25:50.812 (1) <=BE DataRow 17:25:50.812 (1) <=BE CommandStatus(SELECT) 17:25:50.812 (1) <=BE ReadyForQuery(I) The only difference between the 21 blocks is that the $2 parameter goes 1, 2, 3, 4, ... 21 After the 21st block comes this, and that ends the log. 17:38:47.031 (1) selecting select id, address, citystatezip, combined, degree, email, fax, firstname, groupname, lastname, nfiid, pabsid, practicetype, ssn, telephone, insertby, insertdate, inserttime, updateby, updatedate, updatetime from doctor where id= ? 17:38:47.046 (1) simple execute, handler=org.postgresql.jdbc2.AbstractJdbc2Statement$StatementResultHandler@d3c6a3, maxRows=0, fetchSize=0, flags=17 17:38:47.046 (1) FE=> Parse(stmt=null,query="select id, address, citystatezip, combined, degree, email, fax, firstname, groupname, lastname, nfiid, pabsid, practicetype, ssn, telephone, insertby, insertdate, inserttime, updateby, updatedate, updatetime from doctor where id= $1",oids={1043}) 17:38:47.046 (1) FE=> Bind(stmt=null,portal=null,$1=<0984>) 17:38:47.046 (1) FE=> Describe(portal=null) 17:38:47.046 (1) FE=> Execute(portal=null,limit=0) 17:38:47.046 (1) FE=> Sync 17:38:47.046 (1) <=BE ParseComplete [null] 17:38:47.046 (1) <=BE BindComplete [null] 17:38:47.046 (1) <=BE RowDescription(21) 17:38:47.046 (1) <=BE DataRow 17:38:47.046 (1) <=BE CommandStatus(SELECT) 17:38:47.046 (1) <=BE ReadyForQuery(I) 17:38:47.046 (1) done updates 17:38:49.765 (1) FE=> Terminate The value 0984 is the primary key value for the row I changed. I repeated this with the same original resultset, but moved to the 25th row before making a change. Again it did 21 instances of this block (the primary key value was of course different). To me, who knows nothing, the mystery is why 21 repetitions? 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? John