Re: Importing a Large .ndjson file - Mailing list pgsql-general

From Tom Lane
Subject Re: Importing a Large .ndjson file
Date
Msg-id 1446220.1592407101@sss.pgh.pa.us
Whole thread Raw
In response to Importing a Large .ndjson file  (Sankar P <sankar.curiosity@gmail.com>)
Responses Re: Importing a Large .ndjson file
List pgsql-general
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



pgsql-general by date:

Previous
From: "Jim Hurne"
Date:
Subject: Re: Sv: autovacuum failing on pg_largeobject and disk usage of thepg_largeobject growing unchecked
Next
From: Joshua Drake
Date:
Subject: Re: Minor Upgrade Question