pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: D'Arcy J.M. Cain <darcy@druid.net>
To: Kynn Jones <kynnjo@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: How to "unique-ify" HUGE table?
Date: Tue, 23 Dec 2008 12:39:17 -0500
Message-ID: <20081223123917.df2f8c0e.darcy@druid.net> (raw)
In-Reply-To: <c2350ba40812230925jb50fed7h3dc58cc311888c7f@mail.gmail.com>
References: <c2350ba40812230925jb50fed7h3dc58cc311888c7f@mail.gmail.com>

On Tue, 23 Dec 2008 12:25:48 -0500
"Kynn Jones" <kynnjo@gmail.com> wrote:
> Hi everyone!
> I have a very large 2-column table (about 500M records) from which I want to
> remove duplicate records.
> 
> I have tried many approaches, but they all take forever.
> 
> The table's definition consists of two short TEXT columns.  It is a
> temporary table generated from a query:
> 
> CREATE TEMP TABLE huge_table AS SELECT x, y FROM ... ;
> 
> Initially I tried
> 
>  CREATE TEMP TABLE huge_table AS SELECT DISTINCT x, y FROM ... ;
> 
> but after waiting for nearly an hour I aborted the query, and repeated it

Do you have an index on x and y?  Also, does this work better?

CREATE TEMP TABLE huge_table AS SELECT x, y FROM ... GROUP BY x, y;

What does ANALYZE EXPLAIN have to say?

-- 
D'Arcy J.M. Cain <darcy@druid.net>         |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.



view thread (7+ messages)  latest in thread

Message-ID: <20081223123917.df2f8c0e.darcy@druid.net>
Permalink:  ../20081223123917.df2f8c0e.darcy@druid.net/
Also on:    postgresql.org/message-id/20081223123917.df2f8c0e.darcy@druid.net

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: darcy@druid.net, kynnjo@gmail.com
  Subject: Re: How to "unique-ify" HUGE table?
  In-Reply-To: <20081223123917.df2f8c0e.darcy@druid.net>

* 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