Re: update query taking too long

From: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: update query taking too long
Date: 2007-06-28 06:28:26
Message-ID: 20070628062826.GC22066@a-kretschmer.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

am Thu, dem 28.06.2007, um 16:16:50 +1000 mailte Chris folgendes:
> Is there a better way to write the update? I thought about something
> like this (but couldn't get it working - guess I don't have the right
> syntax):
>
> update t1 set domainname=(select id, SUBSTRING(emailaddress FROM
> POSITION('@' IN emailaddress)) from table t2) AS t2 where t1.id=t2.id

test=# select * from foo;
id | mail | domain
----+-------------+--------
1 | foo(at)foo(dot)tld |
2 | bar(at)bar(dot)tld |
(2 rows)

test=*# update foo set domain=SUBSTRING(mail FROM (POSITION('@' IN
mail)+1));
UPDATE 2
test=*# select * from foo;
id | mail | domain
----+-------------+---------
1 | foo(at)foo(dot)tld | foo.tld
2 | bar(at)bar(dot)tld | bar.tld
(2 rows)

(without the @ in the domain...)

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

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Chris 2007-06-28 06:37:43 Re: update query taking too long
Previous Message Chris 2007-06-28 06:20:59 Re: update query taking too long