pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Chris <dmagick@gmail.com>
To: A. Kretschmer <andreas.kretschmer@schollglas.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: update query taking too long
Date: Thu, 28 Jun 2007 16:37:43 +1000
Message-ID: <46835737.8090307@gmail.com> (raw)
In-Reply-To: <20070628062826.GC22066@a-kretschmer.de>
References: <46834124.5010600@gmail.com>
	<21072.1183009270@sss.pgh.pa.us>
	<46835252.5070901@gmail.com>
	<20070628062826.GC22066@a-kretschmer.de>

A. Kretschmer wrote:
> 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@foo.tld |
>   2 | bar@bar.tld |
> (2 rows)
> 
> test=*# update foo set domain=SUBSTRING(mail FROM (POSITION('@' IN
> mail)+1));

That's what my original query is (apart from the +1 at the end) ;)

I was just trying to approach it differently with the other attempt.

-- 
Postgresql & php tutorials
http://www.designmagick.com/



view thread (14+ messages)  latest in thread

Message-ID: <46835737.8090307@gmail.com>
Permalink:  ../46835737.8090307@gmail.com/
Also on:    postgresql.org/message-id/46835737.8090307@gmail.com

 · 

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: dmagick@gmail.com, andreas.kretschmer@schollglas.com
  Subject: Re: update query taking too long
  In-Reply-To: <46835737.8090307@gmail.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