From: | Alexander Farber <alexander(dot)farber(at)gmail(dot)com> |
---|---|
To: | |
Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: From select to delete |
Date: | 2011-10-30 12:53:53 |
Message-ID: | CAADeyWje1A=JrkdAj4ij8xNZLCmBVyk7LxJ7wB=qGeggKH-1jg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I've got another great advice to use DELETE ... USING
instead of DELETE ... (SUB-SELECT),
so my procedure looks now like this (for archive):
create or replace function pref_delete_user(_id varchar,
_reason varchar) returns void as $BODY$
begin
create temporary table temp_gids (gid int not null) on
commit drop;
insert into temp_gids (gid) select gid from
pref_scores where id=_id;
delete from pref_scores p
using temp_gids t
where p.gid = t.gid;
delete from pref_games p
using temp_gids t
where p.gid = t.gid;
/* more delete's here */
end;
$BODY$ language plpgsql;
From | Date | Subject | |
---|---|---|---|
Next Message | Devrim GÜNDÜZ | 2011-10-30 21:28:52 | Re: Why is there no 8.3.16 rpm with _id ? |
Previous Message | Dave Page | 2011-10-30 09:53:57 | Re: Why is there no 8.3.16 rpm with _id ? |