pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Marti Raudsepp <marti@juffo.org>
To: Samuel Gendler <sgendler@ideasculptor.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: multiple table scan performance
Date: Wed, 30 Mar 2011 03:05:08 +0300
Message-ID: <AANLkTi=KVHc1+f8td00U-d0KAJXuZ95JL0773-whYP4d@mail.gmail.com> (raw)
In-Reply-To: <AANLkTim2zSEznvRPJNqrDTfTmgRNCBWZs1KpdjTGEOL2@mail.gmail.com>
References: <AANLkTim2zSEznvRPJNqrDTfTmgRNCBWZs1KpdjTGEOL2@mail.gmail.com>

On Wed, Mar 30, 2011 at 01:16, Samuel Gendler <sgendler@ideasculptor.com> wrote:
> I've got some functionality that necessarily must scan a relatively large table

> Is there any performance benefit to revamping the workload such that it issues
> a single:
> insert into (...) select ... UNION select ... UNION select
> as opposed to 3 separate "insert into () select ..." statements.

Apparently not, as explained by Claudio Freire. This seems like missed
opportunity for the planner, however. If it scanned all three UNION
subqueries in parallel, the synchronized seqscans feature would kick
in and the physical table would only be read once, instead of 3 times.

(I'm assuming that seqscan disk access is your bottleneck)

You can trick Postgres (8.3.x and newer) into doing it in parallel
anyway: open 3 separate database connections and issue each of these
'INSERT INTO ... SELECT' parts separately.  This way all the queries
should execute in about 1/3 the time, compared to running them in one
session or with UNION ALL.

Regards,
Marti



view thread (5+ messages)  latest in thread

Message-ID: <AANLkTi=KVHc1+f8td00U-d0KAJXuZ95JL0773-whYP4d@mail.gmail.com>
Permalink:  ../AANLkTi=KVHc1+f8td00U-d0KAJXuZ95JL0773-whYP4d@mail.gmail.com/
Also on:    postgresql.org/message-id/AANLkTi=KVHc1+f8td00U-d0KAJXuZ95JL0773-whYP4d@mail.gmail.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-performance@postgresql.org
  Cc: marti@juffo.org, sgendler@ideasculptor.com
  Subject: Re: multiple table scan performance
  In-Reply-To: <AANLkTi=KVHc1+f8td00U-d0KAJXuZ95JL0773-whYP4d@mail.gmail.com>
  References: <AANLkTim2zSEznvRPJNqrDTfTmgRNCBWZs1KpdjTGEOL2@mail.gmail.com> <AANLkTi=KVHc1+f8td00U-d0KAJXuZ95JL0773-whYP4d@mail.gmail.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