Can we execute a block of code outside of current session?
In other words, delegate the execution to another working thread, something like a dbms_job.submit
in Oracle.
I found only solutions involving external tools like Cron, but do not see any options to do it using PostgreSQL DBMS itself.
Example of simple long running block that I would like to run without blocking my current session:
DO
$do$
begin
FOR i IN 1..1000000
loop
// some long running inserts
insert into my_table(x) values (i);
commit;
end loop;
end $do$;