Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YbemD-000610-14 for pgsql-committers@arkaria.postgresql.org; Sat, 28 Mar 2015 00:39:01 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YbemC-0003DZ-Fu for pgsql-committers@arkaria.postgresql.org; Sat, 28 Mar 2015 00:39:00 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YbemB-0003DT-Uw for pgsql-committers@postgresql.org; Sat, 28 Mar 2015 00:39:00 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Ybem8-0006RR-Cc for pgsql-committers@postgresql.org; Sat, 28 Mar 2015 00:38:58 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id t2S0crf1002183; Fri, 27 Mar 2015 20:38:53 -0400 From: Tom Lane To: Andrew Dunstan cc: pgsql-committers@postgresql.org Subject: Re: pgsql: Add stats for min, max, mean, stddev times to pg_stat_statements In-reply-to: <562.1427499563@sss.pgh.pa.us> References: <26457.1427493201@sss.pgh.pa.us> <5515D932.8020305@dunslane.net> <562.1427499563@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Fri, 27 Mar 2015 19:39:23 -0400" Date: Fri, 27 Mar 2015 20:38:53 -0400 Message-ID: <2182.1427503133@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-committers Precedence: bulk Sender: pgsql-committers-owner@postgresql.org I wrote: > Andrew Dunstan writes: >> However, it is moaning about the code in the sqrtd() function. I'm >> wondering if we shouldn't just rip that out and use the library sqrt() >> function. It's not called for every statement processed, only each time >> the function is called (for each row). > [ looks... ] +1. I'm skeptical that that's even a win at all on modern > hardware; sqrt() is a primitive operation on nearly anything these days. I did some quick comparisons on a reasonably current server (Xeon E5-2609 running RHEL6.6), and found that this: volatile double x; volatile double y = 1.23456; for (i = 0; i < n; i++) { x = sqrtd(y); } takes about 5.6 nsec per iteration, while with plain sqrt() it's about 8.8 nsec. So while there is a measurable gain (on this hardware anyway) IMO it is absolutely not worth taking any portability risks for. regards, tom lane -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers