Return-Path: Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: (qmail 29788 invoked from network); 13 Jan 2010 16:02:01 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 13 Jan 2010 16:02:01 -0000 Received: (qmail 71842 invoked by uid 500); 13 Jan 2010 16:02:01 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 71797 invoked by uid 500); 13 Jan 2010 16:02:01 -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 71789 invoked by uid 99); 13 Jan 2010 16:02:01 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Jan 2010 16:02:01 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of nathan.boy@gmail.com designates 216.239.58.184 as permitted sender) Received: from [216.239.58.184] (HELO gv-out-0910.google.com) (216.239.58.184) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Jan 2010 16:01:50 +0000 Received: by gv-out-0910.google.com with SMTP id e6so195187gvc.15 for ; Wed, 13 Jan 2010 08:01:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=8YJFd32nHVYhLXyvfSCvJwrCVbDBdm3ugVgCP7J/k1E=; b=UnvX3ZKb/4/ckdl5/v9yDoGbS1aU4rR+xRzgOlML8mTm1+3emif5JWqCqXnU6g7l5s RYC3vbN0Cd4iVHVvjwf4QmPPGMEgkC3cWDddm2wqRTHsw0qbCb8UuBMC4xI987orsihS 4QBJ/g52KD/fz4v+AsFJmU2f+pnX1TQ3Zgo8s= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=ud440uClHvfDMcvkELwiXXXAJAdc3xSSE1Y6dRDGbS+pAaEfL2NPbEdQgVVLpso9YV pwLy/rzQb2F39Q+Ln0ow+kQqXgWD2sNTL0N99Zq1sNqB1ATjS1hMKTwmVMU9NCXzkiWD sSE3+A0TPCFYI5/XrvjY/3U9Rwpsmrwb7pGa4= MIME-Version: 1.0 Received: by 10.103.80.24 with SMTP id h24mr2655158mul.113.1263398489730; Wed, 13 Jan 2010 08:01:29 -0800 (PST) Date: Wed, 13 Jan 2010 11:01:29 -0500 Message-ID: Subject: Improving data insert performance From: Nathan Boy To: derby-user@db.apache.org Content-Type: text/plain; charset=UTF-8 X-Virus-Checked: Checked by ClamAV on apache.org Hello, I have an embedded database application that generally involves inserting somewhere between 50k and 1000k rows of data into a database, and then analyzing and querying that data afterwards. The data goes into about ten tables, but the bulk of the data is in just a few of them. I run my database with "test" durability, and I add all of the primary key and foreign key constraints after the data is inserted into the database. Currently all of the data is inserted using prepared statements executed in batches, and this gives me between 10 and 20 row inserts per millisecond on average. I have spent quite a bit of time optimizing the insert step, and while I was doing research I came across this discussion from last year: http://www.mail-archive.com/derby-user@db.apache.org/msg10194.html The discussion suggests using bulk import as a way to speed up this initial insert step. Unfortunately, I cannot use the built in import functions, as my data includes Timestamps with nanosecond granularity. As far as I can tell, there is no way to convince derby to parse a time specified down to the nanosecond. In one of the emails, someone suggested that you can get bulk import performance by using a table function, and then running a query like "INSERT INTO MYTABLE (...) SELECT S.* FROM TABLE (MYFUNC ()) S". In my tests, however, this doesn't seem to perform the insert any faster than simply inserting the rows one at a time with a prepared statement. I think this may be because I don't have a way to set the 'insertMode=bulkImport' property, which the bulk import system procedure is allowed to do. Does anyone know of a way to work around this, or of a better way to get my data into the database as quickly as possible? Thanks in advance for your time. Cheers, Nathan Boy