From: | Kevin Grittner <kgrittn(at)ymail(dot)com> |
---|---|
To: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, David Fetter <david(at)fetter(dot)org> |
Cc: | Michael Banck <michael(dot)banck(at)credativ(dot)de>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Jaime Casanova <jaime(at)2ndquadrant(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Josh Berkus <josh(at)agliodbs(dot)com>, CK Tan <cktan(at)vitessedata(dot)com> |
Subject: | Re: Let's drop two obsolete features which are bear-traps for novices |
Date: | 2014-11-03 22:56:11 |
Message-ID: | 1415055371.35013.YahooMailNeo@web122301.mail.ne1.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Alvaro Herrera <alvherre(at)2ndquadrant(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Merlin Moncure | 2014-11-03 23:16:08 | Re: tracking commit timestamps |
Previous Message | Tatsuo Ishii | 2014-11-03 22:51:06 | Re: Let's drop two obsolete features which are bear-traps for novices |