Re: DELETE and UPDATE with LIMIT and ORDER BY

From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: Surafel Temesgen <surafel3000(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: DELETE and UPDATE with LIMIT and ORDER BY
Date: 2017-04-24 21:12:29
Message-ID: CAMkU=1znKFeTv_DgbMOt2gyGe8p7Js7Qcg4Gb16naFHZeD1H9Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Apr 24, 2017 at 8:09 AM, Surafel Temesgen <surafel3000(at)gmail(dot)com>
wrote:

> the necessity of allowing limit and order by clause to be used with delete
> and
> update statement is discussed in the past and added to the todo list
>
> preveouse mailing list descissions
>
> http://archives.postgresql.org/pgadmin-hackers/2010-04/msg00078.php
> http://archives.postgresql.org/pgsql-hackers/2010-11/msg01997.php
>

See this more recent one:

https://www.postgresql.org/message-id/flat/54102581(dot)2020207%40joh(dot)to#54102581(dot)2020207(at)joh(dot)to

That patch was not adopted, as I recall, mostly due to the requirement that
it support partitioned tables.

> i attached a small patch for its implementation.
>
> Notice : inorder to avoid unpredictable result the patch did not allow
> limit clause without order by and vise versal.
>

I think both of those are ill-advised. To avoid deadlock, it is perfectly
fine to want an order by without a limit.

And to facilitate the reorganization of partitions or the population of new
columns in bite-size chunks, it is also fine to want limit without order by.

Cheers,

Jeff

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2017-04-24 21:33:39 Re: Unportable implementation of background worker start
Previous Message Andres Freund 2017-04-24 21:07:54 Re: to-do item for explain analyze of hash aggregates?