pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Yuri Budilov <yuri.budilov@hotmail.com>
Cc: John R Pierce <pierce@hogranch.com>
Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: JSON out of memory error on PostgreSQL 9.6.x
Date: Sun, 03 Dec 2017 19:01:09 -0500
Message-ID: <14018.1512345669@sss.pgh.pa.us> (raw)
In-Reply-To: <DM5PR13MB17557D9BE4B9846D16D05405993F0@DM5PR13MB1755.namprd13.prod.outlook.com>
References: <81363279.2185591.1511207314550.ref@mail.yahoo.com>
	<81363279.2185591.1511207314550@mail.yahoo.com>
	<CACqosVSBOQxtCKEipCX=uaf9s6LbDYiCQ__2Het7pzU6pq+smg@mail.gmail.com>
	<CAO32GkCcVOn6kums8mo1hGFHmsKkqoWMxTfD6yk3EmD5e48eZA@mail.gmail.com>
	<CANvgUk4=-Y6bDyc-oMU_pwbxip1iLH1OLVFC-gKR+UjAZMxiGA@mail.gmail.com>
	<6207.1511235609@sss.pgh.pa.us>
	<df175ae4-7522-0ee3-67c0-98b822c5c3e7@hogranch.com>
	<DM5PR13MB17557D9BE4B9846D16D05405993F0@DM5PR13MB1755.namprd13.prod.outlook.com>

Yuri Budilov <yuri.budilov@hotmail.com> writes:
> Posted on Stack Overflow, sadly no replies, so trying here....
> CREATE TABLE X AS
> SELECT json_array_elements(json_rmq -> 'orders'::text) AS order
> FROM table_name
> WHERE blah;
> I get out of memory error.
> The JSON column is about ~5 MB and it has about ~150,000 array row elements in 'orders' above.

I tried to reproduce that, and couldn't, given the available info.
I made a JSON value of more or less that size with

perl -e 'print "{\"orders\": [0"; for($i=1;$i<=150000;$i++){print ",$i"}; print "]}\n";' >jsonval

and then did

regression=# create table table_name(json_rmq json);
CREATE TABLE
regression=# \copy table_name from jsonval
COPY 1
regression=# insert into table_name select * from table_name;
INSERT 0 1
regression=# insert into table_name select * from table_name;
INSERT 0 2
regression=# insert into table_name select * from table_name;
INSERT 0 4
regression=# insert into table_name select * from table_name;
INSERT 0 8
regression=# insert into table_name select * from table_name;
INSERT 0 16
regression=# insert into table_name select * from table_name;
INSERT 0 32
regression=# insert into table_name select * from table_name;
INSERT 0 64
regression=# insert into table_name select * from table_name;
INSERT 0 128
regression=# CREATE TABLE X AS
SELECT json_array_elements(json_rmq -> 'orders'::text) AS order
FROM table_name;
SELECT 38400256

Watching the process with "top", its memory consumption stayed
rock-steady.  If there's a leak in there, this example doesn't
show it.  There could be a leak related to some detail you
failed to mention, but ...

			regards, tom lane




view thread (10+ messages)  latest in thread

Message-ID: <14018.1512345669@sss.pgh.pa.us>
Permalink:  ../14018.1512345669@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/14018.1512345669@sss.pgh.pa.us

 · 

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-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, yuri.budilov@hotmail.com, pierce@hogranch.com
  Subject: Re: JSON out of memory error on PostgreSQL 9.6.x
  In-Reply-To: <14018.1512345669@sss.pgh.pa.us>
  References: <81363279.2185591.1511207314550.ref@mail.yahoo.com> <81363279.2185591.1511207314550@mail.yahoo.com> <CACqosVSBOQxtCKEipCX=uaf9s6LbDYiCQ__2Het7pzU6pq+smg@mail.gmail.com> <CAO32GkCcVOn6kums8mo1hGFHmsKkqoWMxTfD6yk3EmD5e48eZA@mail.gmail.com> <CANvgUk4=-Y6bDyc-oMU_pwbxip1iLH1OLVFC-gKR+UjAZMxiGA@mail.gmail.com> <6207.1511235609@sss.pgh.pa.us> <df175ae4-7522-0ee3-67c0-98b822c5c3e7@hogranch.com> <DM5PR13MB17557D9BE4B9846D16D05405993F0@DM5PR13MB1755.namprd13.prod.outlook.com> <14018.1512345669@sss.pgh.pa.us>

* 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