Re: Suggestion to reduce COPY command output to csv file

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: postggen2020 s <postggen2020(at)gmail(dot)com>
Cc: pgsql-admin <pgsql-admin(at)postgresql(dot)org>, pgsql-general <pgsql-general(at)postgresql(dot)org>, Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
Subject: Re: Suggestion to reduce COPY command output to csv file
Date: 2020-03-04 21:40:48
Message-ID: CAKFQuwbAdYKjJART6wAoiJXQUcZYCAwJ_eb8q46MQJK_KG=jMQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-general

On Wed, Mar 4, 2020 at 11:39 AM postggen2020 s <postggen2020(at)gmail(dot)com>
wrote:

> Hi Team,
> Thanks a lot all of you, for providing support peoples like me.
> Could you please provide a suggestion on COPY command.
>
> Environment:
> DB Version:9.5.15
> postgis:
> Table contain GIS data.
>
> I have a table with GIS data, its around 300MB and 2Lacks+ records. I want
> to export all the records to the CSV file. I can able to export the table
> data into a CSV file, but the exported CSV file size around 162MB.
> While I am trying to opening the excel it is taking a long time and also
> while applying vlookup excel is getting hang.
>
> I am using below command :
> \copy cities TO '/var/lib/pgsql/cities.csv' (DELIMITER ',', FORMAT 'csv',
> HEADER)
>
> I am trying to achieve the following :
> 1. The exported CSV file should have within 10MB.
>

Then you probably need to redefine your problem and solution.

> 2. The excel file should open quickly and able to perform vlookups without
> any problems(like hang).
>

See #1

>
> Could you please provide suggestions on below queries:
> 1. what I am trying to achieve, is the right assumption?.
>

Not really...

> 2. Can we use this command to use for the above use case?.
>

Not without changing your approach to the problem...in which case \copy may
or may not be a useful tool

3. Is there any tool/extension available for the above use case.?
>

Not sure on an additive suggestion but you probably can get considerable
mileage by removing Excel from the equation and bring the external data
into PostgreSQL and use joins (i.e., SQL's version of VLOOKUP).

David J.

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Bo Victor Thomsen 2020-03-05 07:22:08 Re: Suggestion to reduce COPY command output to csv file
Previous Message Alvaro Herrera 2020-03-04 20:52:56 Re: Autovacuum/Analyze Doesn't seem to be running properly

Browse pgsql-general by date

  From Date Subject
Next Message Rory Campbell-Lange 2020-03-04 22:04:26 Advice request : simultaneous function/data updates on many databases
Previous Message John DeSoi 2020-03-04 20:57:18 Re: Postgres on macOS 10