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 1415110600.96493.YahooMailNeo@web122306.mail.ne1.yahoo.com
Whole thread Raw
In response to Re: Let's drop two obsolete features which are bear-traps for novices  (Feng Tian <ftian@vitessedata.com>)
Responses Re: Let's drop two obsolete features which are bear-traps for novices  (Merlin Moncure <mmoncure@gmail.com>)
List pgsql-hackers
Feng Tian <ftian@vitessedata.com> wrote:

> Performance different between Money and Numeric is *HUGE*.  For
> TPCH Q1, the performance difference is 5x for stock postgres, and
> ~20x for vitesse.
>
> Stock postgres, for my laptop, TPCH 1G, Q1, use money type ~ 9s,
> use Numeric (15, 2) is ~53s.
>
>> test=# do $$ begin perform sum('10000.01'::numeric) from generate_series(1,10000000); end; $$;
>
> This may not reflect the difference of the two data type.   One
> aggregate is not where most of the time is spent.  TPCH Q1 has
> many more computing.

That's why I gave the count(*) baseline.  If you subtract that from
the sum() timings for money and numeric, numeric takes 5x as long
as money in my quick-and-dirty benchmark. I have no problem
believing that some applications can see that level of performance
hit from using numeric instead of money.  It's a little surprising
to me to see more than a factor of five slowdown from using numeric
instead of money; it leaves me a little curious how that happens.
Perhaps that workload is more conducive to keeping those money
amounts in registers and doing register arithmetic.

In any event, I'm against removing or re-deprecating the money
type.  There are some problems with money; there are other problems
with numeric.  If the docs are failing to make the trade-offs
clear, we should fix the docs.  And we can always look at improving
either or both types.  The fact that numeric is 5x to 20x slower
than money in important applications, combined with the fact that
it performs far worse than a similar type in another product,
suggest that numeric could stand a serious optimization pass.

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



pgsql-hackers by date:

Previous
From: "ktm@rice.edu"
Date:
Subject: Re: Let's drop two obsolete features which are bear-traps for novices
Next
From: Andreas Karlsson
Date:
Subject: Re: Let's drop two obsolete features which are bear-traps for novices