Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WCwuc-0000Ym-HI for pgsql-performance@arkaria.postgresql.org; Mon, 10 Feb 2014 19:53:02 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WCwub-0004un-UH for pgsql-performance@arkaria.postgresql.org; Mon, 10 Feb 2014 19:53:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WCwua-0004ug-QV for pgsql-performance@postgresql.org; Mon, 10 Feb 2014 19:53:00 +0000 Received: from mail.bytecamp.net ([212.204.60.9]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WCwuW-0006dq-93 for pgsql-performance@postgresql.org; Mon, 10 Feb 2014 19:52:58 +0000 Received: (qmail 37460 invoked by uid 89); 10 Feb 2014 20:52:54 +0100 Received: from p54b7fe32.dip0.t-ipconnect.de (HELO ?192.168.0.234?) (umu@fischheim.de@84.183.254.50) by mail.bytecamp.net with AES256-SHA encrypted SMTP; 10 Feb 2014 20:52:54 +0100 Date: Mon, 10 Feb 2014 20:52:51 +0100 (CET) From: M Putz X-X-Sender: umu@skaj To: pgsql-performance@postgresql.org Subject: Strange performance boost with random() In-Reply-To: Message-ID: References: User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org Hello, While analyzing performance, we encountered the following phenomenon, SELECT sum(pow(.5*generate_series,.5)) FROM generate_series(1,1000000); is much much (a hundred times) slower than SELECT sum(pow(random()*generate_series,.5)) FROM generate_series(1,1000000); and asymptotic difference is even more astounding. This seems counter-intuitive, considering the cost of an additional random() call instead of a constant factor. What are the reasons for this strange performance boost? Thanks, M. Putz -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance