Re: [HACKERS] Efficient DELETE Strategies

From: Hannu Krosing <hannu(at)tm(dot)ee>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Christoph Haller <ch(at)rodos(dot)fzk(dot)de>, pgsql-sql(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [HACKERS] Efficient DELETE Strategies
Date: 2002-06-11 10:02:49
Message-ID: 1023789769.6942.44.camel@taru.tm.ee
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-sql

On Tue, 2002-06-11 at 04:53, Bruce Momjian wrote:
> Tom Lane wrote:
> > Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > > Hannu Krosing wrote:
> > >> What about
> > >>
> > >> DELETE relation_expr FROM relation_expr [ , table_ref [ , ... ] ]
> > >> [ WHERE bool_expr ]
> > >>
> > >> or
> > >>
> > >> DELETE relation_expr.* FROM relation_expr [ , table_ref [ , ... ] ]
> > >> [ WHERE bool_expr ]
> >
> > > So make the initial FROM optional and allow the later FROM to be a list
> > > of relations? Seems kind of strange.

I was inspired by MS Access syntax that has optional relation_expr.* :

DELETE [relation_expr.*] FROM relation_expr WHERE criteria

it does not allow any other tablerefs in from

> Clearly this is a TODO item. I will document it when we decide on a
> direction.

Or then we can just stick with standard syntax and teach people to do

DELETE FROM t1 where t1.id1 in
(select id2 from t2 where t2.id2 = t1.id1)

and perhaps even teach our optimizer to add the t2.id2 = t1.id1 part
itself to make it fast

AFAIK this should be exactly the same as the proposed

DELETE FROM t1 FROM t2
WHERE t2.id2 = t1.id1

--------------
Hannu

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Lee Kindness 2002-06-11 10:51:50 Re: Bug #640: ECPG: inserting float numbers
Previous Message Bruce Momjian 2002-06-11 09:56:51 Re: Project scheduling issues (was Re: Per tuple overhead,

Browse pgsql-sql by date

  From Date Subject
Next Message Christoph Haller 2002-06-11 11:18:34 Re: Efficient DELETE Strategies
Previous Message Achilleus Mantzios 2002-06-11 06:44:32 Re: [SQL] VIEWs and FOREIGN keys