Return-Path: Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: (qmail 19949 invoked from network); 25 Nov 2008 12:32:54 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 25 Nov 2008 12:32:54 -0000 Received: (qmail 69454 invoked by uid 500); 25 Nov 2008 12:33:04 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 69430 invoked by uid 500); 25 Nov 2008 12:33:04 -0000 Mailing-List: contact derby-user-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Reply-To: "Derby Discussion" Delivered-To: mailing list derby-user@db.apache.org Received: (qmail 69419 invoked by uid 99); 25 Nov 2008 12:33:03 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Nov 2008 04:33:03 -0800 X-ASF-Spam-Status: No, hits=-4.0 required=10.0 tests=RCVD_IN_DNSWL_MED,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [192.18.6.21] (HELO gmp-eb-inf-1.sun.com) (192.18.6.21) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Nov 2008 12:31:36 +0000 Received: from fe-emea-09.sun.com (gmp-eb-lb-2-fe3.eu.sun.com [192.18.6.12]) by gmp-eb-inf-1.sun.com (8.13.7+Sun/8.12.9) with ESMTP id mAPCWGR7028706 for ; Tue, 25 Nov 2008 12:32:16 GMT Received: from conversion-daemon.fe-emea-09.sun.com by fe-emea-09.sun.com (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007)) id <0KAW002011UPI000@fe-emea-09.sun.com> (original mail from Kristian.Waagan@Sun.COM) for derby-user@db.apache.org; Tue, 25 Nov 2008 12:32:16 +0000 (GMT) Received: from [129.159.139.223] by fe-emea-09.sun.com (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007)) with ESMTPSA id <0KAW00D0R2T9SE70@fe-emea-09.sun.com> for derby-user@db.apache.org; Tue, 25 Nov 2008 12:31:58 +0000 (GMT) Date: Tue, 25 Nov 2008 13:31:34 +0100 From: Kristian Waagan Subject: Re: how to get data out from Clob? In-reply-to: <21F0E9E7ED2D894F8385A92C80336BF3034C0099@arti-sr-28.artificial-solutions.com> Sender: Kristian.Waagan@Sun.COM To: Derby Discussion Message-id: <492BF026.6070204@Sun.COM> MIME-version: 1.0 Content-type: text/plain; format=flowed; charset=ISO-8859-1 Content-transfer-encoding: 7BIT References: <21F0E9E7ED2D894F8385A92C80336BF3034C0099@arti-sr-28.artificial-solutions.com> User-Agent: Thunderbird 2.0.0.17 (X11/20081023) X-Virus-Checked: Checked by ClamAV on apache.org Mikael Sundberg write: > > We are having some trouble with retrieving data from big Clob fields. > The data is about 40-50MB and it takes forever to retrieve it. > > Tried a lot of different methods, getString, getClob, getAsciiStream. > They all take forever (hours). > > When checking whats running in derby we find > > CALL SYSIBM.CLOBGETSUBSTRING(?, ?, ?) > > A lot of times. > > How should I retrieve large CLob fields fastest? > > > Hello Mikael, You are being hit by a serious performance bug (a lot more prominent since Derby 10.3). I understand you are using the client driver, but which version of Derby are you using? I believe the issue you are experiencing has been fixed in trunk and in the 10.4 branch, but a release hasn't been made after the fix was committed. If you don't want to build Derby yourself, *test binaries* are available if you want to test with a newer version. It should be sufficient to update the server side only (i.e. derbynet.jar and derby.jar). If you try it out, please remember to take a backup of your database! If you need to upgrade you database to trunk, you also need to enable pre-release upgrades. Unfortunately, there is no way to properly work around the problem in older releases. You can adjust the buffer/block size used to fetch data in the client application, but this will only help a little bit and will probably not be sufficient. The optimal buffer size is dependent on the Clob content (due to the UTF-8 encoding used). If your Clobs contain ASCII data, you should set your buffer size to 32672 (note that this is smaller than 32KB). If you are using the embedded driver, make sure you access the Clob using one of the streaming methods (getSubString has been fixed by now). There will be several changes regarding Clob performance in the next feature release. We're also in the progress of adding performance regression tests for LOBs, as this is a problem we should have detected a long time ago! If you are still seeing the problem with the newest version, I'm very interested in getting more details from you. regards, -- Kristian