From: | Christophe Pettus <xof(at)thebuild(dot)com> |
---|---|
To: | Andrey Furs <aefurs93(at)gmail(dot)com> |
Cc: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | Re: ADD TO UPDATE LIMIT |
Date: | 2020-10-23 17:35:03 |
Message-ID: | 6E2FB117-52FA-44E4-B72D-B043163205A0@thebuild.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
> On Oct 23, 2020, at 09:36, Andrey Furs <aefurs93(at)gmail(dot)com> wrote:
>
> Hi there!
> Are you serious !?
> Postgresql not UPDATE LIMIT !?
>
> UPDATE table SET id=100 WHERE id<1000 LIMIT 1;
>
> OMG!
What does that even mean, though? There's no guarantee as to which row is going to be updated, even if that syntax worked. LIMIT without an ORDER BY is not statistically random enough to be useful for true randomness, but is not defined enough to be safe. What you probably want is:
UPDATE t SET id=100 WHERE id = ( SELECT id FROM t ORDER BY id LIMIT 1);
--
-- Christophe Pettus
xof(at)thebuild(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2020-10-23 18:06:45 | Re: ADD TO UPDATE LIMIT |
Previous Message | Andrey Furs | 2020-10-23 16:36:59 | ADD TO UPDATE LIMIT |