Use static inline functions for Float <-> Datum conversions - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Use static inline functions for Float <-> Datum conversions
Date
Msg-id dbb82a4a-2c15-ba27-dd0a-009d2aa72b77@iki.fi
Whole thread Raw
Responses Re: Use static inline functions for Float <-> Datum conversions  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Hi,

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
example:

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

pgsql-hackers by date:

Previous
From: Fujii Masao
Date:
Subject: Re: GIN logging GIN_SEGMENT_UNMODIFIED actions?
Next
From: Fabrízio de Royes Mello
Date:
Subject: Re: Exclude schema during pg_restore