Re: delete to slow - Mailing list pgsql-admin

From Tom Lane
Subject Re: delete to slow
Date
Msg-id 23990.1114300420@sss.pgh.pa.us
Whole thread Raw
In response to Re: delete to slow  ("Spiegelberg, Greg" <gspiegelberg@cranel.com>)
List pgsql-admin
"Spiegelberg, Greg" <gspiegelberg@cranel.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

pgsql-admin by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Product Suggestions
Next
From: Tom Lane
Date:
Subject: Re: FW: PostgreSQL (real and effective user ids must match) error