Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XKSHk-0003Hz-Mf for pgsql-jdbc@arkaria.postgresql.org; Thu, 21 Aug 2014 13:20:12 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XKSHk-00035O-4S for pgsql-jdbc@arkaria.postgresql.org; Thu, 21 Aug 2014 13:20:12 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XKSHi-00032h-Qa for pgsql-jdbc@postgresql.org; Thu, 21 Aug 2014 13:20:10 +0000 Received: from smtp03.smtpout.orange.fr ([80.12.242.125] helo=smtp.smtpout.orange.fr) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XKSHe-0000eS-FM for pgsql-jdbc@postgresql.org; Thu, 21 Aug 2014 13:20:09 +0000 Received: from zimbra.cy.cassidian.net ([86.199.103.180]) by mwinf5d06 with ME id hRL21o00B3tYW1y03RL2Vy; Thu, 21 Aug 2014 15:20:03 +0200 X-ME-Helo: zimbra.cy.cassidian.net X-ME-Date: Thu, 21 Aug 2014 15:20:03 +0200 X-ME-IP: 86.199.103.180 Received: from zimbra.cy.cassidian.net (zimbra.cy.cassidian.net [192.50.50.220]) by zimbra.cy.cassidian.net (Postfix) with ESMTP id AADD582CBD6; Thu, 21 Aug 2014 14:10:03 +0200 (CEST) Date: Thu, 21 Aug 2014 14:10:03 +0200 (CEST) From: Christophe Canovas To: Dave Cramer Cc: List , Christophe Canovas Message-ID: <14844829.55.1408623000936.JavaMail.root@zimbra.cy.cassidian.net> In-Reply-To: Subject: Re: Cursors removed with commit MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [192.50.50.52] X-Mailer: Zimbra 6.0.8_GA_2661 (ZimbraWebClient - SAF3 (Linux)/6.0.8_GA_2661) X-Pg-Spam-Score: -1.6 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org Cursors generally only exist inside a transaction so the first problem make= s sense.=20 =3D=3D> yes, I agree Apparently we aren't dealing with holdable cursors properly optimally thoug= h=20 =3D=3D> holdable cursors cancels fetch ; OutOfMemory for our application Best Regards, ----- Mail original ----- De: "Dave Cramer" =C3=80: "Christophe Canovas" Cc: "List" Envoy=C3=A9: Jeudi 21 Ao=C3=BBt 2014 15:12:47 Objet: Re: [JDBC] Cursors removed with commit Cursors generally only exist inside a transaction so the first problem make= s sense.=20 Apparently we aren't dealing with holdable cursors properly optimally thoug= h=20 Dave Cramer=20 dave.cramer(at)credativ(dot)ca=20 http://www.credativ.ca=20 On 20 August 2014 10:22, Christophe Canovas < cc.ais40@wanadoo.fr > wrote:= =20 To be more explicit, here is my example :=20 private void displayMem() {=20 Runtime rt =3D Runtime.getRuntime();=20 long alloue =3D rt.totalMemory();=20 long libre =3D rt.freeMemory();=20 System.out.println("Free mem =3D " + libre + " / allocated =3D " + alloue);= =20 }=20 public void testJdbcSRS() throws Exception {=20 String driver =3D "org.postgresql.Driver";=20 Class.forName(driver);=20 String acces =3D "jdbc:postgresql:///";=20 Connection con =3D java.sql.DriverManager.getConnection(acces, "",= "");=20 con.setAutoCommit(false);=20 Statement st =3D con.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet= .CONCUR_READ_ONLY);//,ResultSet.HOLD_CURSORS_OVER_COMMIT);=20 st.setFetchSize(10);=20 displayMem();=20 ResultSet rs =3D st.executeQuery("SELECT * FROM doc_index");=20 for (int i =3D 0 ; i < 100; i++) {=20 rs.next();=20 }=20 displayMem();=20 // Statement st2 =3D con.createStatement();=20 // st2.execute("DELETE FROM doc_index WHERE id=3D100");=20 // st2.execute("INSERT INTO doc_index(id,version) VALUES (100,1)");=20 // con.commit();=20 for (int i =3D 0 ; i < 100; i++) {=20 rs.next();=20 }=20 displayMem();=20 rs.close();=20 st.close();=20 con.close();=20 }=20 First run : OK=20 Remove the comments on lines on Statement st2 =3D ... to con.commit()=20 =3D=3D> cursor error=20 (in that case the same table is updated, but i've tried on another table, a= nd it's the same behavior)=20 Try to HOLD_CURSORS_OVER_COMMIT : it works, BUT the fetch is not used anymo= re ; the whole table is loaded in the memory (and in my case : OutOfMemory)= =20 Regards,=20 Christophe=20 ----- Mail original -----=20 De: "Christophe Canovas" < cc.ais40@wanadoo.fr >=20 =C3=80: pgsql-jdbc@postgresql.org=20 Envoy=C3=A9: Mercredi 20 Ao=C3=BBt 2014 15:39:12=20 Objet: [JDBC] Cursors removed with commit=20 Hello,=20 I have a problem with my huge database ; using cursors (so using a transact= ion with noautocommit, statement with type_forward_only) make cursors remov= ed if I update and save (commit) database values in the same transaction du= ring the fetch loop.=20 Error message is : portal "C_03" doesn't exist=20 All is fine if the commit is done in a different transaction.=20 In more details, in the statement creation :=20 con.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY= , ResultSet.HOLD_CURSORS_OVER_COMMIT);=20 the last parameter seems to have no effect ... ?=20 Best Regards,=20 Christophe=20 --=20 Sent via pgsql-jdbc mailing list ( pgsql-jdbc@postgresql.org )=20 To make changes to your subscription:=20 http://www.postgresql.org/mailpref/pgsql-jdbc=20 --=20 Sent via pgsql-jdbc mailing list ( pgsql-jdbc@postgresql.org )=20 To make changes to your subscription:=20 http://www.postgresql.org/mailpref/pgsql-jdbc=20 --=20 Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc