pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: digoal@126.com
To: pgsql-bugs@postgresql.org
Subject: BUG #13749: PostgreSQL cann't compress random data?
Date: Fri, 30 Oct 2015 01:56:46 +0000
Message-ID: <20151030015646.3021.82858@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

The following bug has been logged on the website:

Bug reference:      13749
Logged by:          digoal
Email address:      digoal@126.com
PostgreSQL version: 9.4.5
Operating system:   CentOS 6.x x64
Description:        

postgres=# create table test_plain(c text);
CREATE TABLE
postgres=# alter table test_plain alter column c set storage external;
ALTER TABLE
postgres=# create table test_compress(c text);
CREATE TABLE
postgres=# alter table test_compress alter column c set storage extended;
ALTER TABLE
postgres=# insert into test_plain select repeat(md5(random()::text),10000)
from generate_series(1,1000);
INSERT 0 1000
postgres=# insert into test_compress select
repeat(md5(random()::text),10000) from generate_series(1,1000);
INSERT 0 1000
postgres=# select pg_size_pretty(pg_total_relation_size('test_compress'));
 pg_size_pretty 
----------------
 4168 kB
(1 row)
postgres=# select pg_size_pretty(pg_total_relation_size('test_plain'));
 pg_size_pretty 
----------------
 317 MB
(1 row)

the above case use repeat generate a big data.
but when i use the other case, pgsql cann't compress the data, is the
compress algorithm bug?
postgres=# truncate test_compress ;
TRUNCATE TABLE
postgres=# truncate test_plain ;
TRUNCATE TABLE
postgres=# do language plpgsql $$
   declare 
   begin 
   for i in 1..100 loop 
     insert into test_compress select string_agg(md5(random()::text),' ') v
from generate_series(1,10000);
   end loop;
   end; 
$$;
DO
postgres=# do language plpgsql $$ declare begin for i in 1..100 loop insert
into test_plain select string_agg(md5(random()::text),' ') v from
generate_series(1,10000); end loop; end; $$;
DO

postgres=# select pg_size_pretty(pg_total_relation_size('test_compress'));
 pg_size_pretty 
----------------
 33 MB
(1 row)

postgres=# select pg_size_pretty(pg_total_relation_size('test_plain'));
 pg_size_pretty 
----------------
 33 MB
(1 row)


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



view thread (2+ messages)  latest in thread

Message-ID: <20151030015646.3021.82858@wrigleys.postgresql.org>
Permalink:  ../20151030015646.3021.82858@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/20151030015646.3021.82858@wrigleys.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: digoal@126.com
  Subject: Re: BUG #13749: PostgreSQL cann't compress random data?
  In-Reply-To: <20151030015646.3021.82858@wrigleys.postgresql.org>
  References: <20151030015646.3021.82858@wrigleys.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox