Re: Performance implications of numeric? - Mailing list pgsql-general

From Craig Ringer
Subject Re: Performance implications of numeric?
Date
Msg-id 5034647E.60501@ringerc.id.au
Whole thread Raw
In response to Performance implications of numeric?  (Wells Oliver <wellsoliver@gmail.com>)
List pgsql-general
On 08/22/2012 12:27 PM, Wells Oliver wrote:
> We have a lot of tables which store numeric data. These tables all use
> the numeric type, where the values are 95% integer values. We used
> numeric because it eliminated the need for casting during division to
> yield a floating point value.
>
> I'm curious as to whether this would have performance and/or disk size
> implications.

Yes, and yes, though the gap seems to have shrunk a lot since I first
started using Pg.

It's easy to concoct fairly meaningless micro-benchmarks, but you should
really try it with some real queries you run on your real schema. Take a
copy of your data, convert it, and run some tests. Use
`pg_total_relation_size` to compare the numeric and int versions of the
relations after `CLUSTER`ing them to debloat and reindex them.

> Would converting these columns to integer (or double
> precision on the handful that require the precision) and forcing
> developers to use explicit casting be worth the time?

Without knowing your workload and your constraints, that's a "how blue
is the sky" question.

--
Craig Ringer


pgsql-general by date:

Previous
From: Craig Ringer
Date:
Subject: Re: Grant problem and how to prevent users to execute OS commands?
Next
From: Craig Ringer
Date:
Subject: Re: Amazon High I/O instances