pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Lian Jiang <jiangok2006@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: speed up full table scan using psql
Date: Thu, 1 Jun 2023 08:03:53 -0700
Message-ID: <8bee33fc-9b8d-94d9-6fe3-256db822f75f@aklaver.com> (raw)
In-Reply-To: <CA+aY8X6+ENwVh0megxbHczoX-W-Yd6BmHKRUYS3MJNLGLJDz_w@mail.gmail.com>
References: <CA+aY8X6E6qq-i_10G_wTjkorEtm3XYW+Ag+83xk7gmJUoAoing@mail.gmail.com>
	<c4bfbccc-b004-5830-ade9-c1a12db91e8a@aklaver.com>
	<CA+aY8X4Wn2KBDYsqspPOoWUybsB1Jh6yfBVChMSHxVkuRVm3VQ@mail.gmail.com>
	<dba5964e-e9fb-dddd-328c-6add2b9993cf@aklaver.com>
	<CA+aY8X6+ENwVh0megxbHczoX-W-Yd6BmHKRUYS3MJNLGLJDz_w@mail.gmail.com>

On 5/31/23 22:51, Lian Jiang wrote:
> The whole command is:
> 
> psql %(pg_uri)s -c %(sql)s | %(sed)s | %(pv)s | %(split)s) 2>&1 | %(tr)s
> 
> where:
> sql is "copy (select row_to_json(x_tmp_uniq) from public.mytable 
> x_tmp_uniq) to stdout"
> sed, pv, split, tr together format and split the stdout into jsonl files.

Well that is quite the pipeline. At this point I think you need to do 
some testing on your end. First create a table that is a subset of the 
original data to make testing a little quicker.  Then break the process 
down into smaller actions. Start with just doing a COPY direct to CSV 
and one with the row_to_json to see if that makes a difference. Then 
COPY directly to a file before applying the above pipeline. There are 
more ways you can slice this depending on what the preceding shows you.

> 
> Hope this helps.

-- 
Adrian Klaver
adrian.klaver@aklaver.com






view thread (12+ messages)

Message-ID: <8bee33fc-9b8d-94d9-6fe3-256db822f75f@aklaver.com>
Permalink:  ../8bee33fc-9b8d-94d9-6fe3-256db822f75f@aklaver.com/
Also on:    postgresql.org/message-id/8bee33fc-9b8d-94d9-6fe3-256db822f75f@aklaver.com

 · 

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: adrian.klaver@aklaver.com, jiangok2006@gmail.com
  Subject: Re: speed up full table scan using psql
  In-Reply-To: <8bee33fc-9b8d-94d9-6fe3-256db822f75f@aklaver.com>
  References: <CA+aY8X6E6qq-i_10G_wTjkorEtm3XYW+Ag+83xk7gmJUoAoing@mail.gmail.com> <c4bfbccc-b004-5830-ade9-c1a12db91e8a@aklaver.com> <CA+aY8X4Wn2KBDYsqspPOoWUybsB1Jh6yfBVChMSHxVkuRVm3VQ@mail.gmail.com> <dba5964e-e9fb-dddd-328c-6add2b9993cf@aklaver.com> <CA+aY8X6+ENwVh0megxbHczoX-W-Yd6BmHKRUYS3MJNLGLJDz_w@mail.gmail.com> <8bee33fc-9b8d-94d9-6fe3-256db822f75f@aklaver.com>

* 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