Alvaro Herrera <[email protected]> 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
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers