X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0BE4414B27FC for ; Tue, 10 Aug 2004 12:13:22 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 15712-09 for ; Tue, 10 Aug 2004 15:13:10 +0000 (GMT) Received: from mail.gmx.net (mail.gmx.de [213.165.64.20]) by svr1.postgresql.org (Postfix) with SMTP id EA4BE14B280B for ; Tue, 10 Aug 2004 12:13:05 -0300 (ADT) Received: (qmail 6229 invoked by uid 0); 10 Aug 2004 15:13:00 -0000 Received: from 82.82.214.56 by www53.gmx.net with HTTP; Tue, 10 Aug 2004 17:13:00 +0200 (MEST) Date: Tue, 10 Aug 2004 17:13:00 +0200 (MEST) From: "Ole Streicher" To: pgsql-jdbc@postgresql.org MIME-Version: 1.0 Subject: Cleaning up large objects X-Priority: 3 (Normal) X-Authenticated: #16178552 Message-ID: <4890.1092150780@www53.gmx.net> X-Mailer: WWW-Mail 1.6 (Global Message Exchange) X-Flags: 0001 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200408/68 X-Sequence-Number: 10790 Hi, I have a problem with the cleanup of large objects. My database consists of (mainly) one table that holds a date and an associated large object id. The large object can be as big as 2 megabytes. Every hour, I have a small method that removes all entries that are older than a certain date: private void cleanup(Connection dbConn, Date deleteTo) throws SQLException { try { dbConn.setAutoCommit(false); dbConn.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); LargeObjectManager lobj = ((PGConnection)dbConn).getLargeObjectAPI(); PreparedStatement queryStmt = dbConn.prepareStatement( "SELECT Values FROM MyTable WHERE From_Date < ?"); queryStmt.setTimestamp(0, new Timestamp(deleteTo.getTime())); ResultSet rs = queryStmt.executeQuery(); try { while (rs.next()) { int oid = rs.getInt(1); try { lobj.delete(oid); } catch (SQLException e) {e.printStackTrace();} } } finally { rs.close(); } PreparedStatement deleteStmt = dbConn.prepareStatement("DELETE FROM MyTable WHERE From_Date < ?"); deleteStmt.setTimestamp(1, new Timestamp(deleteTo.getTime())); deleteStmt.executeUpdate(); dbConn.commit(); } catch (SQLException e) { dbConn.rollback(); throw e; } This program also seems to work, that means that I dont get any exceptions from it. Also, every night I run the "vacuum" command: /usr/bin/vacuumdb -a -z But: the data base keeps growing. The table MyTable seems to successfully remove the entries, but the disk usage keeps high. I am quit sure that the disk usage mainly comes from the LOBs since the disk usage shrinks with exactly the speed I expect from the LOBs I put in. What is wrong with my approach that it does not free the disk space? Regards Ole -- NEU: WLAN-Router für 0,- EUR* - auch für DSL-Wechsler! GMX DSL = supergünstig & kabellos http://www.gmx.net/de/go/dsl