pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #13749: PostgreSQL cann't compress random data?
2+ messages / 2 participants
[nested] [flat]

* BUG #13749: PostgreSQL cann't compress random data?
@ 2015-10-30 01:56  digoal@126.com
  0 siblings, 1 reply; 2+ messages in thread

From: digoal@126.com @ 2015-10-30 01:56 UTC (permalink / raw)
  To: pgsql-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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #13749: PostgreSQL cann't compress random data?
@ 2015-10-30 15:12  Tom Lane <tgl@sss.pgh.pa.us>
  parent: digoal@126.com
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2015-10-30 15:12 UTC (permalink / raw)
  To: digoal@126.com; +Cc: pgsql-bugs

digoal@126.com writes:
> but when i use the other case, pgsql cann't compress the data, is the
> compress algorithm bug?

No compression algorithm can compress random data.  (If you find that
one can, it means the data isn't really random.)

			regards, tom lane


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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2015-10-30 15:12 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-10-30 01:56 BUG #13749: PostgreSQL cann't compress random data? digoal@126.com
2015-10-30 15:12 ` Tom Lane <tgl@sss.pgh.pa.us>

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