Strange performance boost with random()

From: M Putz <puma(at)c007(dot)de>
To: pgsql-performance(at)postgresql(dot)org
Subject: Strange performance boost with random()
Date: 2014-02-10 19:52:51
Message-ID: alpine.DEB.2.02.1402102007580.14849@skaj
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance


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

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Heikki Linnakangas 2014-02-10 20:03:36 Re: Strange performance boost with random()
Previous Message Sergey Konoplev 2014-02-09 23:29:41 Re: Bloated tables and why is vacuum full the only option