Re: Let's drop two obsolete features which are bear-traps for novices - Mailing list pgsql-hackers

From Kevin Grittner
Subject Re: Let's drop two obsolete features which are bear-traps for novices
Date
Msg-id 1415055371.35013.YahooMailNeo@web122301.mail.ne1.yahoo.com
Whole thread Raw
In response to Re: Let's drop two obsolete features which are bear-traps for novices  (Alvaro Herrera <alvherre@2ndquadrant.com>)
List pgsql-hackers
Alvaro Herrera <alvherre@2ndquadrant.com> wrote:

> There is a real advantage of money over numeric in the performance
> front.  I haven't measured it, but suffice to say that money uses
> integer operations which map almost directly to CPU instructions,
> whereas numeric needs to decode from our varlena base-10000 digit
> format, operate on digits at a time, then encode back.  No matter how
> much you optimize numeric, it's never going to outperform stuff that
> runs practically on bare electrons.  As far as I recall, some TPCH
> queries run aggregations on currency columns.
>
> Now, whether this makes a measurable difference or not in TPCH terms, I
> have no idea.

Best of 3 tries on each statement...

A count(*) as a baseline:

test=# do $$ begin perform count(*) from generate_series(1,10000000); end; $$;
DO
Time: 3260.920 ms

A sum of money:

test=# do $$ begin perform sum('10000.01'::money) from generate_series(1,10000000); end; $$;
DO
Time: 3572.709 ms

A sum of numeric:

test=# do $$ begin perform sum('10000.01'::numeric) from generate_series(1,10000000); end; $$;
DO
Time: 4805.559 ms

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-hackers by date:

Previous
From: Tatsuo Ishii
Date:
Subject: Re: Let's drop two obsolete features which are bear-traps for novices
Next
From: Merlin Moncure
Date:
Subject: Re: tracking commit timestamps