pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Matthew Wakeling <matthew@flymine.org>
To: pgsql-performance@postgresql.org
Subject: Re: two memory-consuming postgres processes
Date: Sat, 3 May 2008 10:25:28 +0100 (BST)
Message-ID: <Pine.LNX.4.64.0805031019580.32064@aragorn.flymine.org> (raw)
In-Reply-To: <op.uajp1iotcigqcu@apollo13.peufeu.com>
References: <A728C858-76CF-473F-917B-3C9EA4AA75CF@gmail.com>
	<dcc563d10805021230i5916561k3962a41e2afa894c@mail.gmail.com>
	<27A4D379-2553-496D-A96C-102F2A5E62C2@gmail.com>
	<dcc563d10805021253n1589baa7u559fdfc8053d23d3@mail.gmail.com>
	<21403.1209759217@sss.pgh.pa.us>
	<72E02D29-848B-467A-AE6B-401568010254@gmail.com>
	<dcc563d10805021340u274ff4fegcf8902f66118d7c1@mail.gmail.com>
	<481B8160.2090106@emolecules.com>
	<C25E5DBA-B649-4483-B1A2-2A881522B891@gmail.com>
	<op.uajp1iotcigqcu@apollo13.peufeu.com>

On Fri, 2 May 2008, PFC wrote:
> CREATE TABLE derived AS SELECT ... FROM ... (perform all your derived 
> calculations here)

Given what you have said (that you really want all the data in one table) 
it may be best to proceed like this:

First, take your original table, create an index on the primary key field, 
and CLUSTER on that index.

CREATE TABLE derived AS SELECT ... FROM ... ORDER BY primary key field
CREATE INDEX derived_pk ON derived(primary key field)

Repeat those last two commands ad nauseum.

Then, when you want a final full table, run:

CREATE TABLE new_original AS SELECT * FROM original, derived, derived2,
       ... WHERE original.pk = derived.pk ...

That should be a merge join, which should run really quickly, and you can 
then create all the indexes you want on it.

Matthew

-- 
When I first started working with sendmail, I was convinced that the cf
file had been created by someone bashing their head on the keyboard. After
a week, I realised this was, indeed, almost certainly the case.
        -- Unknown



view thread (21+ messages)  latest in thread

Message-ID: <Pine.LNX.4.64.0805031019580.32064@aragorn.flymine.org>
Permalink:  ../Pine.LNX.4.64.0805031019580.32064@aragorn.flymine.org/
Also on:    postgresql.org/message-id/Pine.LNX.4.64.0805031019580.32064@aragorn.flymine.org

 · 

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: matthew@flymine.org
  Subject: Re: two memory-consuming postgres processes
  In-Reply-To: <Pine.LNX.4.64.0805031019580.32064@aragorn.flymine.org>
  References: <A728C858-76CF-473F-917B-3C9EA4AA75CF@gmail.com> <dcc563d10805021230i5916561k3962a41e2afa894c@mail.gmail.com> <27A4D379-2553-496D-A96C-102F2A5E62C2@gmail.com> <dcc563d10805021253n1589baa7u559fdfc8053d23d3@mail.gmail.com> <21403.1209759217@sss.pgh.pa.us> <72E02D29-848B-467A-AE6B-401568010254@gmail.com> <dcc563d10805021340u274ff4fegcf8902f66118d7c1@mail.gmail.com> <481B8160.2090106@emolecules.com> <C25E5DBA-B649-4483-B1A2-2A881522B891@gmail.com> <op.uajp1iotcigqcu@apollo13.peufeu.com> <Pine.LNX.4.64.0805031019580.32064@aragorn.flymine.org>

* 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