Subject: Partitioning table - Update on partitioning key

From: Raj <[email-masked]>
Date: Thu, 21 May 2026 16:45:37 +0530

Hi,

Update happing on partition key.

And we get error 'Tuple to be locked was already moved to another partition
due to concurrent update error..

What's the best solution to handle it?

---

From: Laurenz Albe <[email-masked]>
Date: Thu, 21 May 2026 04:42:55 -0700

On Thu, 2026-05-21 at 16:45 +0530, Raj wrote:
> And we get error 'Tuple to be locked was already moved to another partition due to concurrent update error..
> 

Could you give us more context, like the exact statement and a description
of the data it is operating on?

If I had to guess, I would suspect that your UPDATE statement tries to modify
the same row more than once.

Yours,
Laurenz Albe

---

From: Raj <[email-masked]>
Date: Thu, 21 May 2026 21:41:55 +0530

No, updating the partition key (say colum created_at)....when u update the
date , say change march to April,  this record is in new partition and we
get this error

On Thu, 21 May 2026, 17:12 Laurenz Albe, <[email-masked]> wrote:

> > And we get error 'Tuple to be locked was already moved to another
> partition due to concurrent update error..
> >

---

From: Ron Johnson <[email-masked]>
Date: Thu, 21 May 2026 13:50:21 -0400

We'll need to see a "reproducer" (aka short bit of code that reproduces
your problem), with the output pasted here.

-- 
Death to <Redacted>, and butter sauce.
Don't boil me, I'm still alive.
<Redacted> lobster!

---

From: Raj <[email-masked]>
Date: Fri, 22 May 2026 19:53:51 +0530

The error occurs, due to updating the partition key column.

We recently migrated from oracle to postgres.

According to my research, columns that are updated frequently are not best
candidtae for partition key.

With isolation method read committed,  if there are concurrent updates on
the same row in different sessions for example( may be updated on different
columns out of which one update is on partition key),  updates on the
partition key, may cause the row placed to New partition.

Now, because of MVCC the second update may be looking for row to update in
the old partition itself and that's when we get error.

..

On Thu, 21 May 2026, 23:20 Ron Johnson, <[email-masked]> wrote:

>> No, updating the partition key (say colum created_at)....when u update
>> the date , say change march to April,  this record is in new partition and
>> we get this error
>>

---

From: Ron Johnson <[email-masked]>
Date: Fri, 22 May 2026 10:40:08 -0400

> candidtae for partition key.

Absolutely.  How is it even wise in Oracle?

---

From: Giovanni Martinez <[email-masked]>
Date: Fri, 22 May 2026 10:42:40 -0400

Hi Raj,

I encountered a similar situation in the past. To resolve it, I set up an
INSTEAD OF trigger that replaces updates on the partition key column with a
DELETE followed by an INSERT statement.

You might want to try a similar approach to handle the concurrent update
errors.

Best,
Giovanni Martinez

-- 
 <https://www.linkedin.com/in/gmartinez-dbai/>

*Giovanni Martinez*
IQtoolkit.ai | Principal AI Solutions Architect
[email-masked]
https://www.iqtoolkit.ai
Book a meeting <https://calendar.app.google/JoTjgsJg19xPbzS48>

-- 
Building the future of AI-driven database optimization.