philippe_sabaa@hotmail.fr writes:
> We're running in an out of memory exception (failed on request of size
> Failed on request of size 775).
Looks to me like you need to reduce work_mem. Keep in mind that a
statement can consume work_mem for each sort or hash operation, and
this one seems to be running four separate hash joins.
Also, it's hard to tell from the information provided, but I wonder if
this is a 32-bit build of Postgres. If so, switching to a 64-bit build
would give you a lot more headroom.
regards, tom lane