Vladimir Ryabtsev <greatvovan@xxxxxxxxx> writes: > I see some recommendations in Internet to do like this (e.g. > https://stackoverflow.com/questions/5170546/how-do-i-delete-a-fixed-number-of-rows-with-sorting-in-postgresql > ). > Did it really work in 2011? No, or at least not any better than today. (For context, "git blame" says I wrote the comment I just quoted to you in 2005. The feature it says isn't there wasn't there before that, either.) > Anyway I think the problem is pretty clear: I want to eventually clear the > table based on the predicate but I don't want to lock it for a long time. DELETE doesn't lock the whole table. What problem are you actually facing? regards, tom lane