Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XDHSw-0000Fh-Bx for pgsql-bugs@arkaria.postgresql.org; Fri, 01 Aug 2014 18:22:06 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XDHSv-00023v-Op for pgsql-bugs@arkaria.postgresql.org; Fri, 01 Aug 2014 18:22:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XDHSv-00023o-6V for pgsql-bugs@postgresql.org; Fri, 01 Aug 2014 18:22:05 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XDHSs-0006CE-67 for pgsql-bugs@postgresql.org; Fri, 01 Aug 2014 18:22:04 +0000 MIME-Version: 1.0 Subject: BUG #11109: No Toast compression on JSON, JSONB columns To: pgsql-bugs@postgresql.org From: ljw1001@gmail.com Date: Fri, 01 Aug 2014 18:21:02 +0000 Message-ID: <20140801182102.2696.87926@wrigleys.postgresql.org> X-Pg-Spam-Score: -0.1 (/) Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org The following bug has been logged on the website: Bug reference: 11109 Logged by: Larry White Email address: ljw1001@gmail.com PostgreSQL version: 9.4beta2 Operating system: OSX Mavericks Description: if PG can, after compression, put an entire JSON or JSONB 'document' into one row/page in the toast table it does. However, if the document is too big to fit in one row after compression, it does no compression at all. I created a test Json file (in part) with this loop: for (int j = 0; j < 110; j++) { mediumPayload.getJunk().add("124245etweetwet345gwtretwt43 qwrqwq qwre qw rsdflkas"); mediumPayload.getJunk().add("q4535 wqrqwrqwrqw2 wrqwrqwrq32232w kswe sfasrs sdfsd"); } if the loop runs 110 times as shown, it compresses. if the loop runs 111 times, it does not: With 110 iterations: Extended 8192 bytes (one page) External 66 MB With 111 iterations: Extended 69 MB External 69 MB This is not the behavior observed with Text compression in Toast. For very large files Text compression works correctly. I got these results running similar tests on larger json files: Column Type - Storage - TOAST table size JSONB - EXTERNAL - 2448 MB JSONB - EXTENDED - 2448 MB JSON - EXTENDED - 2504 MB TEXT - EXTERNAL - 2409 MB TEXT - EXTENDED - 40 MB To Recreate: Take a json file that is too large to compress into a single page. insert it into a table and check the size of the Toast table. Repeat with a file that is small enough to fit into a single page when compressed (but bigger than the Toast minimum size). The first file will have no compression and the second file will compress correctly. -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs