Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id F22429F98FA for ; Sun, 19 Nov 2006 16:31:44 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 47803-03 for ; Sun, 19 Nov 2006 20:31:39 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail01.enterprisedb.com (mail01.enterprisedb.com [63.246.7.168]) by postgresql.org (Postfix) with ESMTP id 051419F9F47 for ; Sun, 19 Nov 2006 16:31:38 -0400 (AST) thread-index: AccMGbg7jFZAGpVIQdyNW2NejGXb9Q== Received: from [192.168.1.10] ([82.27.226.40]) by mail01.enterprisedb.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.1830); Sun, 19 Nov 2006 15:31:40 -0500 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.2757 Content-class: urn:content-classes:message Importance: normal Message-ID: <4560BF23.9070003@enterprisedb.com> Date: Sun, 19 Nov 2006 20:31:31 +0000 From: "Heikki Linnakangas" User-Agent: Thunderbird 1.5.0.7 (X11/20060927) MIME-Version: 1.0 To: "Mikko Tiihonen" Cc: Subject: Re: ResultSet.getBytes() of bytea speedup batch References: <1163715629.8932.22.camel@mokki.local> In-Reply-To: <1163715629.8932.22.camel@mokki.local> Content-Type: text/plain; format=flowed; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 19 Nov 2006 20:31:40.0703 (UTC) FILETIME=[B82D22F0:01C70C19] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200611/91 X-Sequence-Number: 16133 Mikko Tiihonen wrote: > The attached patch gives 20-400% speedup depending on the bytea column > size. The speedup comes from switching to the binary transfer mode > instead of the text transfer mode for bytea columns. Impressive results! > The patch also contains the test code which I used to test the > performance (ByteaBenchTest.java). The benchmark results are: > > cvs: > column size: transfer speed: > 512b speed: 3,8MB/s > 2048b speed: 10,0MB/s > 4096b speed: 13,1MB/s > 16384b speed: 22,0MB/s > 65536b speed: 22,4MB/s > 1048576b speed: 21,2MB/s > > patch: > column size: transfer speed: > 512b speed: 4,6MB/s - 21% speedup > 2048b speed: 16,8MB/s - 68% speedup > 4096b speed: 27,9MB/s - 112% speedup > 16384b speed: 79,2MB/s - 260% speedup > 65536b speed: 111,1MB/s - 395% speedup (optimal for my L2 cache?) > 1048576b speed: 74,8MB/s - 252% speedup I'm getting similar results, though the drop after 65536b is even steeper: cvs: [junit] 512b speed: 1.8MB/s memory: 2.5MB [junit] 2048b speed: 5.0MB/s memory: 2.0MB [junit] 4096b speed: 7.5MB/s memory: 2.0MB [junit] 16384b speed: 11.8MB/s memory: 2.4MB [junit] 65536b speed: 12.6MB/s memory: 2.4MB [junit] 1048576b speed: 5.3MB/s memory: 5.8MB patch: [junit] 512b speed: 2.1MB/s memory: 2.0MB [junit] 2048b speed: 7.4MB/s memory: 2.2MB [junit] 4096b speed: 13.0MB/s memory: 2.1MB [junit] 16384b speed: 35.9MB/s memory: 2.3MB [junit] 65536b speed: 56.7MB/s memory: 2.0MB [junit] 1048576b speed: 17.2MB/s memory: 2.9MB [junit] ------------- ---------------- --------------- Ran on Sun JRE 1.5.0_06, on Intel Core Duo. I sure would like to find an explanation for the drop. > Still open questions: > - is there any better way to obtain the result set field information in > QueryExecutor? > * could the result set type information be obtained during the > prepare? It could. If the driver issued a Sync message after Describe, and waited for the response before sending the Bind, the driver could use the information in the RowDesription response. But that would require an extra round-trip to the server, so it's probably not worth it in most queries. I wish we could set a default format for each data type in a separate message. Like: SetFormat(oid = 17, format="b") The server would then send all bytea fields as binary unless otherwise stated in the Bind message. It would require a backend-change, of course. > - in which conditions should a prepared statement drop the cached fields > * do the result set fields ever change? > * any other conditions? > - if caching of Field information is allowed (at least in some > circumstances), could the driver stop requesting a Describe from the > backend? I can't imagine how the fields could change. Seems safe to me. > @@ -126,6 +134,8 @@ > private byte[] encodedStatementName; > private PhantomReference cleanupRef; > private int[] preparedTypes; > + private static final byte[] EMPTY_STATEMENTNAME = new byte[] { 0 }; > + private Field[] fields; > > final static SimpleParameterList NO_PARAMETERS = new SimpleParameterList(0); > } This is just some leftover crud, right? Couldn't find a reference to EMPTY_STATEMENTNAME anywhere. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com