pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: A. Kretschmer <andreas.kretschmer@schollglas.com>
To: pgsql-performance@postgresql.org
Subject: Re: update query taking too long
Date: Thu, 28 Jun 2007 07:37:25 +0200
Message-ID: <20070628053724.GB22066@a-kretschmer.de> (raw)
In-Reply-To: <46834124.5010600@gmail.com>
References: <46834124.5010600@gmail.com>

am  Thu, dem 28.06.2007, um 15:03:32 +1000 mailte Chris folgendes:
> Hi all,
> 
> I'm trying to do an update of a reasonably large table and it's taking 
> way too long so I'm trying to work out why and if I need to tweak any 
> settings to speed it up.
> 
> The table is around 3.5 million records.
> 
> The query is
> 
> update table set domainname=substring(emailaddress from position('@' in 
> emailaddress));

I think, this is a bad idea.
Because, first, you have 2 columns with nearly identical data
(mailaddres includes the domain and a extra domain field)

And, after the UPDATE you have every row twice, because of MVCC: the
live tuple and a dead tuple.


> Any pointers about settings etc are most welcome.

I think, you should better use a VIEW.

CREATE VIEW my_view_on_table as SELECT mailaddres, substring(...) as
domain, ...

or, use the substring(...) in your regular queries instead the extra
column.


Andreas
-- 
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net



view thread (14+ messages)  latest in thread

Message-ID: <20070628053724.GB22066@a-kretschmer.de>
Permalink:  ../20070628053724.GB22066@a-kretschmer.de/
Also on:    postgresql.org/message-id/20070628053724.GB22066@a-kretschmer.de

 · 

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: andreas.kretschmer@schollglas.com
  Subject: Re: update query taking too long
  In-Reply-To: <20070628053724.GB22066@a-kretschmer.de>

* 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