Hi Zoltan, I haven’t needed to use a cursor in 20 years of sometimes very complex sql coding. Why? Cursors result in RBAR (row by agonizing row) operation which eliminates the power of set-based sql operations. Performance will always suffer – sometimes to extremes. I’m all about fastest possible performance for a given sql solution. How? There have been times I’ve initially said a similar thing – “I don’t see how to solve this without a cursor”. When I hit that point, I stop and decompose the problem into simpler bits, and soak on it and always – literally always – a solution will appear. It’s all in how we envision the solution, especially with Postgres and its amazing ecosystem of sql functions. We really can do almost anything. Since the code is obviously way to complex to post here, I’d simply encourage you to rethink how you’re approaching the solution. Mike From: Szalontai Zoltán <szalontai.zoltan@xxxxxxxxxxx> Hi Milos, Inside the loops there are frequently if / else branches value transformations used. We could not solve it without using a cursor. Regards, Zoltán From: Milos Babic <milos.babic@xxxxxxxxx> Hi Zoltan, is there any particular reason why you don't do a bulk insert as: insert into target_table select ... from source_table(s) (with joins etc) Regards, Milos On Thu, Apr 8, 2021 at 1:24 PM Szalontai Zoltán <szalontai.zoltan@xxxxxxxxxxx> wrote:
-- Milos Babic |