pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andrew Dunstan <andrew@dunslane.net>
Cc: pgsql-committers@postgresql.org
Subject: Re: pgsql: Add stats for min, max, mean, stddev times to pg_stat_statements
Date: Fri, 27 Mar 2015 20:38:53 -0400
Message-ID: <2182.1427503133@sss.pgh.pa.us> (raw)
In-Reply-To: <562.1427499563@sss.pgh.pa.us>
References: <E1YbaFW-0008VB-AD@gemulon.postgresql.org>
	<26457.1427493201@sss.pgh.pa.us>
	<5515D932.8020305@dunslane.net>
	<562.1427499563@sss.pgh.pa.us>
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-committers>

I wrote:
> Andrew Dunstan <andrew@dunslane.net> 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



view thread (6+ messages)

Message-ID: <2182.1427503133@sss.pgh.pa.us>
Permalink:  ../2182.1427503133@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2182.1427503133@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, andrew@dunslane.net
  Subject: Re: pgsql: Add stats for min, max, mean, stddev times to pg_stat_statements
  In-Reply-To: <2182.1427503133@sss.pgh.pa.us>
  References: <E1YbaFW-0008VB-AD@gemulon.postgresql.org> <26457.1427493201@sss.pgh.pa.us> <5515D932.8020305@dunslane.net> <562.1427499563@sss.pgh.pa.us> <2182.1427503133@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox