Re: deletion of records - Mailing list pgsql-general

From Chris Albertson
Subject Re: deletion of records
Date
Msg-id 20020712180334.17995.qmail@web14707.mail.yahoo.com
Whole thread Raw
In response to deletion of records  ("Dorward Villaruz" <dorwardv@ntsp.nec.co.jp>)
List pgsql-general
--- Dorward Villaruz <dorwardv@ntsp.nec.co.jp> wrote:
>
> here is my sql statement
>
> psql -h $HOSTNAME -d $DBNAME -c "DELETE FROM custinfo WHERE
> custinfo.UserID IN (SELECT custinfotemp.userid FROM custinfotemp
> where updateStatus='D')";

Try this

DELETE FROM custinfo
WHERE
  custinfo.UserID           = custinfotemp.userid AND
  custinfotemp.updateStatus = 'D';

It would be good to have indexs on UserID on both tables.

Seeing a table named "custinfotemp" kind of raises a red
flag.  Possibly you may want to re-think the design if
you are moving data between tables that is really the
same data.


=====
Chris Albertson
  Home:   310-376-1029  chrisalbertson90278@yahoo.com
  Cell:   310-990-7550
  Office: 310-336-5189  Christopher.J.Albertson@aero.org

__________________________________________________
Do You Yahoo!?
Sign up for SBC Yahoo! Dial - First Month Free
http://sbc.yahoo.com

pgsql-general by date:

Previous
From: Elaine Lindelef
Date:
Subject: Re: MySQL vs. PostgreSQL
Next
From: reina@nsi.edu (Tony Reina)
Date:
Subject: Re: 7.2.1 optimises very badly against 7.2