Search Postgresql Archives

Re: Column storage (EXTERNAL/EXTENDED) settings for bytea/text column

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In response to Joel Stevenson <jstevenson@xxxxxxxxxxx>:

> Hi all,
> 
> I'm trying to do some comparisons between the EXTERNAL and the EXTENDED storage methods on a bytea column and from the outside the setting doesn't appear to affect the value stored on initial insert, but perhaps I'm looking at the wrong numbers.  If I create two new tables with a single bytea column and set one of them to external storage, then insert an existing bytea value from another table into each one, they appear to be of exactly the same size.  This is using PG 9.0.3 on Debian Lenny, using the backports-sloppy deb package of PG 9.
> 
> (I've verified that the first table has "extended" storage via pg_attribute and that the second table has external.)
> 
> create table obj1 ( object bytea );
> create table obj2 ( object bytea );
> alter table obj2 alter column object set storage external;
> insert into obj1 ( object ) select object from serialized_content where id = 12345;
> insert into obj2 ( object ) select object from obj1;
> select pg_total_relation_size('obj1') as o1, pg_total_relation_size( (select reltoastrelid from pg_class where relname = 'obj1' ) ) as otoast1, pg_total_relation_size('obj2') as o2, pg_total_relation_size( (select reltoastrelid from pg_class where relname = 'obj2' ) ) as otoast2;
>   o1   | otoast1 |  o2   | otoast2 
> -------+---------+-------+---------
>  65536 |   57344 | 65536 |   57344
> (1 row)
> 
> Now at this point if I perform a vacuum full on one or both, they'll both shrink down to a bit over half that size:
> 
> vacuum full obj1;
> vacuum full obj2;
> select pg_total_relation_size('obj1') as o1, pg_total_relation_size( (select reltoastrelid from pg_class where relname = 'obj1' ) ) as otoast1, pg_total_relation_size('obj2') as o2, pg_total_relation_size( (select reltoastrelid from pg_class where relname = 'obj2' ) ) as otoast2;
>   o1   | otoast1 |  o2   | otoast2 
> -------+---------+-------+---------
>  40960 |   32768 | 40960 |   32768

I'm not an expert, but it looks like you're not storing enough data to
actually see the difference, since the actual sizes of the tables will
always be rounded to an even page size.  With only 1 row, it's always
going to take a minimum amount.

Also, are you sure you're storing compressible data?  For example, if
you're putting PNG or JPEG images in there, they're not going to compress
any.

-- 
Bill Moran
http://www.potentialtech.com
http://people.collaborativefusion.com/~wmoran/

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux