From: Craig James <craig_james@emolecules.com>
To: pgsql-performance@postgresql.org
Subject: Re: multiple table scan performance
Date: Tue, 29 Mar 2011 16:31:26 -0700
Message-ID: <4D926BCE.8000001@emolecules.com> (raw)
In-Reply-To: <AANLkTim2zSEznvRPJNqrDTfTmgRNCBWZs1KpdjTGEOL2@mail.gmail.com>
References: <AANLkTim2zSEznvRPJNqrDTfTmgRNCBWZs1KpdjTGEOL2@mail.gmail.com>
On 3/29/11 3:16 PM, Samuel Gendler wrote:
> I've got some functionality that necessarily must scan a relatively large table. Even worse, the total workload is actually 3 similar, but different queries, each of which requires a table scan. They all have a resultset that has the same structure, and all get inserted into a temp 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.
>
> I could figure it out empirically, but the queries are really slow on my dev laptop and I don't have access to the staging system at the moment. Also, it requires revamping a fair bit of code, so I figured it never hurts to ask. I don't have a sense of whether postgres is able to parallelize multiple subqueries via a single scan
You don't indicate how complex your queries are. If it's just a single table and the conditions are relatively simple, could you do something like this?
insert into (...) select ... where (...) OR (...) OR (...)
Craig
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 using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: craig_james@emolecules.com
Subject: Re: multiple table scan performance
In-Reply-To: <4D926BCE.8000001@emolecules.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