title: It seems that mongoDB compression does not work properly
body: <p>Nginx + php-fpm + mongoDB(+mongodb php-lib)</p>
  <p>trying to compare the compression rate of mongoDB
  but, the results are not as expected.
  Here are my experiments.</p>
  <pre><code>/etc/mongod.conf  
  
  # mongod.conf  //default setting
  
  # for documentation of all options, see:
  #   http://docs.mongodb.org/manual/reference/configuration-options/
  
  # Where and how to store data.
  storage:
    dbPath: /var/lib/mongodb
    journal:
      enabled: true
  #  engine:
  #  mmapv1:
  #  wiredTiger:
  
  # where to write logging data.
  systemLog:
    destination: file
    logAppend: true
    path: /var/log/mongodb/mongod.log
  
  # network interfaces
  net:
    port: 27017
    bindIp: 127.0.0.1
  
  # how the process runs
  processManagement:
    timeZoneInfo: /usr/share/zoneinfo
  
  #security:
  #operationProfiling:
  #replication:
  #sharding:
  ## Enterprise-Only Options:
  #auditLog:
  #snmp:
  </code></pre>
  <blockquote>
  <p>Setting compression when creating collection in mongoDB shell</p>
  <p>mongoDB shell&gt; db.createCollection( &quot;test&quot;,{storageEngine:{wiredTiger:{configString:'block_compressor=none, prefix_compression=false'}}})</p>
  <p>The compression options are set to 6 in total</p>
  <p>block_compressor = none or snappy or zlib // prefix_compression = false or true</p>
  <p>When checked with db.printCollectionStats(), the options were applied correctly.</p>
  </blockquote>
  <p>insert data size is 100KB * 100000 = about 9GB.</p>
  <p>but db.test.storageSize() result.</p>
  <p>block_compression none = 10653536256 (byte)</p>
  <p>block_compression snappy = 10653405184 (byte)</p>
  <p>block_compression zlib = 6690177024 (byte)</p>
  <p>zlib  is about 40% compressed compared to none.
  but, none and snappy are not different.</p>
  <p>(prefix_compress is also unchanged.)</p>
  <p>What settings should I add?</p>
  <p>+UPDATE</p>
  <p>snappy+false</p>
  <pre><code>&quot;compression&quot; : {
              &quot;compressed pages read&quot; : 0,
              &quot;compressed pages written&quot; : 0,
              &quot;page written failed to compress&quot; : 100007,
              &quot;page written was too small to compress&quot; : 1025
         }
  </code></pre>
  <p>zlib+false</p>
  <pre><code>&quot;compression&quot; : {
              &quot;compressed pages read&quot; : 0,
              &quot;compressed pages written&quot; : 98881,
              &quot;page written failed to compress&quot; : 0,
              &quot;page written was too small to compress&quot; : 924
         }
  </code></pre>
  <p>what is &quot;page written failed to compress&quot; mean?
  What is the solution?</p>
  <p>+update2</p>
  <p>used mongoDB server version: 4.0.9</p>
  <pre><code>insert data document
  
  $result = $collection-&gt;insertOne( ['num'=&gt; (int)$i , 
                                      'title' =&gt; &quot;$i&quot;, 
                                      'main' =&gt; &quot;$i&quot;, 
                                      'img' =&gt; &quot;$t&quot;,
                                      'user'=&gt;&quot;$users&quot;, 
                                      'like'=&gt; 0,
                                      'time'=&gt; &quot;$date&quot; ] );
  
  ---Variable Description---
  $i = 1 ~ 100,000 (Increment by 1)
  $t = 100KB(102400byt) random string 
  $users =  (Random 10 characters in 12134567890abcdefghij)
  $data =  Real-time server date (ex = 2019:05:18 xx.xx.xx)
  
  index 
  db.test.createIndex( { &quot;num&quot;:1 } )
  db.test.createIndex( { &quot;title&quot;:1 } )
  db.test.createIndex( { &quot;user&quot;:1 } )
  db.test.createIndex( { &quot;like&quot;:1 } )
  db.test.createIndex( { &quot;time&quot;:1 } )     
  </code></pre>
  <p>collection stats is too long so I will put only two.</p>
  <p>snappy+false</p>
  <blockquote>
  <p>&quot;creationString&quot; : &quot;access_pattern_hint=none,allocation_size=4KB,app_metadata=(formatVersion=1),assert=(commit_timestamp=none,read_timestamp=none),block_allocation=best,<strong>block_compressor=snappy</strong>,cache_resident=false,checksum=on,colgroups=,collator=,columns=,dictionary=0,encryption=(keyid=,name=),exclusive=false,extractor=,format=btree,huffman_key=,huffman_value=,ignore_in_memory_cache_size=false,immutable=false,internal_item_max=0,internal_key_max=0,internal_key_truncate=true,internal_page_max=4KB,key_format=q,key_gap=10,leaf_item_max=0,leaf_key_max=0,leaf_page_max=32KB,leaf_value_max=64MB,log=(enabled=true),lsm=(auto_throttle=true,bloom=true,bloom_bit_count=16,bloom_config=,bloom_hash_count=8,bloom_oldest=false,chunk_count_limit=0,chunk_max=5GB,chunk_size=10MB,merge_custom=(prefix=,start_generation=0,suffix=),merge_max=15,merge_min=0),memory_page_image_max=0,memory_page_max=10m,os_cache_dirty_max=0,os_cache_max=0,<strong>prefix_compression=false</strong>,prefix_compression_min=4,source=,split_deepen_min_child=0,split_deepen_per_child=0,split_pct=90,type=file,value_format=u&quot;,</p>
  </blockquote>
  <p>snappy+true</p>
  <blockquote>
  <p>&quot;creationString&quot; : &quot;access_pattern_hint=none,allocation_size=4KB,app_metadata=(formatVersion=1),assert=(commit_timestamp=none,read_timestamp=none),block_allocation=best,<strong>block_compressor=snappy</strong>,cache_resident=false,checksum=on,colgroups=,collator=,columns=,dictionary=0,encryption=(keyid=,name=),exclusive=false,extractor=,format=btree,huffman_key=,huffman_value=,ignore_in_memory_cache_size=false,immutable=false,internal_item_max=0,internal_key_max=0,internal_key_truncate=true,internal_page_max=4KB,key_format=q,key_gap=10,leaf_item_max=0,leaf_key_max=0,leaf_page_max=32KB,leaf_value_max=64MB,log=(enabled=true),lsm=(auto_throttle=true,bloom=true,bloom_bit_count=16,bloom_config=,bloom_hash_count=8,bloom_oldest=false,chunk_count_limit=0,chunk_max=5GB,chunk_size=10MB,merge_custom=(prefix=,start_generation=0,suffix=),merge_max=15,merge_min=0),memory_page_image_max=0,memory_page_max=10m,os_cache_dirty_max=0,os_cache_max=0,<strong>prefix_compression=true</strong>,prefix_compression_min=4,source=,split_deepen_min_child=0,split_deepen_per_child=0,split_pct=90,type=file,value_format=u&quot;,</p>
  </blockquote>
  <p>Thank you for your interest.</p>