Re: alter table type from double precision to real

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: ssoo(at)siliconfile(dot)com, pgsql-general(at)postgresql(dot)org
Subject: Re: alter table type from double precision to real
Date: 2007-06-25 06:46:44
Message-ID: 20070625064644.GA39239@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Jun 25, 2007 at 12:35:11AM -0400, Tom Lane wrote:
> Michael Fuhr <mike(at)fuhr(dot)org> writes:
> > On Mon, Jun 25, 2007 at 09:51:30AM +0900, ssoo(at)siliconfile(dot)com wrote:
> >> It seems that real takes 8 byte storage sizes.
>
> > Real is 4 bytes but other columns' alignment requirements might
> > result in no space being saved.
>
> Even with no other columns involved, if you're on a machine with
> MAXALIGN = 8 (which includes all 64-bit platforms as well as some
> that aren't), the row width won't shrink.

I see table sizes shrink on 64-bit sparc and x86 architectures, as
in the following example that results in adjacent 4-byte columns.
Or am I misinterpreting what's happening?

test=> create table test (col1 double precision, col2 integer);
CREATE TABLE
test=> insert into test select 1.0, 1 from generate_series(1, 10000);
INSERT 0 10000
test=> select pg_relation_size('test');
pg_relation_size
------------------
524288
(1 row)

test=> alter table test alter col1 type real;
ALTER TABLE
test=> select pg_relation_size('test');
pg_relation_size
------------------
450560
(1 row)

--
Michael Fuhr

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Albe Laurenz 2007-06-25 06:51:59 Re: writing debug output in perl
Previous Message Murali Doss 2007-06-25 06:22:57 postgresql varchar[] data type equivalent in Oracle