Use static inline functions for Float <-> Datum conversions

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Use static inline functions for Float <-> Datum conversions
Date: 2016-08-31 10:48:29
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


Now that we are OK with static inline functions, we can save some cycles
from floating-point functions, by turning Float4GetDatum,
Float8GetDatum, and DatumGetFloat8 into static inlines. They are only a
few instructions, but couldn't be implemented as macros before, because
they need a local union-variable for the conversion.

That can add up to significant speedups with float-heavy queries. For

create table floats as select g::float8 as a, g::float8 as b, g::float8
as c from generate_series(1, 1000000) g;

select sum(a+b+c+1) from floats;

The sum query is about 4% faster on my laptop with this patch.

- Heikki

Attachment Content-Type Size
0001-Use-static-inline-functions-for-float-Datum-conversi.patch application/x-patch 5.0 KB


Browse pgsql-hackers by date

  From Date Subject
Next Message Fabrízio de Royes Mello 2016-08-31 10:59:22 Re: Exclude schema during pg_restore
Previous Message Fujii Masao 2016-08-31 10:39:29 Re: GIN logging GIN_SEGMENT_UNMODIFIED actions?