I have a function like below which upserts data from temp_table to main table. I\'m looking options to improve function execution time or improve performance of function. I\