On Tue, Oct 2, 2018 at 3:44 PM, pinker <pinker@xxxxxxx> wrote: ... > Yes, I do try to convince them to do it outside the db, that's the reason > I'm looking for some support here :) I'm not sure those 2 reasons are enough > to convince them, wanted to be prepared... Well, not knowing the logic I cannot be sure, but you can try the "it depends on isolation level" I pointed to. > You know it's always time to do refactoring and in this case it's a lot of > time because of the amount and complexity of the logic in db. Not having seen it, I trust your word. But I doubt the dessign can be correct, it seems a case of "all I know is pl/xx, so I'll do everything I can in it. I got one product with a similar problem in Oracle. But unless the logic is really perverse, it seems to me you could do two procs, the normal one ( without the pg_sleep in a loop ), and a wrapping one testing for the "data appears" condition and calling the first, and call the second in a loop. But again, details will be needed and trusting your words I do not want them on the list ;-> . Francisco Olarte.