0

is there a way to set a rate limit on the delete query(like 5 delete in 5 minutes) on a table in Postgresql to prevent DB users from deleting all data?

  • If your client app is written in Java you could use something like Bucket4j (very easy to use) to limit the cadence of operations. I'm sure there are similar libraries for other languages. – The Impaler Aug 04 '22 at 13:22
  • Look Into : https://stackoverflow.com/questions/5170546/how-do-i-delete-a-fixed-number-of-rows-with-sorting-in-postgresql – Sund'er Aug 04 '22 at 13:42
  • It is ok if they delete data the shouldn't as long as they take a long time to do it? – jjanes Aug 04 '22 at 15:23
  • A single DELETE statement could (at least in theory) empty an entire database. Do you want to count the number of statements that someone can execute or the number of rows? But why would you give somebody the permission to delete data, but then worry about the number of statements or records this person deletes? You just gave this person the permissions to do so... – Frank Heikens Aug 04 '22 at 15:28
  • Agreed that this should be handled mostly with users/roles and permissions. Furthermore, you could create functions to handle all of your deletes and cleanup. Then give permissions to execute certain functions to specific roles. If your DB is susceptible to a malicious delete all data, you have a lot of other configuration to consider. – J Spratt Aug 04 '22 at 15:56

0 Answers0