Re: [SQL] More efficient DELETE ... ?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [SQL] More efficient DELETE ... ?
Дата
Msg-id 20925.948564467@sss.pgh.pa.us
обсуждение исходный текст
Ответ на More efficient DELETE ... ?  (The Hermit Hacker <scrappy@hub.org>)
Ответы Re: [SQL] More efficient DELETE ... ?  (Bruce Momjian <pgman@candle.pha.pa.us>)
Re: [SQL] More efficient DELETE ... ?  (The Hermit Hacker <scrappy@hub.org>)
Список pgsql-sql
The Hermit Hacker <scrappy@hub.org> writes:
> This looks painful ...

> DELETE FROM webhit_referer_raw
>       WHERE oid IN ( SELECT w.oid
>                        FROM webhit_referer_raw w, referrer_data r
>                       WHERE stat_date < 'Jan 17 2000 15:05:00'
>                         AND w.referrer_url = r.referrer );

I believe you can do

DELETE FROM webhit_referer_raw
WHERE referrer_url = referrer_data.referrer     AND referrer_data.stat_date < 'Jan 17 2000 15:05:00';

(I assume stat_date is in referrer_data, otherwise this'd be easy.)

This is an example where Postgres' willingness to create implicit FROM
clause entries is a win ... AFAIK you couldn't do it in standard SQL,
since for some reason DELETE doesn't take a FROM clause.
        regards, tom lane


В списке pgsql-sql по дате отправления:

Предыдущее
От: Mark Stosberg
Дата:
Сообщение: geo_distance radius question
Следующее
От: Web Manager
Дата:
Сообщение: Repost: restore from dump problem - query buffer full