On Mon, 2021-03-15 at 13:58 +0200, Yambu wrote: > May I know why the below takes so long? > > > BEGIN; > select * from func1() ; > fetch all from "<unnamed portal 1>"; > end; > > Select * from func1() ; on its own is very fast The second just fetches a cursor for the query, the first executes the query. Executing the query is what can take long. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com