Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id D498CB5DBBE for ; Mon, 13 Jun 2011 04:09:49 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 55815-08 for ; Mon, 13 Jun 2011 07:09:42 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from www.postnewspapers.com.au (www.postnewspapers.com.au [173.230.139.50]) by mail.postgresql.org (Postfix) with ESMTP id 83E9BB5D80A for ; Mon, 13 Jun 2011 04:09:42 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by www.postnewspapers.com.au (Postfix) with ESMTP id 20C2910D; Mon, 13 Jun 2011 03:09:42 -0400 (EDT) X-Virus-Scanned: amavisd-new at postnewspapers.com.au.com Received: from www.postnewspapers.com.au ([127.0.0.1]) by localhost (www.postnewspapers.com.au [127.0.0.1]) (amavisd-new, port 10024) with LMTP id LknMGKWCHn-c; Mon, 13 Jun 2011 03:09:41 -0400 (EDT) Received: from mail.postnewspapers.com.au (ppp171-128.static.internode.on.net [150.101.171.128]) by www.postnewspapers.com.au (Postfix) with ESMTP id 1803D2D; Mon, 13 Jun 2011 03:09:41 -0400 (EDT) Received: from [10.0.0.53] (wallace.localnet [10.0.0.53]) by mail.postnewspapers.com.au (Postfix) with ESMTP id DAAA7AF5F0; Mon, 13 Jun 2011 15:09:39 +0800 (WST) Message-ID: <4DF5B7B3.7010708@postnewspapers.com.au> Date: Mon, 13 Jun 2011 15:09:39 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.15) Gecko/20110307 Thunderbird/3.1.9 MIME-Version: 1.0 To: Israel Ben Guilherme Fonseca CC: pgsql-jdbc@postgresql.org Subject: Re: Question about speed: Weird Behavior References: In-Reply-To: X-Enigmail-Version: 1.1.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201106/26 X-Sequence-Number: 21950 On 13/06/11 11:14, Israel Ben Guilherme Fonseca wrote: > At every stop, I print the milliseconds occurred between the begin and > the end of the operation. The results were basically > > 1st operation: 0.05 miliseconds > 2nd operation: 0.1 miliseconds I suspect you're right on the border of the precision the timers you are using can offer you. It's hard to be sure as you didn't mention you platform, CPU, or JDK version. Try using System.nanoTime() for your timing, and/or (much better) do many iterations rather than just one to try to smooth out error and jitter. http://download.oracle.com/javase/1,5.0/docs/api/java/lang/System.html#nanoTime() > Anyway, that speed increases is definitely a good thing, but why this > happens it's a mystery for me. The problem is that my benchmark tests > are influenced with this, cause the order of the tests can influence the > outcome of the total time. You really need to tweak your benchmarks to reflect more of a real-world workload. Timing tiny statements stand-alone will not give you data with any relationship to what will happen under real load with many such operations happening concurrently or thousands of them being executed in rapid sequence. -- Craig Ringer