pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Sankar P <sankar.curiosity@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Importing a Large .ndjson file
Date: Wed, 17 Jun 2020 11:18:21 -0400
Message-ID: <1446220.1592407101@sss.pgh.pa.us> (raw)
In-Reply-To: <CAMSEaH5SfyfXN_rSah41dOOA_aAik4hZED0qp52=1wqzjz-pMA@mail.gmail.com>
References: <CAMSEaH5SfyfXN_rSah41dOOA_aAik4hZED0qp52=1wqzjz-pMA@mail.gmail.com>

Sankar P <sankar.curiosity@gmail.com> writes:
> I have a .ndjson file. It is a new-line-delimited JSON file. It is
> about 10GB and has about 100,000 records.
> Some sample records:
> { "key11": "value11", "key12": [ "value12.1", "value12.2"], "key13": {
> "k111": "v111" } } \n\r
> { "key21": "value21", "key22": [ "value22.1", "value22.2"] }

> What is the best way to do this on a postgresql database, deployed in
> kubernetes, with a 1 GB RAM allocated ?

It looks like plain old COPY would do this just fine, along the lines
of (in psql)

\copy myTable(content) from 'myfile.ndjson'

If the newlines actually are \n\r rather than the more usual \r\n,
you might have to clean that up to stop COPY from thinking they
represent two line endings not one.

I'd advise extracting the first hundred or so lines of the file and doing
a test import into a temporary table, just to verify the process.

			regards, tom lane





view thread (7+ messages)  latest in thread

Message-ID: <1446220.1592407101@sss.pgh.pa.us>
Permalink:  ../1446220.1592407101@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1446220.1592407101@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, sankar.curiosity@gmail.com
  Subject: Re: Importing a Large .ndjson file
  In-Reply-To: <1446220.1592407101@sss.pgh.pa.us>
  References: <CAMSEaH5SfyfXN_rSah41dOOA_aAik4hZED0qp52=1wqzjz-pMA@mail.gmail.com> <1446220.1592407101@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