Re: delete to slow

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Spiegelberg, Greg" <gspiegelberg(at)cranel(dot)com>
Cc: "Bruno Wolff III" <bruno(at)wolff(dot)to>, Ricardo Valença de Assis <valenca(at)campusvirtual(dot)br>, pgsql-admin(at)postgresql(dot)org
Subject: Re: delete to slow
Date: 2005-04-23 23:53:40
Message-ID: 23990.1114300420@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

"Spiegelberg, Greg" <gspiegelberg(at)cranel(dot)com> writes:
> Would it be possible to perform a DELETE FROM table WHERE CURRENT OF mycursor?
> Is this implemented in Postgres? I'm not seeing in in the manual for 7.4 or 8.

It is (or at least ought to be) on the TODO list, but it's not done yet
and I don't think anyone's working on it.

A reasonably efficient way to fake it is to include CTID in the cursor
readout and issue a delete-by-ctid instead.

DECLARE c CURSOR FOR SELECT ctid, ... FROM mytable WHERE ...;
FETCH FROM c;
DELETE FROM mytable WHERE ctid = 'whatever';

This is more or less what would have to happen behind the scenes for
WHERE CURRENT OF to be implemented.

regards, tom lane

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Tom Lane 2005-04-24 00:12:44 Re: FW: PostgreSQL (real and effective user ids must match) error
Previous Message Alvaro Herrera 2005-04-23 21:03:17 Re: Product Suggestions