79749584

Date: 2025-08-28 20:54:56
Score: 0.5
Natty:
Report link

This was a headscratcher for us.

The transactions with "delete from x where x.y is less than N" were simply too much, even when limiting the delete - we were constantly running into concurrency issues with ongoing traffic, clogging of the DB etc.

What worked out the best for us was a solution where:

  1. Run deleting in night hours when the traffic is not that huge

  2. Instead of "delete from x where x.y < N", we ran 2 queries in loop
    - "select id from x where x.y < N"
    - "delete from x where id in M" (M from previous query)

I do not remember specifics about this type of deleting,
but it was much more performant,
and it wasn't causing as much concurrency issues with ongoing traffic

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (0.5):
Posted by: El El