pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Alexander Voytsekhovskyy <young.inbox@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Query plan: SELECT vs INSERT from same select
Date: Tue, 23 Jul 2019 17:18:10 -0400
Message-ID: <29965.1563916690@sss.pgh.pa.us> (raw)
In-Reply-To: <CAPa4P2bv4KaoQvrn56FzWPEbnp6-oVO15VT7_GUJ5hnUNt0Beg@mail.gmail.com>
References: <CAPa4P2bv4KaoQvrn56FzWPEbnp6-oVO15VT7_GUJ5hnUNt0Beg@mail.gmail.com>

Alexander Voytsekhovskyy <young.inbox@gmail.com> writes:
> You can see explain analyze verbose here:
> https://explain.depesz.com/s/AEWj

> The problem is, when i wrap it to

> A)
> INSERT INTO norepl_1542_result (axis_x1, axis_y1, v_1)
> SELECT .... SAME QUERY

> OR even

> B)
> WITH rows AS (
> ... SAME SELECT QUERY ...
> )
> INSERT INTO norepl_1542_result (axis_x1, axis_y1, v_1)
> SELECT * FROM rows

> The query time dramatically drops to 500+ seconds.

> You can see explain analyze verbose here
> https://explain.depesz.com/s/AEWj

That's the same link.

> As you can see, 100% of time goes to same SELECT query, there is no issues
> with INSERT-part

We can't see any such thing from what you posted.

			regards, tom lane





view thread (5+ messages)  latest in thread

Message-ID: <29965.1563916690@sss.pgh.pa.us>
Permalink:  ../29965.1563916690@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/29965.1563916690@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, young.inbox@gmail.com
  Subject: Re: Query plan: SELECT vs INSERT from same select
  In-Reply-To: <29965.1563916690@sss.pgh.pa.us>
  References: <CAPa4P2bv4KaoQvrn56FzWPEbnp6-oVO15VT7_GUJ5hnUNt0Beg@mail.gmail.com> <29965.1563916690@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