Move all the big queries in a PL/pgSQL function in separate .sql